go-zero/tools/goctl/api/spec/spec.go
kingxt ee19fb736b
feature: refactor api parse to g4 (#365)
* feature: refactor api parse to g4

* new g4 parser

* add CHANGE_LOG.MD

* refactor

* fix byte bug

* refactor

* optimized

* optimized

* revert

* update readme.md

* update readme.md

* update readme.md

* update readme.md

* remove no need

* fix java gen

* add upgrade

* resolve confilits

Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn>
2021-01-11 15:10:51 +08:00

113 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package spec
type (
Doc []string
Annotation struct {
Properties map[string]string
}
ApiSyntax struct {
Version string
}
ApiSpec struct {
Info Info
Syntax ApiSyntax
Imports []Import
Types []Type
Service Service
}
Import struct {
Value string
}
Group struct {
Annotation Annotation
Routes []Route
}
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 struct {
Name string
// 数据类型字面值string、map[int]string、[]int64、[]*User
Type Type
Tag string
Comment string
// 成员头顶注释说明
Docs Doc
IsInline bool
}
Route struct {
Annotation Annotation
Method string
Path string
RequestType Type
ResponseType Type
Docs Doc
Handler string
}
Service struct {
Name string
Groups []Group
}
Type interface {
Name() string
}
DefineStruct struct {
RawName string
Members []Member
Docs Doc
}
// 系统预设基本数据类型 bool int32 int64 float32
PrimitiveType struct {
RawName string
}
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 struct {
RawName string
Value Type
}
InterfaceType struct {
RawName string
}
PointerType struct {
RawName string
Type Type
}
)