When using the gRPC transcoding package, in combination with the gRPC swagger definitions, the generated documentation is incorrect when using enums.
I've spent some time narrowing this down and believe I've reproduced the behaviour - it appears to be when using an enum in a .proto file. If an enum is only used in a response contract, then the generated swagger correctly states the response type to be a string type enum.
However, when an enum is used in a request contract, then the swagger type is created as an integer incorrectly:
When using an enum in a request message for a gRPC transcoded API, the generated swagger definition should show that enum as a string when WriteEnumsAsIntegers is false.
If you clone the repo, dotnet run and browse to the swagger site: http://localhost:5122/swagger/ you'll see the ResponseOnlyEnum generated type is a string, but the RequestOnlyEnum and SharedEnum are both created as int32
Is there an existing issue for this?
Describe the bug
When using the gRPC transcoding package, in combination with the gRPC swagger definitions, the generated documentation is incorrect when using enums.
I've spent some time narrowing this down and believe I've reproduced the behaviour - it appears to be when using an enum in a
.proto
file. If an enum is only used in a response contract, then the generated swagger correctly states the response type to be astring
type enum.However, when an enum is used in a
request
contract, then the swagger type is created as an integer incorrectly:Generated from the following
.proto
file: greet.proto.txtExpected Behavior
When using an
enum
in arequest
message for a gRPC transcoded API, the generated swagger definition should show that enum as astring
whenWriteEnumsAsIntegers
is false.Steps To Reproduce
I've created a repo here that demonstrates the issue: https://github.com/abbottdev/grpc-swagger-repo
This change may be related to https://github.com/dotnet/aspnetcore/issues/51036
If you clone the repo,
dotnet run
and browse to the swagger site:http://localhost:5122/swagger/
you'll see theResponseOnlyEnum
generated type is a string, but theRequestOnlyEnum
andSharedEnum
are both created asint32
Exceptions (if any)
No response
.NET Version
8.0
Anything else?
Asp.NET Core 8.0.5 and associated packages