dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.

Home Page:https://asp.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swagger method with empty body for grpc get request

careless6666 opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

We use gRPC HTTP API from project (https://github.com/aspnet/AspLabs/tree/main/src/GrpcHttpApi)

when generating a grpc getway, there is a problem that the contract that maps to the get request describes the parameters that should go into the query string, but instead a swagger is generated without any parameters at all

example

`
syntax = "proto3";

import "google/api/annotations.proto";

package greet;

service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {
option (google.api.http) = {
get: "/v1/greeter"
};
}
}

message HelloRequest {
string name = 1 ;
string test = 2;
}

`
it is generate curl in swagger with empty form for get method like this

curl -X GET "http://localhost:5180/v1/greeter" -H "accept: application/json"

expected

curl -X GET "http://localhost:5180/v1/greete?name=test1&test=test2" -H "accept: application/json"

My code example
https://github.com/careless6666/grpc-swagger-issue/tree/feature/empty-params

Expected Behavior

Expected swagger with form for input query string parameters and same curl

curl -X GET "http://localhost:5180/v1/greete?name=test1&test=test2" -H "accept: application/json"

Steps To Reproduce

My code example with full reproduce problem

https://github.com/careless6666/grpc-swagger-issue/tree/feature/empty-params

Exceptions (if any)

No response

.NET Version

dotnet 6.0

Anything else?

No response

Hello. I suggested a fix idea for the grpc swagger query parameters resolver (for all methods), link above. Thx.

I think it looks good, but my opinion does not matter much, what matters is what says @JamesNK , who wrote almost all of this part related to the grps