Skip to content

Commit

Permalink
remove string restriction on atserver (zeromicro#4499)
Browse files Browse the repository at this point in the history
  • Loading branch information
kesonan authored Dec 17, 2024
1 parent dbed1ea commit 89ecb50
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 13 deletions.
6 changes: 1 addition & 5 deletions tools/goctl/pkg/parser/api/parser/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ func (a *Analyzer) convertKV(kv []*ast.KVExpr) map[string]string {
var ret = map[string]string{}
for _, v := range kv {
key := strings.TrimSuffix(v.Key.Token.Text, ":")
if key == summaryKeyText {
ret[key] = v.Value.RawText()
} else {
ret[key] = v.Value.Token.Text
}
ret[key] = v.Value.RawText()
}

return ret
Expand Down
8 changes: 0 additions & 8 deletions tools/goctl/pkg/parser/api/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (

const (
idAPI = "api"
summaryKeyExprText = "summary:"
summaryKeyText = "summary"
groupKeyText = "group"
infoTitleKey = "Title"
infoDescKey = "Desc"
Expand Down Expand Up @@ -1201,12 +1199,6 @@ func (p *Parser) parseAtServerKVExpression() *ast.KVExpr {
expr.Value = node
return expr
} else if p.peekTokenIs(token.STRING) {
if expr.Key.Token.Text != summaryKeyExprText {
if p.notExpectPeekToken(token.QUO, token.DURATION, token.IDENT, token.INT) {
return nil
}
}

if !p.nextToken() {
return nil
}
Expand Down
1 change: 1 addition & 0 deletions tools/goctl/pkg/parser/api/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ func TestParser_Parse_atServerStmt(t *testing.T) {
"prefix3:": "v1/v2_",
"prefix4:": "a-b-c",
"summary:": `"test"`,
"key:": `"bar"`,
}

p := New("foo.api", atServerTestAPI)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
prefix3: v1/v2_
prefix4: a-b-c
summary:"test"
key:"bar"
)
1 change: 1 addition & 0 deletions tools/goctl/pkg/parser/api/parser/testdata/test.api
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ service test {
@server (
jwt: Auth
group: Group1
foo:"bar"
)
service test {
@doc "ping"
Expand Down

0 comments on commit 89ecb50

Please sign in to comment.