We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi guys,
I have the following files
AdminAPI.proto:
AdminAPI.proto
syntax = "proto3"; option go_package = "./admin"; package admin; import "google/protobuf/empty.proto"; service AdminService { rpc GetInstruments(GetInstrumentsRequest) returns (InstrumentList); } message InstrumentNameList { repeated string names = 1; } message GetInstrumentsRequest { oneof instrument_name_filter { google.protobuf.Empty all_instrument_names = 1; InstrumentNameList instrument_name_list = 2; } } message InstrumentList { repeated Instrument instruments = 1; } message Instrument { // long definition here }
grpc_api_configuration.yaml:
grpc_api_configuration.yaml
type: google.api.Service config_version: 3 http: rules: - selector: admin.AdminService.GetInstruments get: /v1/instruments
buf.gen.yaml:
buf.gen.yaml
version: v1 plugins: - plugin: go out: gen opt: - paths=source_relative - plugin: go-grpc out: gen opt: - paths=source_relative - plugin: grpc-gateway out: gen opt: - paths=source_relative - grpc_api_configuration=grpc_api_configuration.yaml - plugin: openapiv2 out: docs opt: - grpc_api_configuration=grpc_api_configuration.yaml - output_format=yaml
After generating code with buf generate I get the following in my swagger:
buf generate
paths: /v1/instruments: get: operationId: AdminService_GetInstruments responses: "200": description: A successful response. schema: $ref: '#/definitions/adminInstrumentList' default: description: An unexpected error response. schema: $ref: '#/definitions/rpcStatus' parameters: - name: allInstrumentNames in: query required: false type: object - name: instrumentNameList.names in: query required: false type: array items: type: string collectionFormat: multi tags: - AdminService
Seems it's impossible to provide allInstrumentNames in query. I tried different options, but always get an error
allInstrumentNames
{ "code": 3, "message": "parsing field \"all_instrument_names\": unsupported message type: \"google.protobuf.Empty\"", "details": [] }
Underlying gRPC service expects whether all_instrument_names or instrument_name_list to be filled, and we cannot change it.
all_instrument_names
instrument_name_list
If proto service method accepts just google.protobuf.Empty, everything works fine since REST server doesn't except any query parameters.
google.protobuf.Empty
Also, if I change method to POST, everything becomes ok with the following request:
{ "allInstrumentNames": {} }
So are there any ways to fix it?
There is a way to pass google.protobuf.Empty struct in query parameter.
REST server returns error
grpc-gateway version is v2.22.0
grpc-gateway
The text was updated successfully, but these errors were encountered:
I don't know of any way to accomplish this, no.
Sorry, something went wrong.
No branches or pull requests
🐛 Bug Report
Hi guys,
I have the following files
AdminAPI.proto
:grpc_api_configuration.yaml
:buf.gen.yaml
:After generating code with
buf generate
I get the following in my swagger:Seems it's impossible to provide
allInstrumentNames
in query. I tried different options, but always get an errorUnderlying gRPC service expects whether
all_instrument_names
orinstrument_name_list
to be filled, and we cannot change it.If proto service method accepts just
google.protobuf.Empty
, everything works fine since REST server doesn't except any query parameters.Also, if I change method to POST, everything becomes ok with the following request:
{ "allInstrumentNames": {} }
So are there any ways to fix it?
Expected behavior
There is a way to pass
google.protobuf.Empty
struct in query parameter.Actual Behavior
REST server returns error
Your Environment
grpc-gateway
version is v2.22.0The text was updated successfully, but these errors were encountered: