Skip to content

Commit

Permalink
Translate int64 and unit64 to integer type in swagger.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Aug 24, 2016
1 parent 2a6b75c commit f7d82dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions protoc-gen-swagger/genswagger/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,19 @@ func primitiveSchema(t pbdescriptor.FieldDescriptorProto_Type) (ftype, format st
case pbdescriptor.FieldDescriptorProto_TYPE_FLOAT:
return "number", "float", true
case pbdescriptor.FieldDescriptorProto_TYPE_INT64:
return "string", "int64", true
return "integer", "int64", true

This comment has been minimized.

Copy link
@achew22

achew22 Oct 4, 2016

Doing this might not lead to the results you want/expect. I wrote up the reasons why on the issue you commented on in grpc-ecosystem#219

case pbdescriptor.FieldDescriptorProto_TYPE_UINT64:
// 64bit integer types are marshaled as string in the default JSONPb marshaler.
// TODO(yugui) Add an option to declare 64bit integers as int64.
//
// NOTE: uint64 is not a predefined format of integer type in Swagger spec.
// So we cannot expect that uint64 is commonly supported by swagger processor.
return "string", "uint64", true
return "integer", "uint64", true
case pbdescriptor.FieldDescriptorProto_TYPE_INT32:
return "integer", "int32", true
case pbdescriptor.FieldDescriptorProto_TYPE_FIXED64:
// Ditto.
return "string", "uint64", true
return "integer", "uint64", true
case pbdescriptor.FieldDescriptorProto_TYPE_FIXED32:
// Ditto.
return "integer", "int64", true
Expand All @@ -174,11 +174,11 @@ func primitiveSchema(t pbdescriptor.FieldDescriptorProto_Type) (ftype, format st
case pbdescriptor.FieldDescriptorProto_TYPE_SFIXED32:
return "integer", "int32", true
case pbdescriptor.FieldDescriptorProto_TYPE_SFIXED64:
return "string", "int64", true
return "integer", "int64", true
case pbdescriptor.FieldDescriptorProto_TYPE_SINT32:
return "integer", "int32", true
case pbdescriptor.FieldDescriptorProto_TYPE_SINT64:
return "string", "int64", true
return "integer", "int64", true
default:
return "", "", false
}
Expand Down

0 comments on commit f7d82dd

Please sign in to comment.