Skip to content

refactor(dart): align enum description field name with the DefaultCodegen - #24506

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
Mattias-Sehlstedt:align-dart-enum-description
Jul 29, 2026
Merged

refactor(dart): align enum description field name with the DefaultCodegen#24506
wing328 merged 1 commit into
OpenAPITools:masterfrom
Mattias-Sehlstedt:align-dart-enum-description

Conversation

@Mattias-Sehlstedt

@Mattias-Sehlstedt Mattias-Sehlstedt commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This changes how enum descriptions are handled in Dart, and aligns the behavior with the DefaultCodegen.

The behavioral change is that we look for enumDescription rather than description in allowableValues -> enumVars. This can unexpectedly affect a consumer that redefines the template, since now the codegen will expose enumDescription rather than description. The fallback is the update the local template to also use enumDescription.

The change from description to enumDescription also ensures that the enum's own description is not leaked to each enum item. This occurs now when the enum items do not have a description themselves, which in turn makes the mustache parses look further up the tree for a value (and thus find the CodegenModel's description). An enum like the one below is an example that would leak the description.

components:
  schemas:
    Order:
      status:
        type: string
        description: Order Status
        enum:
          - placed
          - approved
          - delivered

I have instead aligned all Dart enum classes so that they place the schema description once on the class itself instead. This behavior already exists on some enums.

The interpretation of the vendor extension x-enum-values have also been extracted to the EnumUtils since it is a format that comes from Bungie, and it might be of interest to use in other Codegens too. See for example #1486.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Dart commitee:
@jaumard (2018/09) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)


Summary by cubic

Aligns Dart enum descriptions with DefaultCodegen: enum items now expose enumDescription, and the schema description is emitted once on the enum type. Standardizes Bungie x-enum-values handling and updates templates, tests, and samples.

  • Refactors

    • Update built_value and json_serializable templates (inline and non-inline) to read enumDescription for item docs and render the enum’s description once at the type.
    • Centralize x-enum-values parsing in EnumUtils (BUNGIE_X_ENUM_VALUES, getBungieEnumValues) and use it in AbstractDartCodegen; tests and samples updated to expect enumDescription.
  • Migration

    • If you customized Dart enum templates, replace enum item description with enumDescription.

Written for commit 38796f6. Summary will update on new commits.

Review in cubic

@Mattias-Sehlstedt
Mattias-Sehlstedt force-pushed the align-dart-enum-description branch from c76725c to 0dfcbea Compare July 28, 2026 09:05
@Mattias-Sehlstedt Mattias-Sehlstedt changed the title refactor: align dart enum description field name with the DefaultCodegen refactor(dart): align enum description field name with the DefaultCodegen Jul 28, 2026
@Mattias-Sehlstedt
Mattias-Sehlstedt force-pushed the align-dart-enum-description branch from 0dfcbea to a764872 Compare July 28, 2026 09:25
@Mattias-Sehlstedt
Mattias-Sehlstedt marked this pull request as ready for review July 28, 2026 09:50

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 27 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Mattias-Sehlstedt
Mattias-Sehlstedt force-pushed the align-dart-enum-description branch from a764872 to c83802e Compare July 28, 2026 10:18
@Mattias-Sehlstedt
Mattias-Sehlstedt force-pushed the align-dart-enum-description branch from c83802e to 38796f6 Compare July 28, 2026 11:09
@wing328
wing328 merged commit 4d19e0f into OpenAPITools:master Jul 29, 2026
27 checks passed
@wing328 wing328 added this to the 7.25.0 milestone Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants