-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 incorrectly generated repeated_path_param_separator #3797
base: main
Are you sure you want to change the base?
Fix incorrectly generated repeated_path_param_separator #3797
Conversation
WalkthroughThe changes involve updating the handling of repeated path parameters in a codebase, likely related to API endpoint definitions. The default separator for repeated path parameters has been changed from "csv" to "multi", and the logic for setting the collection format of parameters has been adjusted to use this new default. Additionally, tests have been updated to reflect these changes and to cover new scenarios with different collection formats. Changes
Poem
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (3)
- internal/descriptor/registry.go (1 hunks)
- protoc-gen-openapiv2/internal/genopenapi/template.go (1 hunks)
- protoc-gen-openapiv2/internal/genopenapi/template_test.go (1 hunks)
Additional comments: 6
internal/descriptor/registry.go (1)
- 182-187: The change from "csv" to "multi" for the
repeatedPathParamSeparator
field'sname
property aligns with the PR objectives to respect therepeated_path_param_separator
option specified by the user.protoc-gen-openapiv2/internal/genopenapi/template.go (4)
330-334: The summary indicates a change in the default
repeatedPathParamSeparator
from "csv" to "multi", but this change is not visible in the provided hunk. Please verify if this change is implemented elsewhere in the codebase.330-334: The update to use
reg.GetRepeatedPathParamSeparatorName()
for setting theCollectionFormat
aligns with the PR objective to respect the user's configuration for the repeated path parameter separator.330-334: The summary mentions a typo in the
test
struct fieldRepatedPathParam
which should beRepeatedPathParam
, but this is not visible in the provided hunk. Please verify if this typo is corrected elsewhere in the codebase.330-334: The summary mentions new test cases added to verify the changes to the
CollectionFormat
logic, but these test cases are not visible in the provided hunk. Please verify if these test cases are included elsewhere in the codebase.protoc-gen-openapiv2/internal/genopenapi/template_test.go (1)
- 497-550: The addition of new test cases to verify different collection formats is confirmed and aligns with the PR objectives.
8e06127
to
c06a95f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this, that's pretty bad 😬. To answer your questions:
Question: Should multi
be the default repeated path parameter separator?
We'll have to use whatever we used before as the default, changing it would be breaking, regardless of original intentions.
Question: Should multi be accepted as a new repeated path parameter separator option?
Don't see why not, for users who want to explicitly set the default behavior. Is it not?
References to other Issues or PRs
Fixes #3696
Have you read the Contributing Guidelines?
Yes
Brief description of what is fixed or changed
collectionFormat
specifies the array format (a single parameter with multiple parameter or multiple parameters with the same name) and the separator for array items. source: swagger doc - describing parametersIn the swagger generator of grpc-gateway,
collectionFormat
was always set to "multi" which disregarded the override from therepeated_path_param_separator
option.This MR fixes that behaviour and amends the relevant existing test cases.
Assumptions: default repeated path parameter separator is
multi
Other comments
Question: Should
multi
be the default repeated path parameter separator?Question: Should
multi
be accepted as a new repeated path parameter separator option?Thank you
Summary by CodeRabbit
New Features
Bug Fixes
Tests