Skip to content

Commit

Permalink
fix bug: the resource name of custom method doesn't be retained
Browse files Browse the repository at this point in the history
  • Loading branch information
ch3rub1m authored and johanbrandhorst committed Nov 13, 2018
1 parent 3ff87af commit aa4f5a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions protoc-gen-swagger/genswagger/template.go
Expand Up @@ -570,6 +570,8 @@ func isResourceName(prefix string) bool {
words := strings.Split(prefix, ".")
l := len(words)
field := words[l-1]
words = strings.Split(field, ":")
field = words[0]
return field == "parent" || field == "name"
}

Expand Down
5 changes: 5 additions & 0 deletions protoc-gen-swagger/genswagger/template_test.go
Expand Up @@ -702,6 +702,11 @@ func TestTemplateToSwaggerPath(t *testing.T) {
{"/{user.name=prefix/*}", "/{user.name=prefix/*}"},
{"/{user.name=prefix1/*/prefix2/*}", "/{user.name=prefix1/*/prefix2/*}"},
{"/{parent=prefix/*}/children", "/{parent=prefix/*}/children"},
{"/{name=prefix/*}:customMethod", "/{name=prefix/*}:customMethod"},
{"/{name=prefix1/*/prefix2/*}:customMethod", "/{name=prefix1/*/prefix2/*}:customMethod"},
{"/{user.name=prefix/*}:customMethod", "/{user.name=prefix/*}:customMethod"},
{"/{user.name=prefix1/*/prefix2/*}:customMethod", "/{user.name=prefix1/*/prefix2/*}:customMethod"},
{"/{parent=prefix/*}/children:customMethod", "/{parent=prefix/*}/children:customMethod"},
}

for _, data := range tests {
Expand Down

0 comments on commit aa4f5a4

Please sign in to comment.