spec

package
v1.1.5-0...-dfb45c8 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Properties map[string]string
}

type ApiSpec

type ApiSpec struct {
	Info    Info
	Syntax  ApiSyntax
	Imports []Import
	Types   []Type
	Service Service
}

type ApiSyntax

type ApiSyntax struct {
	Version string
}

type ArrayType

type ArrayType struct {
	RawName string
	Value   Type
}

func (ArrayType) Name

func (t ArrayType) Name() string

type AtDoc

type AtDoc struct {
	Properties map[string]string
	Text       string
}

type DefineStruct

type DefineStruct struct {
	RawName string
	Members []Member
	Docs    Doc
}

func (DefineStruct) GetBodyMembers

func (t DefineStruct) GetBodyMembers() []Member

func (DefineStruct) GetFormMembers

func (t DefineStruct) GetFormMembers() []Member

func (DefineStruct) GetNonBodyMembers

func (t DefineStruct) GetNonBodyMembers() []Member

func (DefineStruct) Name

func (t DefineStruct) Name() string

type Doc

type Doc []string

type Group

type Group struct {
	Annotation Annotation
	Routes     []Route
}

func (Group) GetAnnotation

func (g Group) GetAnnotation(key string) string

type Import

type Import struct {
	Value string
}

type Info

type Info struct {
	// Deprecated: use Properties instead
	Title string
	// Deprecated: use Properties instead
	Desc string
	// Deprecated: use Properties instead
	Version string
	// Deprecated: use Properties instead
	Author string
	// Deprecated: use Properties instead
	Email      string
	Properties map[string]string
}

type InterfaceType

type InterfaceType struct {
	RawName string
}

func (InterfaceType) Name

func (t InterfaceType) Name() string

type MapType

type MapType struct {
	RawName string
	// only support the PrimitiveType
	Key string
	// it can be asserted as PrimitiveType: int、bool、
	// PointerType: *string、*User、
	// MapType: map[${PrimitiveType}]interface、
	// ArrayType:[]int、[]User、[]*User
	// InterfaceType: interface{}
	// Type
	Value Type
}

func (MapType) Name

func (t MapType) Name() string

type Member

type Member struct {
	Name string
	// 数据类型字面值,如:string、map[int]string、[]int64、[]*User
	Type    Type
	Tag     string
	Comment string
	// 成员头顶注释说明
	Docs     Doc
	IsInline bool
}

func (Member) GetComment

func (m Member) GetComment() string

func (Member) GetPropertyName

func (m Member) GetPropertyName() (string, error)

func (Member) IsBodyMember

func (m Member) IsBodyMember() bool

func (Member) IsFormMember

func (m Member) IsFormMember() bool

func (Member) IsOmitEmpty

func (m Member) IsOmitEmpty() bool

func (Member) IsOmitempty

func (m Member) IsOmitempty() bool

func (Member) IsOptional

func (m Member) IsOptional() bool

func (Member) Tags

func (m Member) Tags() []*Tag

type PointerType

type PointerType struct {
	RawName string
	Type    Type
}

func (PointerType) Name

func (t PointerType) Name() string

type PrimitiveType

type PrimitiveType struct {
	RawName string
}

系统预设基本数据类型 bool int32 int64 float32

func (PrimitiveType) Name

func (t PrimitiveType) Name() string

type Route

type Route struct {
	Annotation   Annotation
	Method       string
	Path         string
	RequestType  Type
	ResponseType Type
	Docs         Doc
	Handler      string
	AtDoc        AtDoc
}

func (Route) GetAnnotation

func (r Route) GetAnnotation(key string) string

func (Route) JoinedDoc

func (r Route) JoinedDoc() string

func (Route) RequestTypeName

func (r Route) RequestTypeName() string

func (Route) ResponseTypeName

func (r Route) ResponseTypeName() string

type Service

type Service struct {
	Name   string
	Groups []Group
}

func (Service) Routes

func (s Service) Routes() []Route

type Tag

type Tag struct {
	// Key is the tag key, such as json, xml, etc..
	// i.e: `json:"foo,omitempty". Here key is: "json"
	Key string

	// Name is a part of the value
	// i.e: `json:"foo,omitempty". Here name is: "foo"
	Name string

	// Options is a part of the value. It contains a slice of tag options i.e:
	// `json:"foo,omitempty". Here options is: ["omitempty"]
	Options []string
}

type Tags

type Tags struct {
	// contains filtered or unexported fields
}

func Parse

func Parse(tag string) (*Tags, error)

func (*Tags) Get

func (t *Tags) Get(key string) (*Tag, error)

func (*Tags) Keys

func (t *Tags) Keys() []string

func (*Tags) Tags

func (t *Tags) Tags() []*Tag

type Type

type Type interface {
	Name() string
}

Jump to

Keyboard shortcuts

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