-
Notifications
You must be signed in to change notification settings - Fork 5k
Open
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues
Kong version ($ kong version)
3.10
Current Behavior
With an example Proto file like:
syntax = "proto3";
package example.v1;
import "google/protobuf/wrappers.proto";
enum RegionType {
TYPE_1 = 0;
TYPE_2 = 1;
}
message Region {
RegionType type = 1;
google.protobuf.StringValue code = 2;
}
message Summary {
message More {
int64 diff = 1;
}
message Same {}
message NoneFound {}
oneof state {
More more = 1;
Same same = 2;
NoneFound none_found = 3;
}
}
message Bucket {
repeated string dates = 1;
Summary summary = 2
}
message ExampleRequest {
Region origin = 1;
Region destination = 2;
}
message ExampleResponse {
repeated Bucket buckets = 1;
}
service BucketDataService {
rpc GetBuckets(ExampleRequest) returns (ExampleResponse) {
option (google.api.http) = {
post: "/buckets"
body: "*"
};
};
}
We are experiencing two issues with how it's being translated to JSON by the grpc-gateway plugin.
google.protobuf.StringValueis not getting treated as a string. So in the request thecodeportion was only accepted when it was formatted as
"code": {
"value": "YOW"
}
oneofseems to be producing some odd schema structure. So in the response thesummaryportion was returned formatted as
"summary": {
"state": "same",
"same": {}
}
Expected Behavior
For the two noted issues in current, we expected:
google.protobuf.StringValueis treated as a string, and we could request with
"code": "YOW",
oneofdefined sub resources, so the response would have
"summary": {
"state": {
"same": {}
}
}
Steps To Reproduce
This is a standard grpc-gateway config pattern.
- Mount the proto into the gateway workload
- Create a service for the grpc service
- Create a http route to the service, attach the
grpc-gatewayplugin to this route, and point the plugin to the location of the mounted proto file - Send requests to the http route
Anything else?
We know there has been ongoing effort in #8297 to bring the grpc-gateway up to speed on ProtoJSON standards, however there did not seem to be an issue linked to that work, so maybe this can collect all the issues related to the proto <-> JSON translation that exists, and hopefully get some progress as that effort has been ongoing for > 3 years without resolution.