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

CollectionFormat multi for query params of repeated fields 2 #909

Merged

Conversation

bmperrea
Copy link
Contributor

This fixes the issues introduced in #902 , reverted in #907 , to solve #756 . The issue was that we were adding collectionFormat in all calls to the function schemaOfField not only in queryParams.

For reference the last commit in this branch is the diff from #902 , which includes the removal of several collectionFormat: multi lines. I have confirmed using the live demo of swagger editor that those lines in response_body_service indeed make the swagger "Structural errors" against the spec. The new generated examples appear to follow the spec according to that tool.

@codecov-io
Copy link

codecov-io commented Mar 14, 2019

Codecov Report

Merging #909 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #909      +/-   ##
=========================================
- Coverage   53.52%   53.5%   -0.03%     
=========================================
  Files          40      40              
  Lines        3959    3957       -2     
=========================================
- Hits         2119    2117       -2     
  Misses       1642    1642              
  Partials      198     198
Impacted Files Coverage Δ
protoc-gen-swagger/genswagger/types.go 0% <ø> (-19.05%) ⬇️
protoc-gen-swagger/genswagger/template.go 56.42% <100%> (+0.08%) ⬆️

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 e81e272...cc0d6af. Read the comment docs.

@bmperrea bmperrea changed the title Use collectionFormat multi for query params of repeated fields 2 CollectionFormat multi for query params of repeated fields 2 Mar 14, 2019
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.

Thanks for the quick turnaround on this @bmperrea, fantastic work! I can see you added a test case for repeated enums, will that cover the bug that was introduced?

@bmperrea bmperrea force-pushed the collection-format-multi2 branch from 1990b43 to cc0d6af Compare March 14, 2019 14:13
@bmperrea
Copy link
Contributor Author

@johanbrandhorst - that queryParams test case was in the previous PR as well. But to your point, I just added another commit that adds stricter (and cleaner) deepEqual-based testing of the behavior of schemaOfField that would have failed on my previous PR - here's the output from when I tried it (you can pick out the "only specify multi in the method queryParams" commit on this branch and then run the tests as shown to repeat):

$ go test ./protoc-gen-swagger/genswagger/
--- FAIL: TestSchemaOfField (0.00s)
    template_test.go:1176: Expected schemaOfField(name:"repeated_primitive_field" label:LABEL_REPEATED type:TYPE_STRING ) = {{array   [] 0xc00014f680 [] } <nil> <nil>   <nil> false 0 0 false 0 false 0 0  0 0 false 0 0 [] }, actual: {{array   [] 0xc00014fa00 [] } <nil> <nil>   <nil> false 0 0 false 0 false 0 0  0 0 false 0 0 [] multi}
    template_test.go:1176: Expected schemaOfField(name:"repeated_wrapped_field" label:LABEL_REPEATED type:TYPE_MESSAGE type_name:".google.protobuf.StringValue" ) = {{array   [] 0xc00014f700 [] } <nil> <nil>   <nil> false 0 0 false 0 false 0 0  0 0 false 0 0 [] }, actual: {{array   [] 0xc00014fd00 [] } <nil> <nil>   <nil> false 0 0 false 0 false 0 0  0 0 false 0 0 [] multi}

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.

Thanks for this!

@johanbrandhorst johanbrandhorst merged commit 5e6c709 into grpc-ecosystem:master Mar 14, 2019
@johanbrandhorst
Copy link
Collaborator

@mmarod @c2nc I've merged this to master, could you both confirm this is still working for you before I make a release?

@mmarod
Copy link

mmarod commented Mar 14, 2019

@johanbrandhorst I can check in a few hours

@mmarod
Copy link

mmarod commented Mar 14, 2019

Looks good to me @johanbrandhorst -- and nice job @bmperrea

@johanbrandhorst
Copy link
Collaborator

Thanks for confirming @mmarod, I will make another release.

adasari pushed a commit to adasari/grpc-gateway that referenced this pull request Apr 9, 2020
…osystem#909)

* Use collectionFormat multi for query params of repeated fields

Fixes grpc-ecosystem#756 . Also formats protoc-gen-swagger/genswagger/template_test.go according to go fmt.

* regenerate the files

* only specify multi in the method queryParams

Fixes grpc-ecosystem#906.

* deep equal checks in TestSchemaOfField
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.

5 participants