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

make generated swagger json match gateway behavior for server streams #850

Merged
merged 6 commits into from
Jan 23, 2019
Merged

make generated swagger json match gateway behavior for server streams #850

merged 6 commits into from
Jan 23, 2019

Conversation

mechinn
Copy link
Contributor

@mechinn mechinn commented Jan 17, 2019

Fixes #579, until v2 removes "result" wrapping of server stream response messages this will make protoc-gen-swagger wrap server stream messages in a result object which matches the gateway's behavior for consistency.

@codecov-io
Copy link

codecov-io commented Jan 17, 2019

Codecov Report

Merging #850 into master will increase coverage by 1.32%.
The diff coverage is 71.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #850      +/-   ##
==========================================
+ Coverage   51.75%   53.08%   +1.32%     
==========================================
  Files          39       39              
  Lines        3824     3845      +21     
==========================================
+ Hits         1979     2041      +62     
+ Misses       1655     1610      -45     
- Partials      190      194       +4
Impacted Files Coverage Δ
protoc-gen-swagger/genswagger/types.go 19.04% <ø> (ø) ⬆️
runtime/handler.go 41.6% <ø> (ø) ⬆️
protoc-gen-swagger/genswagger/generator.go 0% <0%> (ø) ⬆️
protoc-gen-swagger/main.go 24.46% <0%> (-2.34%) ⬇️
protoc-gen-swagger/genswagger/template.go 53.48% <76.19%> (+5.14%) ⬆️
runtime/mux.go 44.16% <0%> (-1.37%) ⬇️
examples/server/responsebody.go 0% <0%> (ø) ⬆️
runtime/marshal_jsonpb.go 70.58% <0%> (+1.48%) ⬆️

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 9221822...ae2eca3. Read the comment docs.

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 valuable contribution! I'm wondering if we could consider adding some automated tests to this as well? I see the regeneration of the files have output some differences which is a good indication that it's working but some automated tests should allow us to prevent regressions as well. What do you think?

protoc-gen-swagger/genswagger/types.go Outdated Show resolved Hide resolved
@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 have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot
Copy link

CLAs look good, thanks!

@johanbrandhorst
Copy link
Collaborator

@mechinn Are you planning on fixing this soon? I'm looking to make a release soon and just wondering if I should wait for this to be ready.

@mechinn
Copy link
Contributor Author

mechinn commented Jan 22, 2019

@mechinn Are you planning on fixing this soon? I'm looking to make a release soon and just wondering if I should wait for this to be ready.

yeah sorry getting back to work on the error part after the long weekend

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 good to me, just a few questions before we merge.

protoc-gen-swagger/genswagger/template.go Show resolved Hide resolved
if meth.GetServerStreaming() {
runtimeStreamError := fullyQualifiedNameToSwaggerName(".grpc.gateway.runtime.StreamError", reg)
glog.V(1).Infof("StreamError FQMN: %s", runtimeStreamError)
streamError, err := reg.LookupMsg(".grpc.gateway.runtime", "StreamError")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto

protoc-gen-swagger/genswagger/template.go Show resolved Hide resolved
protoc-gen-swagger/genswagger/template.go Show resolved Hide resolved
protoc-gen-swagger/genswagger/template.go Show resolved Hide resolved
@johanbrandhorst
Copy link
Collaborator

Really excited to land this, thanks for the contribution @mechinn!

@johanbrandhorst johanbrandhorst merged commit f336fbc into grpc-ecosystem:master Jan 23, 2019
adasari pushed a commit to adasari/grpc-gateway that referenced this pull request Apr 9, 2020
…grpc-ecosystem#850)

* grpc-ecosystem#579 fixing protoc-gen-swagger to wrap server stream messages with "result" object to match gateway behavior

* grpc-ecosystem#579 fixing test example swagger json

* change streamdefinitions to x-stream-definitions and add test

* move runtime internal to root of repo for use in protoc-gen-swagger, adding error to stream wrapper

* adding comment explaining AddStreamError

* fix bazel
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