Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

JSON name of proto field unhelpful. #28

Closed
jackwootton opened this issue Oct 11, 2017 · 0 comments
Closed

JSON name of proto field unhelpful. #28

jackwootton opened this issue Oct 11, 2017 · 0 comments
Labels

Comments

@jackwootton
Copy link

If an interface is defined with the following simple .proto:

message Metasyntactic {
    bool foobar = 1;
    bool fooBar = 2;
    bool foo_bar = 3;
}

...and compiled with protoc:

protoc --include_imports  \
  --include_source_info \
  --proto_path=. meta.proto \
  --descriptor_set_out out.pb

Google API Compiler can be used to generate the Service Configuration file:

$API_COMPILER_HOME./run.sh \ 
  --configs grpc-api-config.yaml \
  --descriptor out.pb \
  --json_out service-config.json

The resulting service configuration file defines a google.protobuf.type for each field.

  • foobar remains foobar
  • fooBar' has a JSON name of foo_bar`
  • foo_bar has a JSON name of fooBar

There are a few problems with this:

  • When an API deployed with this service configuration, any client must use a different naming convention from the server.
  • A Proto Descriptor file and gRPC API Configuration YAML file can be used to deploy a service (API) to Cloud without the need for an explicit service configuration file. This approach does not rename any proto message fields. Therefore, any client code must change significantly depending on how the API is deployed.
    • Use the API Manager and subsequent API configuraton file, and fooBar is received as foo_bar.
    • Use a proto descriptor and gRPC config file, and fooBar is received as fooBar.
@jackwootton jackwootton changed the title JSON name of proto field JSON name of proto field unhelpful. Oct 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants