Files
go-zero/tools/goctl/pkg/parser/api/parser/testdata/invalid.api
2024-07-02 03:55:01 +00:00

205 lines
2.8 KiB
Plaintext

// test case: duplicate syntax statement
syntax = "v1"
syntax = "v1"
-----
// test case: duplicate info statement
syntax = "v1"
info()
info()
-----
// test case: duplicate type
syntax = "v1"
type Foo{}
type Foo{}
-----
// test case: duplicate type
syntax = "v1"
type Baz{}
type (
Baz{}
)
-----
// test case: multiple service name
syntax = "v1"
service foo{
@handler foo
get /foo
}
service bar{
@handler foo
get /foo
}
-----
// test case: duplicate handler
syntax = "v1"
service foo{
@handler foo
get /foo
@handler foo
get /bar
}
-----
// test case: duplicate path
syntax = "v1"
service foo{
@handler foo
get /foo
@handler bar
get /foo
@handler qux
get /v1/baz
}
@server(
prefix: /v1
)
service foo{
@handler qux
get /baz
@handler quux
get /baz
}
-----
// test case: type declare context
syntax = "v1"
type Foo {
Bar Bar `json:"bar"`
}
-----
// test case: map key expected literal type
syntax = "v1"
type Foo {
Bar map[[]int]string `json:"bar"`
}
-----
// test case: map key expected literal type
syntax = "v1"
type Foo {
Bar map[[]int]string `json:"bar"`
}
-----
// test case: map key expected literal type
syntax = "v1"
type Foo {
Bar *map[[]int]string `json:"bar"`
}
-----
// test case: invalid slice
syntax = "v1"
type Foo {
Bar []map[[]int]string `json:"bar"`
}
-----
// test case: array
syntax = "v1"
type Foo {
Bar [...]int `json:"bar"`
}
-----
// test case: any
syntax = "v1"
type Foo {
Bar any `json:"bar"`
}
-----
// test case: invalid map key
syntax = "v1"
type Foo {
M map[{}]string `json:"m"`
}
-----
// test case: invalid map key
syntax = "v1"
type Foo {
M map[{
Foo string `json:"foo"`
}]string `json:"m"`
}
-----
// test case: invalid map value
syntax = "v1"
type Foo {
M map[int]{} `json:"m"`
}
-----
// test case: invalid map value
syntax = "v1"
type Foo {
M map[int]{
Foo int `json:"foo"`
} `json:"m"`
}
-----
// test case: invalid array element
syntax = "v1"
type Foo {
Array [3]{} `json:"array"`
}
-----
// test case: invalid array element
syntax = "v1"
type Foo {
Array [3]{
Foo int `json:"foo"`
} `json:"array"`
}
-----
// test case: invalid array element
syntax = "v1"
type Foo {
Array []{} `json:"array"`
}
-----
// test case: invalid slice element
syntax = "v1"
type Foo {
Array []{
Foo int `json:"foo"`
} `json:"array"`
}
-----
// test case: unresolved type
syntax = "v1"
service example {
@handler nestDemo
post /example/nest (NestDemoReq) returns (NestDemoResp)
}
-----
// test case: unsupported array object request body
syntax = "v1"
service example {
@handler nestDemo
post /example/nest ([]NestDemoReq) returns (NestDemoResp)
}
-----
// test case: unsupported array request body
syntax = "v1"
service example {
@handler nestDemo2
post /example/nest2 ([]string) returns (NestDemoResp)
}