Skip to content

Conversation

ajorgensen
Copy link

@ajorgensen ajorgensen commented Sep 26, 2025

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/

Screenshot 2025-09-26 at 11 10 36 AM

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:

 - name: int64_value_type
   in: query
   schema:
-    type: string
+    type: integer
+    format: int64

Fixes #411

…emas

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.
@ajorgensen ajorgensen requested a review from a team as a code owner September 26, 2025 15:52
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.

protoc-gen-openapi BUG

1 participant