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

Configure response content type at the method level #1130

Merged

Conversation

nboukeffa
Copy link
Contributor

This PR will add the possibility to configure the response content
type at the method level.

To do such the developer will have to set the produces property
like in the following example.

rpc OverwriteResponseContentType(google.protobuf.Empty) returns (google.protobuf.StringValue) {
	option (google.api.http) = {
		get: "/v2/example/overwriteresponsecontenttype"
	};
	option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
		produces: "application/text"
	};
}

@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.

This PR will add the possibility to configure the response content
type at the method level.

To do such the developer will have to set the `produces` property
like in the following example.

```
rpc OverwriteResponseContentType(google.protobuf.Empty) returns (google.protobuf.StringValue) {
	option (google.api.http) = {
		get: "/v2/example/overwriteresponsecontenttype"
	};
	option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
		produces: "application/text"
	};
}
```
@nboukeffa
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@nboukeffa
Copy link
Contributor Author

I'm not sure why the build is failing on Circle CI. It's passing locally. If someone can help...

@johanbrandhorst
Copy link
Collaborator

The bazel failure should be fixed by running:

$ docker run -itv $(pwd):/grpc-gateway -w /grpc-gateway --entrypoint /bin/bash --rm \
    l.gcr.io/google/bazel -c 'bazel run :gazelle'

From https://github.com/grpc-ecosystem/grpc-gateway/blob/master/CONTRIBUTING.md

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.

LGTM, lets just get the bazel error fixed (I think it's the new wrappers import in a_bit_of_everything.proto that's causing it).

@codecov-io
Copy link

Codecov Report

Merging #1130 into master will decrease coverage by 0.06%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1130      +/-   ##
=========================================
- Coverage   53.87%   53.8%   -0.07%     
=========================================
  Files          42      42              
  Lines        4197    4202       +5     
=========================================
  Hits         2261    2261              
- Misses       1689    1693       +4     
- Partials      247     248       +1
Impacted Files Coverage Δ
protoc-gen-swagger/genswagger/types.go 0% <ø> (ø) ⬆️
examples/server/a_bit_of_everything.go 0% <0%> (ø) ⬆️
protoc-gen-swagger/genswagger/template.go 56.72% <0%> (-0.16%) ⬇️

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 4c2cec4...11efb19. Read the comment docs.

@johanbrandhorst johanbrandhorst merged commit c3048a0 into grpc-ecosystem:master Feb 14, 2020
@johanbrandhorst
Copy link
Collaborator

Thanks for your contribution!

@nboukeffa
Copy link
Contributor Author

All green. You were right the import was missing in the build definition. Your command did the trick.

Maybe adding it to the CONTRIBUTING.md could help.

@nboukeffa nboukeffa deleted the response-type-overwrite branch March 20, 2020 13:19
adasari pushed a commit to adasari/grpc-gateway that referenced this pull request Apr 9, 2020
)

* Configure response content type at the method level

This PR will add the possibility to configure the response content
type at the method level.

To do such the developer will have to set the `produces` property
like in the following example.

```
rpc OverwriteResponseContentType(google.protobuf.Empty) returns (google.protobuf.StringValue) {
	option (google.api.http) = {
		get: "/v2/example/overwriteresponsecontenttype"
	};
	option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
		produces: "application/text"
	};
}
```

* Fix build
pull bot pushed a commit to BuildingRobotics/grpc-gateway that referenced this pull request Apr 29, 2020
)

* Configure response content type at the method level

This PR will add the possibility to configure the response content
type at the method level.

To do such the developer will have to set the `produces` property
like in the following example.

```
rpc OverwriteResponseContentType(google.protobuf.Empty) returns (google.protobuf.StringValue) {
	option (google.api.http) = {
		get: "/v2/example/overwriteresponsecontenttype"
	};
	option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
		produces: "application/text"
	};
}
```

* Fix build
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