gosnow: github.com/kujenga/gosnow Index | Files

package gosnow

import "github.com/kujenga/gosnow"

Index

Package Files

blueprint.go parser.go sourcemap.go

Constants

const (
    NoWarning                 = 0
    APINameWarning            = 1
    DuplicateWarning          = 2
    FormattingWarning         = 3
    RedefinitionWarning       = 4
    IgnoringWarning           = 5
    EmptyDefinitionWarning    = 6
    NotEmptyDefinitionWarning = 7
    LogicalErrorWarning       = 8
    DeprecatedWarning         = 9
    IndentationWarning        = 10
    AmbiguityWarning          = 11
    URIWarning                = 12
)

Warning Codes see https://github.com/apiaryio/snowcrash/blob/master/src/SourceAnnotation.h#L128

const (
    NoError          = 0
    ApplicationError = 1
    BusinessError    = 2
    SymbolError      = 3
)

Error Codes see https://github.com/apiaryio/snowcrash/blob/master/src/SourceAnnotation.h#L113

const (
    // ScRenderDescriptionsOptionKey causes the parser to render markdown in description
    ScRenderDescriptionsOptionKey = 1 << 0
    // RequireBlueprintNameOptionKey causes the parser to treat missing blueprint name as error
    RequireBlueprintNameOptionKey = 1 << 1
    // ExportSourcemapOptionKey causes the parser to export source maps AST
    ExportSourcemapOptionKey = 1 << 2
)

func RawOptionParse Uses

func RawOptionParse(source string, flags int) ([]byte, error)

RawOptionParse parses the inputted string and passes it to the drafter library for parsing. The raw JSON result is then returned from the function

type Action Uses

type Action struct {
    Name        string
    Description string
    // HTTP request method or nil
    Method string
    // action-specific URI parameters or nil
    Parameters []Parameter
    // TODO: in RedSnow, these are flattened out. Ideally these should be too
    Attributes struct {
        // action relation attribute
        Relation string
        // action uri template attribute
        UTITemplate string
    }
    Content []interface{}
    // action transaction examples
    Examples []TransactionExample
}

Action Blueprint AST node represents 'action section'

type Blueprint Uses

type Blueprint struct {
    Version string `json:"_version"`
    // Metadata collection Blueprint AST node
    Metadata []struct {
        Name  string
        Value string
    }
    // Resource group Blueprint AST node
    // array of resources in the group
    ResourceGroups []struct {
        Name        string
        Description string
        Resources   []Resource
    }
    Name        string
    Description string
    Element     string
}

Blueprint is a data representation of the ast blueprints

type BlueprintSourcemap Uses

type BlueprintSourcemap interface{}

BlueprintSourcemap is a blueprint for sourcemaps

TODO: fill this out just as the AST blueprint is

type LocationPoint Uses

type LocationPoint struct {
    // Zero-based index of the character where warning has occurred.
    Index int
    //  Number of the characters from index where warning has occurred.
    Length int
}

LocationPoint makes up an array of possibly non-continuous blocks of the source API Blueprint.

type Parameter Uses

type Parameter struct {
    Name string
    // an arbitrary type of the parameter or nil
    Type        string
    Description string
    // parameter necessity flag
    // TODO: change this to be an enum indicating required`, optional or undefined
    // Where undefined implies required according to the API Blueprint Specification
    Required bool
    // default value of the parameter or nil
    DefaultValue string `json:"default"`
    // example value of the parameter or nil
    ExampleValue string `json:"example"`
    // an enumeration of possible parameter values
    Values []struct {
        Value string
    }
}

Parameter is a URI parameter Blueprint AST node represents one 'parameters section' parameter

type ParseResult Uses

type ParseResult struct {
    AST       Blueprint
    SourceMap BlueprintSourcemap
    // Description of a parsing error as occurred during parsing.
    // If this field is present && code different from 0 then the
    // content of ast field should be ignored.
    Error SourceAnnotation
    // Ordered array of parser warnings as occurred during the parsing.
    Warnings []SourceAnnotation
}

ParseResult contains all the information resulting from the parse in a fully typed structured format see: https://github.com/apiaryio/api-blueprint-ast/blob/master/Parse%20Result.md

func OptionParse Uses

func OptionParse(source string, options int) (*ParseResult, error)

OptionParse parses the inputted string using the drafter library with the specified options to affect the parse and unmarshals the returned json into a struct containing all the necessary information

func Parse Uses

func Parse(source string) (*ParseResult, error)

Parse is a wrapper around OptionParse passing in 0 for the options value, indicating normal parsing behavior

type Payload Uses

type Payload struct {
    Name        string
    Description string
    // array of HTTP header fields of the message or nil
    Headers []struct {
        Name  string
        Value string
    }
    // HTTP-message body or nil
    Body string
    // HTTP-message body validation schema or nil
    Schema string
    // Symbol Reference if the payload is a reference
    Reference struct {
        ID string
    }
    Content []interface{}
}

Payload is a HTTP message payload Blueprint AST node

type Resource Uses

type Resource struct {
    Element     string
    Name        string
    Description string
    URITemplate string
    Model       Payload
    Parameters  []Parameter
    Actions     []Action
}

Resource is a resource within the blueprint

type SourceAnnotation Uses

type SourceAnnotation struct {
    Message  string
    Code     int
    Location []LocationPoint
}

SourceAnnotation is a building block of the json for API Blueprints

func (*SourceAnnotation) Ok Uses

func (s *SourceAnnotation) Ok() bool

Ok returns whether or not the return code indicated success

type TransactionExample Uses

type TransactionExample struct {
    Name        string
    Description string
    // example request payloads
    Requests []Payload
    // example response payloads
    Responses []Payload
}

TransactionExample Blueprint AST node

Package gosnow imports 4 packages (graph). Updated 2016-07-15. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).