parser

package
v0.0.0-...-93f7656 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(n *yaml.Node, msg string) error

func FillMethodsNames

func FillMethodsNames(methods []Method) error

func NodeComment

func NodeComment(n *yaml.Node) string

func NodeKind

func NodeKind(k yaml.Kind) string

func PrettyPrint

func PrettyPrint(data interface{}) error

func PrintNode

func PrintNode(tab string, n *yaml.Node)

func PrintPair

func PrintPair(pair *NodePair)

func PrintSchema

func PrintSchema(tab string, s Schema)

func ResolveEmbeds

func ResolveEmbeds(doc *Document) error

func SnakeToUpper

func SnakeToUpper(s string) string

Types

type API

type API struct {
	Tags    []Tag
	Methods []Method
}

func ParseAPI

func ParseAPI(n *yaml.Node) (API, error)

type Comment

type Comment struct {
	Description string
	Example     string
}

func ParseComment

func ParseComment(comment string) Comment

type Document

type Document struct {
	Settings Settings
	API      API
	Schemas  []Schema
}

func ParseDocument

func ParseDocument(data []byte) (Document, error)

type Method

type Method struct {
	Method      string
	Path        string
	Description string
	Tag         string
	Name        string
	Request     Request
	Response    Response
}

func ParseCommon

func ParseCommon(n *yaml.Node) (Method, error)

func ParseMethod

func ParseMethod(path string, n *yaml.Node) (Method, error)

func ParseMethods

func ParseMethods(n *yaml.Node, tag string) ([]Method, error)

type NodePair

type NodePair struct {
	Left  *yaml.Node
	Right *yaml.Node
}

func PairNodes

func PairNodes(n *yaml.Node) ([]NodePair, error)

type Request

type Request struct {
	Params  []Schema
	Query   []Schema
	Headers []Schema
	Body    *Schema
}

func MergeRequest

func MergeRequest(prior, minor Request) Request

func ParseRequest

func ParseRequest(n *yaml.Node) (Request, error)

type Response

type Response struct {
	Body    *Schema
	Default *Schema
	Errors  map[string]*Schema
}

func MergeResponse

func MergeResponse(prior, minor Response) Response

func ParseResponse

func ParseResponse(n *yaml.Node) (Response, error)

type ScalarType

type ScalarType struct {
	Type        Type
	Format      string
	Optional    bool
	IsArray     bool
	Description string
	Example     string
}

func ParseScalarType

func ParseScalarType(n *yaml.Node) (ScalarType, error)

type Schema

type Schema struct {
	Name        string
	Type        Type
	Format      string
	IsArray     bool
	Optional    bool
	Description string
	Example     string
	Embeds      []Type
	Fields      []Schema
}

func MergeFields

func MergeFields(prior, minor []Schema) []Schema

func MergeParams

func MergeParams(prior, minor []Schema) []Schema

func ParseBody

func ParseBody(p *NodePair) (*Schema, error)

func ParseHeaders

func ParseHeaders(p *NodePair) ([]Schema, error)

func ParseParams

func ParseParams(p *NodePair) ([]Schema, error)

func ParsePathParams

func ParsePathParams(path string) (string, []Schema)

func ParseQuery

func ParseQuery(p *NodePair) ([]Schema, error)

func ParseSchema

func ParseSchema(p *NodePair) (Schema, error)

func ParseSchemas

func ParseSchemas(n *yaml.Node) ([]Schema, error)

type Settings

type Settings struct {
	URL     string
	Version string
	Title   string
}

func ParseSettings

func ParseSettings(n *yaml.Node) (Settings, error)

type Tag

type Tag struct {
	Name        string
	Description string
}

type Type

type Type string
const (
	TypeAny    Type = "any"
	TypeBool   Type = "bool"
	TypeObject Type = "object"
	TypeInt32  Type = "int32"
	TypeInt64  Type = "int64"
	TypeFloat  Type = "float"
	TypeDouble Type = "double"
	TypeString Type = "string"
	TypeUUID   Type = "uuid"
	TypeFile   Type = "file"
)

func GetType

func GetType(val string) (Type, error)

func ParseSchemaDefinition

func ParseSchemaDefinition(val string) (string, []Type)

func (*Type) IsRef

func (t *Type) IsRef() bool

func (*Type) Name

func (t *Type) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL