OpenAPITools / OpenAPITools/openapi-generator

[dart-dio] Support `BigInt` for `"type":"string", "format":"int64"` in Dart generator

Open
#21,473 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
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.

Currently any OpenAPI schema property declared as:

"id": {
  "example": "1",
  "format": "int64",
  "type": "string"
}

is generated as a Dart String. This forces users to manually parse large integers themselves, even though Dart has built-in BigInt support and json_serializable can already handle BigInt encoding/decoding.

Describe the solution you’d like

Enhance the Dart generator so that fields with "type": "string", "format": "int64" map to Dart BigInt.

  • In models: generate BigInt typed fields.
  • In (de)serialization: use BigInt.parse(...) and .toString().
  • Optionally expose a generator flag to fall back to String if desired.
Describe alternatives you’ve considered
  • Post-generation script to replace all String with BigInt and insert manual (de)serialization logic.
  • Manually converting in app code after receiving responses.
Additional context

The json_serializable package already supports BigInt via custom converters. Automating this in the generator would save repeated boilerplate and reduce runtime errors when handling very large 64-bit IDs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the dart-dio generator's type-mapping and model serialization entry points, then inspect how string/int64 schemas are handled. Verify the generated model fields and deserialization/serialization behavior for the example schema; done means those fields use BigInt with the requested conversions, while any fallback option is clearly defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.