-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Support nested messages in GET request queries #492
Comments
As far as I can tell, there isn't a way to specify a repeated message field using GET query parameters alone. Only repeated primitive fields (strings, ints, bools, floats, etc) are supported in query parameters. See runtime/query.go. Can you use POST instead? |
I think @rogerhub's answer is probably the best way to go here. I'm not sure what the standard syntax for repeated fields in a query string would be. I guess the PHP format? I'm not sure though and think you would probably be happier with this as a different verb. |
I think there's a valid use case for this. In my case, I have a A simplified example: service ResourceService {
rpc ListResource (ListResourceRequest) returns (ListResourceResponse) {
option (google.api.http) = {
get: "/api/resource"
};
}
}
message ListResourceRequest {
ResourceFilter filter = 1;
}
message ResourceFilter {
repeated string ID = 1;
repeated RangeFilter range = 2;
}
message RangeFilter {
int64 minimum = 1;
int64 maximum = 2;
}
message myMethodResponse {
repeated Resource resources = 1;
} Trying a request:
{"error":"unexpected repeated field in filter.resources.ranges.minimum","message":"unexpected repeated field in filter.resources.ranges.minimum","code":3,"details":[]} In this case, the method really shouldn't be I also understand the syntax isn't obvious, but there are a few alternatives that could work, and the benefit of supporting a use case like the one above is quite significant. For me, being able to specify the structure of the filters in the protos format helps make sense of an otherwise complex part of the API. The commonly seen alternative of using a string field as generic filter (e.g. So, for the use case I've laid out above (and I could conceive of others), I'd be grateful if you could reconsider supporting repeated message fields in query strings. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
*Bump I agree with @kwoodhouse93 there is valid use case for this. |
I agree with the proposal and willing to solve this, I am new to this repo so what will be a good starting point to solve this? |
Hi @sum2000, thanks for showing an interest in contributing! I think all the query parameter parsing happens in Line 47 in 5ebe3a8
|
Thanks, will do! Is there a discord or chat for grpc-gateway ? |
We have a channel on the gophers slack: #grpc-gateway after joining https://invite.slack.golangbridge.org/. |
any updates? quite a good feature to support |
I don't think there's been any work on this recently unfortunately, but if you'd like to see this feature in the gateway, please feel free to have a go at implementing it. My advice above is still relevant. |
I just ran into this same issue. We created an ordering struct |
Given the
with GET request
returns an error
The text was updated successfully, but these errors were encountered: