-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat: add expand_slashed_path_patterns flag #4813
feat: add expand_slashed_path_patterns flag #4813
Conversation
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.
This is a great start. Could you please make sure to also:
- Add this new flag to the bazel rules for the openapiv2 generator. Just follow the pattern for the other flags.
- Add a small section to our docs about this new flag with some example use cases? The file you want is https://github.com/grpc-ecosystem/grpc-gateway/blob/main/docs/docs/mapping/customizing_openapi_output.md.
Thanks!
I created a single clean function that patches the path parts & params only when the flag is turned on. It consumes the parts from the If you pass into the
where the path pattern contains snake-kase
so the path pattern is camelcased. I believe this is wrong, since only the path parameter names should be camelcased, not other parts of the URI - am I right? |
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.
I believe this is wrong, since only the path parameter names should be camelcased, not other parts of the URI - am I right?
Yeah this looks wrong, thanks for finding it. Can you fix it?
348d4ea
to
9a7d834
Compare
@@ -988,30 +998,24 @@ func templateToParts(path string, reg *descriptor.Registry, fields []*descriptor | |||
var parts []string | |||
depth := 0 | |||
buffer := "" | |||
jsonBuffer := "" |
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.
This second jsonBuffer
was just a complexity gainer, I added a single branch to the }
case, where it extracts the parameter name and camel-case it, when the camel-casing is enabled.
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.
This is really cool, as a final request, do you think you could add a little blurb about this setting to our docs? This page: https://github.com/grpc-ecosystem/grpc-gateway/blob/main/docs/docs/mapping/customizing_openapi_output.md
Looks like there was a test failure, I think it's from the camelcase fix you made. |
Thank you for your contribution! |
References to other Issues or PRs
Closes #4784 - a feature request
Have you read the Contributing Guidelines?
Yes 👍
Brief description of what is fixed or changed
This adds an experimental flag into the OpenAPI generator, that expands path patterns containing URI sub-paths into the URI with new path parameters. This improves the readability and OpenAPI compatibility of protobuf APIs based on Google AIP. For more context read the linked issue.