OpenAPITools / OpenAPITools/openapi-generator
[REQ] [dart-dio] Proper support for 64bit integers
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
When generating model-files from a spec where the data type is of integer with format int64
this is translated to an int in dart. However, when running dart on the web, it compiles to javascript, which has a 53 bit mantissa for integers. This means that large integers are not handled correctly on web, which can lead to hard to pin down errors if you are trying to use a shared code base on mobile apps and web (which is the case in Flutter).
Describe the solution you'd like
When encountering specs with the int64 format, use 'num' instead of 'int' as data type. Possibly add a feature flag since this could break backwards compatibility.
Describe alternatives you've considered
There are no other ironclad ways of dealing with this unfortunately. Ideally the API I'm working with would stop using int64 for their identifiers, but that is outside of my juristiction right now.
Additional context
EDIT: Unfortunately, since the json.decode calls mangle the large integers on json decoding I can't see a good way of implementing this after all. This fix would have to happen in json.decode itself
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 by tracing how the dart-dio generator maps OpenAPI integer formats, then review Dart web json.decode behavior for large integers. No file or test is named, and the issue notes that the required fix may be outside the generator; done would require an agreed, working approach for preserving int64 values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100