Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger Gen: underscores -> lowerCamelCase field names and refs #261

Closed
msample opened this issue Nov 16, 2016 · 6 comments
Closed

Swagger Gen: underscores -> lowerCamelCase field names and refs #261

msample opened this issue Nov 16, 2016 · 6 comments

Comments

@msample
Copy link
Contributor

msample commented Nov 16, 2016

Protobuf3 style guidelines suggest using underscores in Message field names in .proto files, and the JSON mappings will be translated to use lowerCamelCase field names (https://developers.google.com/protocol-buffers/docs/proto3).

For the same reasons (ie JSON encoding derived form the Swagger), shouldn't these field names be in lowerCamelCase format in the grpc-gateway-generated Swagger as well?

I am running into this issue using swagger-codegen on Swagger produced by grpc-gateway. The work around is to use the lowerCamelCase in original protobuf files - I am not sure if this introduces problems with other protoc codegen paths.

@tmc
Copy link
Collaborator

tmc commented Nov 20, 2016

This is a little tricky since the marshaler can be customized -- IMO defaulting to the default marshaler &JSONPb{OrigName: true} is the most appropriate behavior here.

@achew22
Copy link
Collaborator

achew22 commented Nov 20, 2016

I would also be supportive of switching over to &JSPNpb{OrigName: true} as the default. This is another breaking change. Maybe we should wrap this up along with the context change and do a 2.0 release?

@tmc
Copy link
Collaborator

tmc commented Nov 20, 2016

Just to be clear the current behavior is expected. Respecting the field names in the proto file vs the canonical json representation of proto3 (lowerCamelCase) was introduced in PR #151 (adding OrigName: true).

This probably merits a documentation addition.

If we want to discuss changing the default marshaler configuration (and the swagger output) we can in another issue.

@tmc tmc closed this as completed Nov 20, 2016
@tmc
Copy link
Collaborator

tmc commented Nov 20, 2016

opened #266

@tamalsaha tamalsaha mentioned this issue Mar 30, 2017
1 task
@yingzong
Copy link

yingzong commented Sep 18, 2017

This is a little tricky since the marshaler can be customized -- IMO defaulting to the default marshaler &JSONPb{OrigName: true} is the most appropriate behavior here.

@tmc How do you customize the marshaler, specifically the OrigName: false in the --protoc-gen-swagger plugin?

@tmc
Copy link
Collaborator

tmc commented Sep 19, 2017

@yingzong unfortunately there is not a mechanism to provide these options. You can open a feature request to allow providing an option of this sort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants