Skip to content

[typescript] Fix missing model imports for container types in oneOf schemas (#23286) - #25173

Open
cpruijsen wants to merge 1 commit into
OpenAPITools:masterfrom
cpruijsen:fix/issue-23286-e5017ae9
Open

cpruijsen wants to merge 1 commit into
OpenAPITools:masterfrom
cpruijsen:fix/issue-23286-e5017ae9

Conversation

@cpruijsen

@cpruijsen cpruijsen commented Oct 7, 2026 •

Copy link
Copy Markdown

The typescript and typescript-redux-query generators now keep model imports for container branches of oneOf schemas.
For the circular schema in #23286, typescript generated Array<Repro> | string without the necessary Repro import.

Both filters use CodegenProperty.getImports with parsed branch metadata.
The filters keep direct references, remove unused imports, and keep imports sorted.
The substring comparison from the issue can keep an unused Foo import for a FooBar branch.

Fixes #23286.

The regression test in modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/TypeScriptClientCodegenTest.java failed without the changes and passed with them.
The TypeScript package tests passed.

PR checklist

  • Read the contribution guidelines.
  • Run the complete project build, all sample generation, and generator documentation export.
  • Mention the TypeScript technical committee members.

cc @TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim


Summary by cubic

Fixes missing model imports for container types in oneOf schemas in the typescript and typescript-redux-query generators, resolving circular schema generation issues from #23286.

Previously, model imports were kept only when they matched a direct oneOf branch name, so a branch like Array<Repro> lost the Repro import. The filters now resolve imports from each branch's parsed metadata so inner types of container branches retain their imports, while unused imports are still removed and ordering is preserved.

Adds a regression test with a circular oneOf schema (Array<Repro> | string) covering both generators.

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

View guided diff

@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 4 files

View guided diff | Re-trigger cubic

This branch has not been deployed

No deployments
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.

[BUG][typescript] Missing import statements in model with circular oneOf

2 participants