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 2494 #3646

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Fix 2494 #3646

wants to merge 4 commits into from

Conversation

amanraja
Copy link

@amanraja amanraja commented Oct 6, 2023

Fixes #2494

@coderabbitai
Copy link

coderabbitai bot commented Oct 6, 2023

Walkthrough

The changes introduced add a new check in the template to ensure compatibility between path and query parameters. Additionally, updates to the proto file include a oneof_decl named "primary_key" and two new fields, enhancing the service options for HTTP GET requests.

Changes

File Summary
.../genopenapi/template.go Introduced a check to prevent conflicting field types from being used together.
.../path_item_object.prototext Added a oneof_decl named "primary_key", two new fields "uuid" and "id", and additional bindings for HTTP GET requests.

🐇💻

In the land of code, where logic is king,

A rabbit hops forth, changes to bring.

With each line written, with each test run,

The software evolves, the work is done.

So let's celebrate this commit, so neat,

For every bug squashed, is a feat! 🎉🥕


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link

@coderabbitai coderabbitai bot left a 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: 0

Commits Files that changed from the base of the PR and between d271d84 and b1ee40f.
Files ignored due to filter (1)
  • protoc-gen-openapiv2/internal/genopenapi/testdata/generator/path_item_object.swagger.yaml
Files selected for processing (2)
  • protoc-gen-openapiv2/internal/genopenapi/template.go (1 hunks)
  • protoc-gen-openapiv2/internal/genopenapi/testdata/generator/path_item_object.prototext (2 hunks)
Files skipped from review due to trivial changes (1)
  • protoc-gen-openapiv2/internal/genopenapi/template.go
Additional comments (Suppressed): 2
protoc-gen-openapiv2/internal/genopenapi/testdata/generator/path_item_object.prototext (2)
  • 14-32: The oneof_decl named "primary_key" and the fields "uuid" and "id" have been added to the message type. Ensure that these changes are reflected in the corresponding service methods and their usage throughout the codebase.

  • 40-50: Additional HTTP GET bindings have been added for the fields "value", "uuid", and "id". Make sure that the server-side implementation can handle these new routes correctly, and that they do not conflict with existing routes.

@amanraja
Copy link
Author

amanraja commented Oct 8, 2023

Hey @johanbrandhorst , Would you please look into this PR ?

@johanbrandhorst johanbrandhorst changed the title fix: added fix for https://github.com/grpc-ecosystem/grpc-gateway/iss… Fix 2494 Oct 9, 2023
Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

Hi! Thanks for this PR. The change looks reasonable, but I'm not sure I understand what the testdata changes do. Could you add a test to template_test.go? Or perhaps add an example of this circumstance to one of the test protobuf files and regenerate the files? Thanks!

@amanraja
Copy link
Author

amanraja commented Oct 9, 2023

Hi! Thanks for this PR. The change looks reasonable, but I'm not sure I understand what the testdata changes do. Could you add a test to template_test.go? Or perhaps add an example of this circumstance to one of the test protobuf files and regenerate the files? Thanks!

Hey @johanbrandhorst , sure i will add tests for template_test.go, i made changes to testdata file to show the issue that we are addressing, hope that would suffice for us ?

schema:
$ref: '#/definitions/StringMessage'
parameters:
- name: uuid
Copy link
Author

Choose a reason for hiding this comment

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

without this fix Id would also come up here, it's not now because uuid is of type one_of

@zfy0701
Copy link

zfy0701 commented Nov 8, 2024

any change this get merge? @johanbrandhorst it's super useful

Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

Don't know how I forgot about this PR, but it looks reasonable to me.

@johanbrandhorst
Copy link
Collaborator

I'm going to close and reopen this to re-trigger the CI

@johanbrandhorst
Copy link
Collaborator

Looks like we still need to rerun the generation script (see CONTRIBUTING.md). If the original author @amanraja cannot pick this back up, feel free to copy the changes to a new PR.

@amanraja
Copy link
Author

amanraja commented Nov 9, 2024

Hey @johanbrandhorst , have ran the generation script now, Please check the PR again , there are few changes changes have come up because of it.

Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

I think there's still a bug here

Comment on lines -483 to -495
{
"name": "status.progress",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "status.note",
"in": "query",
"required": false,
"type": "string"
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these were removed incorrectly, no? There's nothing in this RPC definition that means the status query parameters shouldn't show up, I think? Here's the definition:

additional_bindings: {get: "/v1/example/echo/{id}/{num}/{lang}"}
. I think it's removing all oneofs instead of just the lineNum oneof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An RPC proto oneof field documents the field not used in the path as an optional request parameter
4 participants