spec

package
Version: v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: MIT Imports: 5 Imported by: 18

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
}

Annotation defines key-value

type ApiSpec

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

ApiSpec describes a api file

type ApiSyntax added in v1.1.3

type ApiSyntax struct {
	Version string
	Doc     Doc
	Comment Doc
}

ApiSyntax describes the syntax grammar

type ArrayType

type ArrayType struct {
	RawName string
	Value   Type
}

ArrayType describes a slice for api

func (ArrayType) Comments added in v1.1.8

func (t ArrayType) Comments() []string

Comments returns the comments of struct

func (ArrayType) Documents added in v1.1.8

func (t ArrayType) Documents() []string

Documents returns the documents of struct

func (ArrayType) Name added in v1.1.3

func (t ArrayType) Name() string

Name returns a slice string, such as []int

type AtDoc added in v1.1.3

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

AtDoc describes a metadata for api grammar: @doc(...)

type DefineStruct added in v1.1.3

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

DefineStruct describes api structure

func (DefineStruct) Comments added in v1.1.8

func (t DefineStruct) Comments() []string

Comments returns the comments of struct

func (DefineStruct) Documents added in v1.1.8

func (t DefineStruct) Documents() []string

Documents returns the documents of struct

func (DefineStruct) GetBodyMembers added in v1.1.3

func (t DefineStruct) GetBodyMembers() []Member

GetBodyMembers returns all json fields

func (DefineStruct) GetFormMembers added in v1.1.3

func (t DefineStruct) GetFormMembers() []Member

GetFormMembers returns all form fields

func (DefineStruct) GetNonBodyMembers added in v1.1.3

func (t DefineStruct) GetNonBodyMembers() []Member

GetNonBodyMembers returns all have no tag fields

func (DefineStruct) Name added in v1.1.3

func (t DefineStruct) Name() string

Name returns a structure string, such as User

type Doc added in v1.1.3

type Doc []string

Doc describes document

type Group

type Group struct {
	Annotation Annotation
	Routes     []Route
}

Group defines a set of routing information

func (Group) GetAnnotation added in v1.1.3

func (g Group) GetAnnotation(key string) string

GetAnnotation returns the value by specified key from @server

type Import added in v1.1.3

type Import struct {
	Value   string
	Doc     Doc
	Comment Doc
}

Import describes api import

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
}

Info describes info grammar block

type InterfaceType

type InterfaceType struct {
	RawName string
}

InterfaceType describes a interface for api

func (InterfaceType) Comments added in v1.1.8

func (t InterfaceType) Comments() []string

Comments returns the comments of struct

func (InterfaceType) Documents added in v1.1.8

func (t InterfaceType) Documents() []string

Documents returns the documents of struct

func (InterfaceType) Name added in v1.1.3

func (t InterfaceType) Name() string

Name returns a interface string, Its fixed value is interface{}

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
}

MapType describes a map for api

func (MapType) Comments added in v1.1.8

func (t MapType) Comments() []string

Comments returns the comments of struct

func (MapType) Documents added in v1.1.8

func (t MapType) Documents() []string

Documents returns the documents of struct

func (MapType) Name added in v1.1.3

func (t MapType) Name() string

Name returns a map string, such as map[string]int

type Member

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

Member describes the field of a structure

func (Member) GetComment

func (m Member) GetComment() string

GetComment returns comment value of Member

func (Member) GetPropertyName

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

GetPropertyName returns json tag value

func (Member) IsBodyMember

func (m Member) IsBodyMember() bool

IsBodyMember returns true if contains json tag

func (Member) IsFormMember added in v1.1.3

func (m Member) IsFormMember() bool

IsFormMember returns true if contains form tag

func (Member) IsOmitEmpty added in v1.1.3

func (m Member) IsOmitEmpty() bool

IsOmitEmpty returns true if tag contains omitempty

func (Member) IsOptional

func (m Member) IsOptional() bool

IsOptional returns true if tag is optional

func (Member) Tags added in v1.1.0

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

Tags returns all tags in Member

type PointerType

type PointerType struct {
	RawName string
	Type    Type
}

PointerType describes a pointer for api

func (PointerType) Comments added in v1.1.8

func (t PointerType) Comments() []string

Comments returns the comments of struct

func (PointerType) Documents added in v1.1.8

func (t PointerType) Documents() []string

Documents returns the documents of struct

func (PointerType) Name added in v1.1.3

func (t PointerType) Name() string

Name returns a pointer string, such as *User

type PrimitiveType added in v1.1.3

type PrimitiveType struct {
	RawName string
}

PrimitiveType describes the basic golang type, such as bool,int32,int64, ...

func (PrimitiveType) Comments added in v1.1.8

func (t PrimitiveType) Comments() []string

Comments returns the comments of struct

func (PrimitiveType) Documents added in v1.1.8

func (t PrimitiveType) Documents() []string

Documents returns the documents of struct

func (PrimitiveType) Name added in v1.1.3

func (t PrimitiveType) Name() string

Name returns a basic string, such as int32,int64

type Route

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

Route describes api route

func (Route) GetAnnotation added in v1.1.3

func (r Route) GetAnnotation(key string) string

GetAnnotation returns the value by specified key from @server

func (Route) JoinedDoc added in v1.1.3

func (r Route) JoinedDoc() string

JoinedDoc joins comments and summary value in AtDoc

func (Route) RequestTypeName added in v1.1.3

func (r Route) RequestTypeName() string

RequestTypeName returns request type name of route

func (Route) ResponseTypeName added in v1.1.3

func (r Route) ResponseTypeName() string

ResponseTypeName returns response type name of route

type Service

type Service struct {
	Name   string
	Groups []Group
}

Service describes api service

func (Service) Routes

func (s Service) Routes() []Route

Routes returns all routes in api service

type Tag added in v1.1.0

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
}

Tag defines a tag for structure filed

type Tags added in v1.1.0

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

Tags defines a slice for Tag

func Parse added in v1.1.0

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

Parse converts tag string into Tag

func (*Tags) Get added in v1.1.0

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

Get gets tag value by specified key

func (*Tags) Keys added in v1.1.0

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

Keys returns all keys in Tags

func (*Tags) Tags added in v1.1.0

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

Tags returns all tags in Tags

type Type

type Type interface {
	Name() string
	Comments() []string
	Documents() []string
}

Type defines api type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL