Microsoft.AspNetCore.Grpc.Swagger doesn't respect WriteEnumsAsIntegers for request contracts
abbottdev opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When using the gRPC transcoding package to generate swagger definitions, the generated swagger is incorrect when using enums.
I've spent some time narrowing this down and have reproduced the behaviour - it appears to be when using an enum in a .proto
file- if that enum is only used in a response contract, then the generated swagger states the response type to be a string
type enum. Whenever, however, an enum is used in a request
contract, then the swagger type is created as an integer:
Generated from the following .proto
file:
greet.proto.txt
Expected Behavior
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.
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 #51036
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
Exceptions (if any)
No response
.NET Version
8.0
Anything else?
Asp.NET Core 8.0.5 and associated packages