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

Fix gen-swagger to support more well known types #496

Merged
merged 2 commits into from
Dec 23, 2017

Conversation

shouichi
Copy link
Contributor

@shouichi shouichi commented Dec 7, 2017

Some well know types are not handled correctly. Given we have the following proto message.

// proto
message User {
  google.protobuf.StringValue name = 1;
}

name is output as an object.

// swagger.json
"name": {
  "$ref": "#/definitions/protobufStringValue"
}

It should be output as a primitive.

// swagger.json
"name": {
  "type": "string"
}

This PR adds support for the following well know types.

  • StringValue
  • Int32Value
  • Int64Value
  • FloatValue
  • DoubleValue
  • BoolValue

@achew22
Copy link
Collaborator

achew22 commented Dec 7, 2017

This looks like a great start! I'm excited to merge this. Could you add some tests to verify schemaOfField does the right thing for these new well known types? It looks like we are totally missing coverage on that method right now.

https://github.com/shouichi/grpc-gateway/blob/31e65b13c82edfcf1c78926c59fa829b7ed14841/protoc-gen-swagger/genswagger/template.go#L250

@shouichi
Copy link
Contributor Author

shouichi commented Dec 7, 2017

Sure, thanks for your advice!

@roadrunner
Copy link

+1

@shouichi
Copy link
Contributor Author

shouichi commented Dec 8, 2017

Added test for schemaOfField. I'm not sure if I set up descriptor registry correctly. Feel free to comment if I'm doing something wrong.

@achew22
Copy link
Collaborator

achew22 commented Dec 14, 2017

Sorry this took so long. Looking through the docs a bit I think this is correct. Merging. Thanks for your contribution!

@achew22 achew22 merged commit f60d5c6 into grpc-ecosystem:master Dec 23, 2017
@shouichi shouichi mentioned this pull request Dec 27, 2017
adasari pushed a commit to adasari/grpc-gateway that referenced this pull request Apr 9, 2020
* Fix gen-swagger to support more well known types
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

Successfully merging this pull request may close these issues.

3 participants