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: JSON definitions aren't CamelCased #375

Closed
utrack opened this issue May 3, 2017 · 7 comments
Closed

Swagger: JSON definitions aren't CamelCased #375

utrack opened this issue May 3, 2017 · 7 comments

Comments

@utrack
Copy link
Contributor

utrack commented May 3, 2017

Example:

message Foo {
  string bar_baz = 1;
}

Go generator generates CamelCased JSON field json="barBaz,omitempty", but gen-swagger takes raw name (bar_baz).

https://github.com/golang/protobuf/blob/master/protoc-gen-go/generator/generator.go#L1781

@cheung-chifung
Copy link

same problem.

I think the f.GetName() in following code should be f.GetJsonName().

schema.Properties = append(schema.Properties, keyVal{f.GetName(), fieldValue})

https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-swagger/genswagger/template.go#L186

@achew22
Copy link
Collaborator

achew22 commented Dec 14, 2017

There has been a lot of work on the swagger definitions since this was filed and I think it's likely that this is fixed. If you have more issues please reopen/file a new issue.

@achew22 achew22 closed this as completed Dec 14, 2017
@alexleigh
Copy link
Contributor

This is still an issue. f.GetName() is still being used, resulting in snake_case names rather than camelCase names in the generated swagger definitions.

@achew22
Copy link
Collaborator

achew22 commented Feb 6, 2018

@alexleigh, looks like it is. Would you mind contributing a patch and helping out the community? It would be a great starter to get into the project. Just remember to run make examples afterward to ensure update the goldens.

@achew22 achew22 reopened this Feb 6, 2018
achew22 added a commit to achew22/grpc-gateway that referenced this issue Feb 10, 2018
One of the recurring themes of this project has been trouble around the
default marshaller. This change modifies it to be more what people
expect when they first start the project.

1.  It emits the proto3 json style version of field names instead of the
    field name as it appeared in the .proto file.
2.  It emits zero values for fields. This means that if you have a field
    that is unset it will now have a value unlike before.

Fixes: grpc-ecosystem#540, grpc-ecosystem#375, grpc-ecosystem#254, grpc-ecosystem#233
achew22 added a commit to achew22/grpc-gateway that referenced this issue Apr 9, 2018
One of the recurring themes of this project has been trouble around the
default marshaller. This change modifies it to be more what people
expect when they first start the project.

1.  It emits the proto3 json style version of field names instead of the
    field name as it appeared in the .proto file.
2.  It emits zero values for fields. This means that if you have a field
    that is unset it will now have a value unlike before.

Upgrade to swagger-codegen 2.4.0

Also fix a regex-o in .travis.yml. + needed to be escaped.

Fixes: grpc-ecosystem#540, grpc-ecosystem#375, grpc-ecosystem#254, grpc-ecosystem#233
@tmc tmc added the openapi label Jun 19, 2018
@stale
Copy link

stale bot commented Sep 9, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 9, 2019
@stale stale bot closed this as completed Sep 16, 2019
@johanbrandhorst
Copy link
Collaborator

I think we want to fix this for v2, if it's still an issue.

@johanbrandhorst
Copy link
Collaborator

Fixed in #1376

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