Skip to content

[typescript-fetch] Fix Omit generic using baseName for readOnly fields#24275

Merged
wing328 merged 2 commits into
OpenAPITools:masterfrom
KannaKim:issue-23380
Jul 12, 2026
Merged

[typescript-fetch] Fix Omit generic using baseName for readOnly fields#24275
wing328 merged 2 commits into
OpenAPITools:masterfrom
KannaKim:issue-23380

Conversation

@KannaKim

@KannaKim KannaKim commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #23380

When generating the Omit<...> utility type for readOnly fields in models, the typescript-fetch generator incorrectly used baseName instead of name. This resulted in invalid TypeScript compiler errors when the model property naming strategy diverged from the raw OpenAPI property name (e.g. single_car in the spec vs singleCar in the generated interface).

This commit fixes modelGeneric.mustache to properly use the generated property name ({{name}}) instead of {{baseName}} for read-only fields, and adds test coverage to ensure the fix is maintained.

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.
    @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) @joscha (2024/10)

Summary by cubic

Fixes #23380. The typescript-fetch generator now uses generated property names in the Omit<...> for readOnly fields, preventing TypeScript errors when spec names differ from interface names.

  • Bug Fixes
    • Use {{name}} instead of {{baseName}} when building Omit<...> for read-only properties in modelGeneric.mustache.
    • Add a test (issue_23380.yaml) to verify camelCase names are used in Omit, and update petstore samples accordingly.

Written for commit 63f0d9c. Summary will update on new commits.

Review in cubic

KannaKim added 2 commits July 11, 2026 22:28
Fixes OpenAPITools#23380

When generating the `Omit<...>` utility type for readOnly fields in models, the typescript-fetch generator incorrectly used `baseName` instead of `name`. This resulted in invalid TypeScript compiler errors when the model property naming strategy diverged from the raw OpenAPI property name (e.g. `single_car` in the spec vs `singleCar` in the generated interface).

This commit fixes `modelGeneric.mustache` to properly use the generated property name (`{{name}}`) instead of `{{baseName}}` for read-only fields, and adds test coverage to ensure the fix is maintained.

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

Re-trigger cubic

@wing328

wing328 commented Jul 12, 2026

Copy link
Copy Markdown
Member

lgtm. thanks for the fix

@wing328 wing328 merged commit dd2afd5 into OpenAPITools:master Jul 12, 2026
16 checks passed
@wing328 wing328 added this to the 7.24.0 milestone Jul 12, 2026
@KannaKim KannaKim deleted the issue-23380 branch July 12, 2026 15:51
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] Omitted fields are incorrectly set in snake-case

2 participants