[JsonTranscoding] Requesting that when there is an error response the code field in google.grpc.Status gets json serialized as the enum value (string) instead of the int code
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
When using the JsonTranscoding Library and there is a non successful response the error response body contains an integer error code that corresponds to:
https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto#L38
For ex:
```
{
"code": 10,
"message": "TEST ERROR",
"details": []
}
```
It would be great if we could have an option to update the JsonSerialization of the Status in the case of an error response to populate the enum name as a string instead of the integer error code.
### Describe the solution you'd like
I would suggest that we update:
https://github.com/dotnet/aspnetcore/blob/bec278eabea54f63da15e10e654bdfa4168a2479/src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/Internal/JsonRequestHelpers.cs#L85-L99
To allow for returning using a custom status message proto where the code was an enum instead of an integer:
https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
This would allow the json to contain the enum value instead of the integer code.
We could add an option to enable this functionality here: https://github.com/dotnet/aspnetcore/blob/bec278eabea54f63da15e10e654bdfa4168a2479/src/Grpc/JsonTranscoding/src/Microsoft.AspNetCore.Grpc.JsonTranscoding/GrpcJsonSettings.cs#L9
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.