Adven27 / grpc-wiremock

gRPC Mock Server
MIT License
93 stars 40 forks source link

Allow preserving proto field names before checking mappings #26

Closed manuel-trejo-rico closed 3 years ago

manuel-trejo-rico commented 3 years ago

Is your feature request related to a problem? Please describe.

Using grpc-wiremock we have noticed that mappings must have request in lowerCamlCase. This is due to the following code: https://github.com/Adven27/grpc-wiremock/blob/830097d13bfb9e01e5f56dfd54fcb7c0a643327e/src/main/java/io/adven/grpc/wiremock/HttpMock.java#L137-L139

There, JsonFormat default printer is used, which by default convert names to lowerCamelCase.

Describe the solution you'd like

To allow preserving proto field names

JsonFormat.preservingProtoFieldNames().printer()

should be called instead of

JsonFormat.printer()

So the solution proposed is to leave the current behavior as it is and, depending on an environment variable that could be set in the container, use the "preservingProtoFieldNames" printer. This way, both approaches could be used.

Describe alternatives you've considered Nothing. If not done we must define requests in lowerCamlCase

Additional context

No further actions needed in the response, because no matter the mapping is lowerCamlCase or snake_case, it is converted right into snake_case for protos: https://github.com/Adven27/grpc-wiremock/blob/830097d13bfb9e01e5f56dfd54fcb7c0a643327e/src/main/java/io/adven/grpc/wiremock/HttpMock.java#L143-L152