Skip to content

refactor: simplify discriminatorFound logic and move it to the DiscriminatorUtils#24199

Open
Mattias-Sehlstedt wants to merge 1 commit into
OpenAPITools:masterfrom
Mattias-Sehlstedt:move-discriminator-found-to-utils
Open

refactor: simplify discriminatorFound logic and move it to the DiscriminatorUtils#24199
Mattias-Sehlstedt wants to merge 1 commit into
OpenAPITools:masterfrom
Mattias-Sehlstedt:move-discriminator-found-to-utils

Conversation

@Mattias-Sehlstedt

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

Copy link
Copy Markdown
Contributor

This PR simplifies the logic in the discriminatorFound method within class DefaultCodegen. It also moves the method to DiscriminatorUtils in order to reduce the overall size of DefaultCodegen and to centralize discriminator introspection into a single place.

Protected method getDiscriminatorSchema has also been removed from DefaultCodegen and made private in DiscriminatorUtils. This is technically a breaking change, but I would argue that it can be safely ignored since the method was very recently introduced by me. Its presence also no longer serves any purpose since it cannot act as a extension point for anything with the moving of discriminatorFound.

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.

Summary by cubic

Simplified discriminator detection and moved it from DefaultCodegen to DiscriminatorUtils to centralize logic and reduce DefaultCodegen size. No functional changes expected for generators.

  • Refactors

    • Moved and simplified discriminatorFound into DiscriminatorUtils as discriminatorFound(OpenAPI, ...) and updated call sites in DefaultCodegen.
    • Removed DefaultCodegen#getDiscriminatorSchema; equivalent logic now lives as a private helper in DiscriminatorUtils.
  • Migration

    • If you extended DefaultCodegen and used getDiscriminatorSchema, switch to DiscriminatorUtils.discriminatorFound(...) or DiscriminatorUtils.getDiscriminatorPropertyType(...) as needed.

Written for commit ce50154. Summary will update on new commits.

Review in cubic

@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.

1 issue found across 2 files

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

Re-trigger cubic

@Mattias-Sehlstedt Mattias-Sehlstedt force-pushed the move-discriminator-found-to-utils branch from 37b3ffa to ce50154 Compare July 4, 2026 12:48

@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.

No issues found across 2 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant