123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- package spec
- type (
- // Doc describes document
- Doc []string
- // Annotation defines key-value
- Annotation struct {
- Properties map[string]string
- }
- // ApiSyntax describes the syntax grammar
- ApiSyntax struct {
- Version string
- Doc Doc
- Comment Doc
- }
- // ApiSpec describes a api file
- ApiSpec struct {
- Info Info
- Syntax ApiSyntax
- Imports []Import
- Types []Type
- Service Service
- }
- // Import describes api import
- Import struct {
- Value string
- Doc Doc
- Comment Doc
- }
- // Group defines a set of routing information
- Group struct {
- Annotation Annotation
- Routes []Route
- }
- // Info describes info grammar block
- 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
- }
- // Member describes the field of a structure
- Member struct {
- Name string
- // 数据类型字面值,如:string、map[int]string、[]int64、[]*User
- Type Type
- Tag string
- Comment string
- // 成员头顶注释说明
- Docs Doc
- IsInline bool
- }
- // Route describes api route
- 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
- }
- // Service describes api service
- Service struct {
- Name string
- Groups []Group
- }
- // Type defines api type
- Type interface {
- Name() string
- Comments() []string
- Documents() []string
- }
- // DefineStruct describes api structure
- DefineStruct struct {
- RawName string
- Members []Member
- Docs Doc
- }
- // PrimitiveType describes the basic golang type, such as bool,int32,int64, ...
- PrimitiveType struct {
- RawName string
- }
- // MapType describes a map for api
- 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
- }
- // ArrayType describes a slice for api
- ArrayType struct {
- RawName string
- Value Type
- }
- // InterfaceType describes a interface for api
- InterfaceType struct {
- RawName string
- }
- // PointerType describes a pointer for api
- PointerType struct {
- RawName string
- Type Type
- }
- // AtDoc describes a metadata for api grammar: @doc(...)
- AtDoc struct {
- Properties map[string]string
- Text string
- }
- )
|