-
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
protoc-gen-openapiv2: add example for AIP-133 #1524
protoc-gen-openapiv2: add example for AIP-133 #1524
Conversation
This example illustrates that the `book_id` field is not converted into a query string parameter in the generated swagger.json file.
@johanbrandhorst hey! I added two TODO tasks to the original comment. Before I press on with those do you mind taking a peek at my changes? Some things:
|
I reran the test and it looks like it passed, so that test is clearly flaky. I've raised #1527 to fix it.
This is great! Clearly this was never working correctly.
I think it looks great so far. |
Cool thanks @johanbrandhorst. I'll add that Go test next and then see how it looks, that might be all that's needed before this is ready for review. |
non-body fields are added as query parameters
@johanbrandhorst and friends this is ready for review. |
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 looks great! Thank you so much.
Thanks for your contribution! How much work would it be to backport this to v1? |
@johanbrandhorst you're welcome! It should be easy, I'll get on to that. |
Originally opened against v1: #1514
This example illustrates that the
book_id
field is not converted into a query string parameter in the generated swagger.json file.References to other Issues or PRs
This PR contains an example required for a fix for #559.
Generally speaking, the main issue is that for requests with a body, non-body fields need to be added as query parameters. I think this is the same conclusion that @wotzhs came to in their comment at #559 (comment).
Have you read the Contributing Guidelines?
Yes.
Brief description of what is fixed or changed
I added an example to
examples/internal/proto/examplepb/a_bit_of_everything.proto
that is very similar to the example in https://google.aip.dev/133#user-specified-ids that allows users to provide their own ID. The user-specified ID needs to become a query string parameter per aip-dev/google.aip.dev#542 (comment).The gateway generator is fine, but the Swagger generator does not generate query string parameters when there is a body on the binding.
The generated
parameters
is currently:Notice that there is no mention of the
book_id
. For clients generated off the swagger.json there is literally no way for them to know they need to provide abook_id
.Thus
parameters
should include this:Note: this is correlated by the reply on my AIP issue here: aip-dev/google.aip.dev#542 (comment)
Other comments
I started to fix this locally and I have a rough idea of what needs doing, but I wanted to start the PR with a broken example first and I will attempt to fix the issue using this as a base.
TODO
Thanks for reading :)