OpenAPITools / OpenAPITools/openapi-generator
[BUG] uint64 maximum 1.844...e+19 is parsed as 384 (truncation error)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Large integers in the OpenAPI specification are not read in correctly.
I am generating a client from a spec that specifies the uint64 maximum 1.8446744073709552e+19, but the value is parsed as 384.
openapi-generator version
5.4.0
OpenAPI declaration file content or url
Just add the size property to petstore.yaml, so it looks like this:
[...]
status:
type: string
description: pet status in the store
deprecated: true
enum:
- available
- pending
- sold
size:
description: in bytes
maximum: 1.8446744073709552e+19
minimum: 0
type: integer
xml:
name: Pet
ApiResponse:
title: An uploaded response
[...]
Generation Details
openapi-generator-cli generate -i petstore.yaml -g python
Steps to reproduce
The steps above produce this code:
validations = {
('size',): {
'inclusive_maximum': 384,
'inclusive_minimum': 0,
},
}
inclusive_maximum should be 1.8446744073709552e+19 instead.
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/10620 is very similar.
Suggest a fix
I don't know where it happens, but it is clearly a truncation error. For 1.844e+19, the generated code is 'inclusive_maximum': -6744073709551616,.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the petstore.yaml reproduction and run openapi-generator-cli generate -i petstore.yaml -g python. Trace how the maximum value reaches the generated Python validations dictionary, comparing the expected uint64 maximum with the truncated output. Done means the generated value is preserved correctly and the regression is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100