Documentation ¶
Index ¶
- Constants
- Variables
- type Annotation
- type ApiSpec
- type ApiSyntax
- type ArrayType
- type AtDoc
- type DefineStruct
- func (t DefineStruct) Comments() []string
- func (t DefineStruct) Documents() []string
- func (t DefineStruct) GetBodyMembers() []Member
- func (t DefineStruct) GetFormMembers() []Member
- func (t DefineStruct) GetNonBodyMembers() []Member
- func (t DefineStruct) GetTagMembers(tagKey string) []Member
- func (t DefineStruct) Name() string
- type Doc
- type Group
- type Import
- type Info
- type InterfaceType
- type MapType
- type Member
- func (m Member) GetComment() string
- func (m Member) GetEnumOptions() []string
- func (m Member) GetPropertyName() (string, error)
- func (m Member) IsBodyMember() bool
- func (m Member) IsFormMember() bool
- func (m Member) IsOmitEmpty() bool
- func (m Member) IsOptional() bool
- func (m Member) IsTagMember(tagKey string) bool
- func (m Member) Tags() []*Tag
- type PointerType
- type PrimitiveType
- type Route
- type Service
- type Tag
- type Tags
- type Type
Examples ¶
Constants ¶
const RoutePrefixKey = "prefix"
RoutePrefixKey is the prefix keyword for the routes.
Variables ¶
var ErrMissingService = errors.New("missing service")
Functions ¶
This section is empty.
Types ¶
type Annotation ¶
Annotation defines key-value
type ApiSpec ¶
type ApiSpec struct { Info Info // Deprecated: useless expression Syntax ApiSyntax // Deprecated: useless expression Imports []Import // Deprecated: useless expression Types []Type Service Service }
ApiSpec describes an api file
type ArrayType ¶
ArrayType describes a slice for api
type DefineStruct ¶
DefineStruct describes api structure
func (DefineStruct) Comments ¶
func (t DefineStruct) Comments() []string
Comments returns the comments of struct
func (DefineStruct) Documents ¶
func (t DefineStruct) Documents() []string
Documents returns the documents of struct
func (DefineStruct) GetBodyMembers ¶
func (t DefineStruct) GetBodyMembers() []Member
GetBodyMembers returns all json fields
func (DefineStruct) GetFormMembers ¶
func (t DefineStruct) GetFormMembers() []Member
GetFormMembers returns all form fields
func (DefineStruct) GetNonBodyMembers ¶
func (t DefineStruct) GetNonBodyMembers() []Member
GetNonBodyMembers returns all have no tag fields
func (DefineStruct) GetTagMembers ¶
func (t DefineStruct) GetTagMembers(tagKey string) []Member
GetTagMembers returns all given key fields
func (DefineStruct) Name ¶
func (t DefineStruct) Name() string
Name returns a structure string, such as User
type Group ¶
type Group struct { Annotation Annotation Routes []Route }
Group defines a set of routing information
func (Group) GetAnnotation ¶
GetAnnotation returns the value by specified key from @server
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 an interface for api
func (InterfaceType) Comments ¶
func (t InterfaceType) Comments() []string
Comments returns the comments of struct
func (InterfaceType) Documents ¶
func (t InterfaceType) Documents() []string
Documents returns the documents of struct
func (InterfaceType) Name ¶
func (t InterfaceType) Name() string
Name returns an interface string, Its fixed value is any
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
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 ¶
GetComment returns comment value of Member
func (Member) GetEnumOptions ¶
GetEnumOptions return a slice contains all enumeration options
Example ¶
package main import ( "fmt" "github.com/wangliujing/goctl/api/spec" ) func main() { member := spec.Member{ Tag: `json:"foo,options=foo|bar|options|123"`, } fmt.Println(member.GetEnumOptions()) }
Output: [foo bar options 123]
func (Member) GetPropertyName ¶
GetPropertyName returns json tag value
func (Member) IsBodyMember ¶
IsBodyMember returns true if contains json tag
func (Member) IsFormMember ¶
IsFormMember returns true if contains form tag
func (Member) IsOmitEmpty ¶
IsOmitEmpty returns true if tag contains omitempty
func (Member) IsOptional ¶
IsOptional returns true if tag is optional
func (Member) IsTagMember ¶
IsTagMember returns true if contains given tag
type PointerType ¶
PointerType describes a pointer for api
func (PointerType) Comments ¶
func (t PointerType) Comments() []string
Comments returns the comments of struct
func (PointerType) Documents ¶
func (t PointerType) Documents() []string
Documents returns the documents of struct
func (PointerType) Name ¶
func (t PointerType) Name() string
Name returns a pointer string, such as *User
type PrimitiveType ¶
type PrimitiveType struct {
RawName string
}
PrimitiveType describes the basic golang type, such as bool,int32,int64, ...
func (PrimitiveType) Comments ¶
func (t PrimitiveType) Comments() []string
Comments returns the comments of struct
func (PrimitiveType) Documents ¶
func (t PrimitiveType) Documents() []string
Documents returns the documents of struct
func (PrimitiveType) Name ¶
func (t PrimitiveType) Name() string
Name returns a basic string, such as int32,int64
type Route ¶
type Route struct { // Deprecated: Use Service AtServer instead. 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 ¶
GetAnnotation returns the value by specified key from @server
func (Route) RequestTypeName ¶
RequestTypeName returns request type name of route
func (Route) ResponseTypeName ¶
ResponseTypeName returns response type name of 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 }
Tag defines a tag for structure filed