Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix path with : in the middle #3517 issue #3532

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 1 addition & 9 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Expand Up @@ -962,8 +962,7 @@ func templateToParts(path string, reg *descriptor.Registry, fields []*descriptor
depth := 0
buffer := ""
jsonBuffer := ""
pathLoop:
for i, char := range path {
for _, char := range path {
switch char {
case '{':
// Push on the stack
Expand Down Expand Up @@ -997,13 +996,6 @@ pathLoop:
buffer += string(char)
jsonBuffer += string(char)
case ':':
if depth == 0 {
// As soon as we find a ":" outside a variable,
// everything following is a verb
parts = append(parts, buffer)
buffer = path[i:]
break pathLoop
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about just removing this, are all the tests still passing?

buffer += string(char)
jsonBuffer += string(char)
default:
Expand Down
1 change: 1 addition & 0 deletions protoc-gen-openapiv2/internal/genopenapi/template_test.go
Expand Up @@ -3858,6 +3858,7 @@ func TestTemplateWithJsonCamelCase(t *testing.T) {
{"test/{ab_c}", "test/{abC}"},
{"test/{json_name}", "test/{jsonNAME}"},
{"test/{field_abc.field_newName}", "test/{fieldAbc.RESERVEDJSONNAME}"},
{"/item/search:items/{item_no_query}", "/item/search:items/{itemNoQuery}"},
}
reg := descriptor.NewRegistry()
reg.SetUseJSONNamesForFields(true)
Expand Down