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>
This commit is contained in:
99
tools/goctl/api/parser/g4/test.api
Normal file
99
tools/goctl/api/parser/g4/test.api
Normal file
@@ -0,0 +1,99 @@
|
||||
// only one
|
||||
syntax = "v1"
|
||||
|
||||
// import
|
||||
import "foo.api"
|
||||
|
||||
// import group
|
||||
import(
|
||||
"foo.api"
|
||||
"foo/bar.api"
|
||||
)
|
||||
|
||||
// only one
|
||||
info(
|
||||
title: "foo title"
|
||||
desc: "foo
|
||||
desc"
|
||||
author: "foo author"
|
||||
email: "foo email"
|
||||
version: "foo version"
|
||||
)
|
||||
|
||||
// ignore the following duplicate name
|
||||
|
||||
type Foo int
|
||||
|
||||
// type single
|
||||
type Foo {
|
||||
Bar string
|
||||
}
|
||||
|
||||
type Foo {
|
||||
Bar string `json:"bar"`
|
||||
Inline
|
||||
}
|
||||
// go struct
|
||||
type Foo struct {
|
||||
Bar string `json:"bar"`
|
||||
}
|
||||
|
||||
// type group
|
||||
type (
|
||||
Foo int
|
||||
|
||||
// go struct
|
||||
Foo struct {
|
||||
Bar string `json:"bar"`
|
||||
}
|
||||
|
||||
Foo {
|
||||
VString string `json:"vString"`
|
||||
VBool bool `json:"vBool"`
|
||||
VInt8 int8 `json:"vInt8"`
|
||||
VInt16 int16 `json:"vInt16"`
|
||||
VInt32 int32 `json:"vInt32"`
|
||||
VInt64 int64 `json:"vInt64"`
|
||||
VInt int `json:"vInt"`
|
||||
VUInt8 uint8 `json:"vUInt8"`
|
||||
VUInt16 uint16 `json:"vUInt16"`
|
||||
VUInt32 uint32 `json:"vUInt32"`
|
||||
VUInt64 uint64 `json:"vUInt64"`
|
||||
VFloat32 float32 `json:"vFloat32"`
|
||||
VFloat64 float64 `json:"vFloat64"`
|
||||
VByte byte `json:"vByte"`
|
||||
VRune rune `json:"vRune"`
|
||||
VMap map[string]int `json:"vMap"`
|
||||
VArray []int `json:"vArray"`
|
||||
VStruct Foo `json:"vStruct"`
|
||||
VStructPointer *Foo `json:"vStructPointer"`
|
||||
VInterface interface{} `json:"vInterface"`
|
||||
T time.Time
|
||||
}
|
||||
)
|
||||
|
||||
@server(
|
||||
jwt: Foo
|
||||
group: foo/bar
|
||||
anotherKey: anotherValue
|
||||
)
|
||||
service example-api {
|
||||
@doc(
|
||||
summary: "foo1"
|
||||
)
|
||||
@server(
|
||||
handler: fooHandler1
|
||||
anotherKey: anotherValue
|
||||
)
|
||||
post /api/foo1 (SingleExample)
|
||||
|
||||
@doc "foo2"
|
||||
@handler fooHandler2
|
||||
get /api/foo2 (SingleExample) returns (SingleExample2)
|
||||
|
||||
@handler fooHandler3
|
||||
post /api/foo3/:id returns (SingleExample2)
|
||||
|
||||
@handler fooHandler4
|
||||
get /api/foo4
|
||||
}
|
||||
Reference in New Issue
Block a user