OpenAPITools / OpenAPITools/openapi-generator

[dart-dio][client] Unusable Enums Produced

Open
#14,030 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

When generating a dart-dio client, unusable Enums are created.

ImageResolutionEnum resolution = ImageResolutionEnum.number196

The only property of the enum is name which is just a string of the enum name. You'd expect that the value of ImageResolutionEnum.number196 to equal 196, but it instead equals the string 'number196'.

openapi-generator version

2.5.2 via npm install.

OpenAPI declaration file content or url

I can't really share the openapi spec, as it's for my employer and the API hasn't been made public yet.

Command line used for generation

openapi-generator-cli generate -g dart-dio -i $SPEC_FILE -c "conf/dart_client.yaml" -o $path --enable-post-process-file

Steps to reproduce

Generate a client against an OpenApi spec which contains an IntEnum.

Related issues/PRs

Several related, but not quite similar issues have occurred in the past, regarding issues with enums in the dart-dio client generation.

Suggest a fix/enhancement

Enums should return the expected value, not the name of the enum.

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 reproducing the issue with the documented dart-dio generation command and an OpenAPI schema containing an IntEnum. Inspect the generated Dart enum and the dart-dio generator's enum handling to determine why the numeric value becomes a name string. Done means generated enum members expose their declared values, with coverage for this case if the generator has a relevant test location.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.