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

protoc-gen-swagger, Fix for infinite loop on circular references in query parameters #1266

Conversation

Romeren
Copy link
Contributor

@Romeren Romeren commented May 4, 2020

Added function nestedQueryParams in proto-gen-swagger/genswagger/template.go with map[string]bool parameter for keeping track of and detecting circular references.
Added test TestMessageToQueryParametersRecursive in proto-gen-swagger/genswagger/template_test.go for testing gracefully handling of circular references between messages.
See issue #1167

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@codecov-io
Copy link

codecov-io commented May 4, 2020

Codecov Report

Merging #1266 into master will increase coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1266      +/-   ##
==========================================
+ Coverage   53.99%   54.14%   +0.15%     
==========================================
  Files          42       42              
  Lines        4369     4375       +6     
==========================================
+ Hits         2359     2369      +10     
+ Misses       1752     1750       -2     
+ Partials      258      256       -2     
Impacted Files Coverage Δ
protoc-gen-swagger/genswagger/template.go 57.62% <100.00%> (+0.54%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01598a7...ea71c3c. Read the comment docs.

@Romeren
Copy link
Contributor Author

Romeren commented May 4, 2020

@googlebot I signed it!

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@Romeren
Copy link
Contributor Author

Romeren commented May 4, 2020

@googlebot I fixed it.

@Romeren
Copy link
Contributor Author

Romeren commented May 4, 2020

@googlebot I fixed 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.

This is fantastic! Thanks so much for putting this together, and I love your comments. A+, I've only got some grammatical comments, I think the more commonly used phrase for this sort of thing is cycle, so I've made some suggestions. Thanks for your contribution!

protoc-gen-swagger/genswagger/template.go Outdated Show resolved Hide resolved
protoc-gen-swagger/genswagger/template.go Outdated Show resolved Hide resolved
protoc-gen-swagger/genswagger/template.go Outdated Show resolved Hide resolved
protoc-gen-swagger/genswagger/template_test.go Outdated Show resolved Hide resolved
protoc-gen-swagger/genswagger/template_test.go Outdated Show resolved Hide resolved
protoc-gen-swagger/genswagger/template_test.go Outdated Show resolved Hide resolved
…ng track of and detecting circular references. Added test TestMessageToQueryParametersRecursive for testing gracefully handling of circular references between messages. See issue grpc-ecosystem#1167
@Romeren Romeren force-pushed the fix-swagger-gen-infinite-loop-on-queryparam-with-circular-ref branch from 50ae79d to 02f5169 Compare May 4, 2020 09:38
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels May 4, 2020
@Romeren Romeren requested a review from johanbrandhorst May 4, 2020 09:52
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no and removed cla: yes labels May 4, 2020
@Romeren Romeren force-pushed the fix-swagger-gen-infinite-loop-on-queryparam-with-circular-ref branch from 245886a to ded59b5 Compare May 4, 2020 10:32
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels May 4, 2020
@Romeren
Copy link
Contributor Author

Romeren commented May 4, 2020

Hmm... I seem to continuously run into issues with cla/google. It does not like my setup with multiple email accounts... but i think i have managed to get it working.

I have accepted all your requested changed

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.

Looks like a missed a few circle references, sorry!

protoc-gen-swagger/genswagger/template_test.go Outdated Show resolved Hide resolved
protoc-gen-swagger/genswagger/template_test.go Outdated Show resolved Hide resolved
protoc-gen-swagger/genswagger/template_test.go Outdated Show resolved Hide resolved
protoc-gen-swagger/genswagger/template_test.go Outdated Show resolved Hide resolved
@johanbrandhorst johanbrandhorst merged commit 9e25b2b into grpc-ecosystem:master May 4, 2020
@johanbrandhorst
Copy link
Collaborator

Thanks for your contribution! Could you please cherry pick this commit to v2?

pull bot pushed a commit to BuildingRobotics/grpc-gateway that referenced this pull request May 7, 2020
… parameters (grpc-ecosystem#1266)

* Added function nestedQueryParams with map[string] parameter for keeping track of and detecting circular references. Added test TestMessageToQueryParametersRecursive for testing gracefully handling of circular references between messages. See issue grpc-ecosystem#1167

* Code-review change requests accepted

* More missed circle references changed to cycle

Fixes grpc-ecosystem#1167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants