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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -987,13 +987,6 @@ pathLoop:
jsonBuffer = ""
}
case '/':
if depth == 0 {
parts = append(parts, buffer)
buffer = ""
// Since the stack was empty when we hit the '/' we are done with this
// section.
continue
}
buffer += string(char)
jsonBuffer += string(char)
case ':':
Expand Down
1 change: 1 addition & 0 deletions protoc-gen-openapiv2/internal/genopenapi/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3918,6 +3918,7 @@ func TestTemplateToOpenAPIPath(t *testing.T) {
{"/{user.name=prefix/*}:customMethod", "/{user.name}:customMethod"},
{"/{user.name=prefix1/*/prefix2/*}:customMethod", "/{user.name}:customMethod"},
{"/{parent=prefix/*}/children:customMethod", "/{parent}/children:customMethod"},
{"/item/search:items/{item_no_query}", "/item/search:items/{item_no_query}"},

Choose a reason for hiding this comment

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

it should be camel case here.. "/item/search:items/{itemNoQuery}"

Maybe you need to add a test to TestTemplateWithJsonCamelCase https://github.com/grpc-ecosystem/grpc-gateway/blob/main/protoc-gen-openapiv2/internal/genopenapi/template_test.go#L3843C6-L3843C35

Choose a reason for hiding this comment

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

Yes, thanks. This is the proper place for the test. Also corrected the fix in the actual function, deleted the wrong if depth == 0 branch...
This should also reproduce the issue and at least fixes the case mentioned in the issue.

}
reg := descriptor.NewRegistry()
reg.SetUseJSONNamesForFields(false)
Expand Down