gen

package
v0.0.0-...-798b8f6 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiMethodGet    = "GET"
	ApiMethodPost   = "POST"
	ApiMethodPut    = "PUT"
	ApiMethodDelete = "DELETE"
)
View Source
const (
	JsonSchemaTypeArrary  = "array"
	JsonSchemaTypeObject  = "object"
	JsonSchemaTypeBoolean = "boolean"
	JsonSchemaTypeNumber  = "number"
	JsonSchemaTypeInteger = "integer"
	JsonSchemaTypeString  = "string"
	JsonSchemaTypeAny     = "any"
	JsonSchemaTypeNull    = "null"
)

Variables

This section is empty.

Functions

func GenApis

func GenApis(output string, apiSchemas []ApiSchema) error

func Walk

func Walk(v Visitor, n ast.Node)

Walk traverses an AST in depth-first order: It starts by calling v.Enter(node); node must not be nil. If the visitor v returned by v.Enter(node) is not nil, Walk is invoked recursively with visitor v for each of the non-nil children of node, followed by a call of v.Exit(node).

Types

type AdditionalProperties

type AdditionalProperties struct {
	Schema *JsonSchema
	Bool   ZeroOneBool
}

func (*AdditionalProperties) UnmarshalJSON

func (s *AdditionalProperties) UnmarshalJSON(data []byte) error

type ApiDefine

type ApiDefine struct {
	Name            string
	Description     string
	APILink         string
	Method          ApiMethod
	Path            string
	RequestPayload  []ApiPayload
	ResponsePayload []ApiPayload
}

func NewApiDefine

func NewApiDefine(path string, api ApiInfo) *ApiDefine

type ApiInfo

type ApiInfo struct {
	Allowtoken  ZeroOneBool
	Description string
	Method      ApiMethod
	Name        string
	Parameters  *JsonSchema
	Returns     *JsonSchema
	Permissions interface{}
}

type ApiMethod

type ApiMethod string

type ApiPayload

type ApiPayload struct {
	Name    string
	Comment string
	Type    string
	Fields  []ApiPayloadField
}

type ApiPayloadField

type ApiPayloadField struct {
	Name    string
	Type    string
	Tag     string
	Comment string
}

type ApiSchema

type ApiSchema struct {
	Children []ApiSchema
	Info     map[ApiMethod]ApiInfo
	Leaf     int
	Path     string
	Text     string
}

func ParseSchemaFile

func ParseSchemaFile(f string) ([]ApiSchema, error)

func ParseSchemaFilex

func ParseSchemaFilex(f string) ([]ApiSchema, error)

type JsonSchema

type JsonSchema struct {
	Type     JsonSchemaType
	Optional ZeroOneBool

	TypeText    string
	Description string
	Format      PropertiesFormat

	Properties           map[string]JsonSchema
	AdditionalProperties AdditionalProperties

	Items *JsonSchema
	Links []*Link `json:"links"`
}

type JsonSchemaType

type JsonSchemaType string
type Link struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
}

type PropertiesFormat

type PropertiesFormat struct {
	Object map[string]PropertiesFormatObject
	String string
}

func (*PropertiesFormat) UnmarshalJSON

func (p *PropertiesFormat) UnmarshalJSON(data []byte) error

type PropertiesFormatObject

type PropertiesFormatObject struct {
	Default     interface{}
	DefaultKey  interface{}
	Description string
	Type        JsonSchemaType
	Enum        []interface{}
	Optional    ZeroOneBool
}

type Visitor

type Visitor interface {
	Enter(n ast.Node) Visitor
	Exit(n ast.Node)
}

Visitor Enter method is invoked for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor v, followed by a call of the Exit method.

type ZeroOneBool

type ZeroOneBool bool

func (*ZeroOneBool) UnmarshalJSON

func (s *ZeroOneBool) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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