Skip to content

fix(typescript-fetch): support non-default file names#24006

Draft
celluj34 wants to merge 8 commits into
OpenAPITools:masterfrom
celluj34:jgc/fix-api-imports
Draft

fix(typescript-fetch): support non-default file names#24006
celluj34 wants to merge 8 commits into
OpenAPITools:masterfrom
celluj34:jgc/fix-api-imports

Conversation

@celluj34

@celluj34 celluj34 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

files generated with non-default (e.g. "fileNaming": "kebab-case") have their import path set with the default file name. this PR fixes the non-barrel imports by using the parsed file name instead of simply the class name.

(fixes #23840)

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

Fixes broken model imports in the typescript-fetch generator when fileNaming is non-default (e.g., kebab-case). API files now import models using the actual generated file name instead of the class name.

  • Bug Fixes
    • Generate and use classFileName (via convertUsingFileNamingConvention) for model import paths in apis.mustache and sagas.mustache to support non-default fileNaming.
    • Added a test in TypeScriptFetchClientCodegenTest to assert kebab-case imports (e.g., ../models/pet not ../models/Pet) and set WITHOUT_RUNTIME_CHECKS to false to exercise imports.
    • Added bin/configs/typescript-fetch-kebab-case.yaml and regenerated samples under samples/client/petstore/typescript-fetch/builds/kebab-case for coverage.

Written for commit 80e5496. Summary will update on new commits.

Review in 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.

[BUG][typescript-fetch] api model imports not using correct filename

1 participant