Skip to content

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

Open
@AndrewDongminYoo

Description

@AndrewDongminYoo

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions