GRPC JSON transcoding : query parameters not "discovered"
See original GitHub issueThis is about #167 and https://docs.microsoft.com/en-us/aspnet/core/grpc/httpapi?view=aspnetcore-5.0
Given the following proto
syntax = "proto3";
option csharp_namespace = "user_management";
import "google/api/annotations.proto";
service UserListService {
//List users
rpc ListUsers (ListUserRequest) returns (UserList) {
option (google.api.http) = {
get: "/v1/users";
};
}
}
message ListUserRequest {
int32 page_size = 1;
int32 page_nb = 2;
string order_by = 3;
string name = 4;
}
message UserList {
int32 total = 1;
int32 page_nb = 2;
repeated UserItem data = 3;
}
//Partial details for a user
message UserItem{
string id = 1;
string name = 2;
}
I would expect that ListUserRequest is exposed as query parameters
Indeed, calling http://localhost:5000/v1/users?page_size=10&page_nb=1 will correctly submit the parameters to the C# class
However, the generated swagger as explained at https://docs.microsoft.com/en-us/aspnet/core/grpc/httpapi?view=aspnetcore-5.0#enable-swaggeropenapi-support does not contain them
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Configure HTTP and JSON for gRPC JSON transcoding
gRPC JSON transcoding routes support route parameters. For example, {name} in a route binds to the name field on the request message.
Read more >gRPC JSON transcoding : using repeated fields in query ...
I'm trying to make a request via Swagger using JSON transcoding, but I'm encountering an error when I use a repeated field parameter...
Read more >gRPC-JSON transcoder (proto)
(repeated string) A list of query parameters to be ignored for transcoding method mapping. By default, the transcoder filter will not transcode a...
Read more >Transcoding HTTP/JSON to gRPC - Cloud Endpoints
Transcoding involves mapping HTTP/JSON requests and their parameters to gRPC ... field not bound by the path template should be mapped to the...
Read more >gRPC JSON Transcoding in .NET 7
With gRPC JSON Transcoding, any application that can issue an HttpRequest can use the service. The application can issue a HTTP/1.1 or an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JamesNK thanks for your answer
if there is no way to include them automatically, what is the way to include them explicitly ?
for ex, for post I can do :
however, there is no such thing for get (at least that I can see)
it seems wrong to do
another point (already said in the ticket, sorry for redundancy) is that if I call http://localhost:5000/v1/users?page_size=10&page_nb=1, then it will correctly submit the parameters to the C# class -> why are they not documented in the OpenApi part if I can use them (and because it is a GET, it is the ONLY possible way to use them anyway)
final point, the google docs https://cloud.google.com/endpoints/docs/grpc-service-config/reference/rpc/google.api#google.api.HttpRule
Hope it helps to make a decision in my favor 😃 😃 😃
This is done in the OpenAPI integration for gRPC JSON transcoding:
https://learn.microsoft.com/en-us/aspnet/core/grpc/json-transcoding-openapi?view=aspnetcore-7.0