* fixes #987

* chore: fix test failure

* chore: add comments
This commit is contained in:
Kevin Wan
2021-12-01 17:45:48 +08:00
committed by GitHub
parent f1d70eb6b2
commit 543d590710
3 changed files with 46 additions and 13 deletions

View File

@@ -267,11 +267,8 @@ func (v *ApiVisitor) VisitReplybody(ctx *api.ReplybodyContext) interface{} {
}
case *Literal:
lit := dataType.Literal.Text()
if api.IsGolangKeyWord(dataType.Literal.Text()) {
v.panic(dataType.Literal, fmt.Sprintf("expecting 'ID', but found golang keyword '%s'", dataType.Literal.Text()))
}
if api.IsBasicType(lit) {
v.panic(dt.Expr(), fmt.Sprintf("unsupport %s", dt.Expr().Text()))
if api.IsGolangKeyWord(lit) {
v.panic(dataType.Literal, fmt.Sprintf("expecting 'ID', but found golang keyword '%s'", lit))
}
default:
v.panic(dt.Expr(), fmt.Sprintf("unsupport %s", dt.Expr().Text()))

View File

@@ -174,7 +174,7 @@ func TestRoute(t *testing.T) {
assert.Error(t, err)
_, err = parser.Accept(fn, ` post /foo/bar returns (int)`)
assert.Error(t, err)
assert.Nil(t, err)
_, err = parser.Accept(fn, ` post /foo/bar returns (*int)`)
assert.Error(t, err)