HttpApi doesn't write empty strings
See original GitHub issueNot sure if I need to make an issue about HttpApi here. https://github.com/grpc/grpc-dotnet/issues/167 is for feedback, however there are 47 people subscribed to the thread which I don’t want to notify. Also https://github.com/aspnet/AspLabs has issues disabled which brings me here.
What version of gRPC and what language are you using?
Grpc.AspNetCore : 2.32.0
Microsoft.AspNetCore.Grpc.HttpApi : 0.1.0-alpha.20580.2
Microsoft.AspNetCore.Grpc.Swagger : 0.1.0-alpha.20580.2
What operating system (Linux, Windows,…) and version?
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
What runtime / compiler are you using (e.g. .NET Core SDK version dotnet --info
)
.NET SDK (reflecting any global.json):
Version: 5.0.100
Commit: 5044b93829
Host (useful for support):
Version: 5.0.0
Commit: cf258a14b7
What did you do?
I’ve created a gRPC service that returns the following message:
message GuildUser {
uint64 id = 1;
string username = 2;
string discriminator = 3;
string nickname = 4;
}
After that I’ve followed https://docs.microsoft.com/en-us/aspnet/core/grpc/httpapi to create a REST API for the service.
What did you expect to see?
Messages with all their fields.
What did you see instead?
Messages with missing fields.
When an empty string is being written, the field is omitted. On the client-side this would cause the value to be null
(or undefined
in JavaScript), while it should be an empty string.
Screenshot:
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Use empty string, null or remove empty property in API ...
Going with an empty string is a definitive no. Empty string still is a value, it is just empty. No value should be...
Read more >AWS API Gateway HTTP API how to pass string query ...
I'm not familiar with Serverless Frameworks for APIGW, but manipulating QueryString parameters is built into the APIGW Console.
Read more >Working with routes for HTTP APIs
Routes direct incoming API requests to backend resources. Routes consist of two parts: an HTTP method and a resource path—for example, GET /pets...
Read more >.empty() | jQuery API Documentation
Description: Remove all child nodes of the set of matched elements from the DOM. version added: 1.0.empty(). This method does not accept any...
Read more >Amazon API Gateway API request and response data ...
This section explains how to set up data mappings from an API's method request data, including other data stored in context, stage, or...
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
It looks like emitting default values is on by default in grpc-gateway V2. I didn’t know it had changed.
In that case it should be turned on in HttpApi.
how to turn it on to not emit the default value in json response? i am currently use go and find no way to do this