Closed
Description
The --swagger_out plugin yields a swagger definition that translates an int64 protobuf type to a string, even though the Swagger 2.0 OpenAPI specification allows for a signed 64-bit type (type integer
; format int64
). This might be an oversight and/or copy/paste error, as this code section seems to indicate that this was done intentionally for uint64
values.
Example proto file:
syntax = "proto2";
package testmessage;
import "google/api/annotations.proto";
message TestMessage {
optional int32 int32Field = 1;
optional int64 int64Field = 2;
optional uint32 uint32Field = 3;
optional uint64 uint64Field = 4;
}
service TestService {
rpc DoItNow(TestMessage) returns (TestMessage) {
option (google.api.http) = {
post: "/do/it/now"
body: "*"
};
}
}
Running protoc
with the grpc-gateway
plugin and the --swagger_out
output currently yields this swagger definition:
{
"swagger": "2.0",
"info": {
"title": "TestService.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/do/it/now": {
"post": {
"operationId": "DoItNow",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/testmessageTestMessage"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/testmessageTestMessage"
}
}
],
"tags": [
"TestService"
]
}
}
},
"definitions": {
"testmessageTestMessage": {
"type": "object",
"properties": {
"int32Field": {
"type": "integer",
"format": "int32"
},
"int64Field": {
"type": "string",
"format": "int64"
},
"uint32Field": {
"type": "integer",
"format": "int64"
},
"uint64Field": {
"type": "string",
"format": "uint64"
}
}
}
}
}
Metadata
Assignees
Labels
No labels