Skip to content

[BUG] [dart-dio] Enum properties with "default" values create compile errors #20495

@mrohlof-protofy

Description

@mrohlof-protofy

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

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