OpenAPITools / OpenAPITools/openapi-generator
[BUG] [dart-dio] Enum properties with "default" values create compile errors
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
For a schema that has an Enum property with a "default" value, the generated result has compile errors. This does not happen with string properties that have default values.
Minimal api.json:
https://gist.github.com/mrohlof-protofy/f35cab420710d1ce696c28a584285099
Call:
openapi-generator generate -g dart-dio -i api.json -o ./
dart run build_runner build --delete-conflicting-outputs
Result:
...
27 | static void _defaults(MyActionBuilder b) => b
28 | ..executionMode = const ._(ExecutionMode.INSTANT);
...
Issue:
my_action.dart:28:31: Expected an identifier.
Expected Result:
...
27 | static void _defaults(MyActionBuilder b) => b
28 | ..executionMode = ExecutionMode.INSTANT;
...
openapi-generator version
7.10.0
OpenAPI declaration file content or url
Minimal example:
https://gist.github.com/mrohlof-protofy/f35cab420710d1ce696c28a584285099
Generation Details
Steps to reproduce
openapi-generator generate -g dart-dio -i api.json -o ./
dart run build_runner build --delete-conflicting-outputs
Related issues/PRs
Suggest a fix
Defaults
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 running the reported openapi-generator dart-dio command with the linked minimal api.json, then inspect the generated my_action.dart around the enum default assignment. Run dart run build_runner build --delete-conflicting-outputs and verify that enum defaults compile without the invalid ._(...) syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100