Generate int64 types as integer instead of string in OpenAPI schema #459
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Bug
Protobuf int64, sint64, uint64, sfixed64, and fixed64 types were incorrectly being generated as string type in OpenAPI schemas. OpenAPI specification supports int64 as integer type with format specifier, so this change moves 64-bit integer types from string generation to integer generation with appropriate format.
This appears to have been a regression between version v0.6.9 and v0.7.0 of the protoc-gen-openapi generator.
The current code only treats 32 bit integer types as an integer but 64 bit integers as a raw string, this is against the openapi v2 and v3 spec. See the Data Types sections for both versions
https://swagger.io/specification/v2/
https://swagger.io/specification/v3/
This bug results in incorrectly generated openapi files where int64s are written into the specs as being raw strings. This has the the downstream effect of any generated client will treat the integers as string values and require special parsing by the user of the client to parse the long value out of the string.
Examples of the correct values are in the fixture but here is a snippet of what the change in the generate schema looks like for int64:
Fixes #411