Skip to content

[typescript-fetch] Fix Omit generic using baseName for readOnly fields in API requests#24276

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
KannaKim:issue-19572
Jul 12, 2026
Merged

[typescript-fetch] Fix Omit generic using baseName for readOnly fields in API requests#24276
wing328 merged 1 commit into
OpenAPITools:masterfrom
KannaKim:issue-19572

Conversation

@KannaKim

@KannaKim KannaKim commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #19572

Description

Context: In the typescript-fetch generator, the generated Omit generic in API request interfaces was incorrectly using the baseName (e.g., created_at) instead of the generated TypeScript property name for readOnly fields (e.g., createdAt).

Because ToJSON safely strips out readOnly fields at runtime anyway, this bug did not break the actual JSON payloads sent to the backend. However, it caused TypeScript typing errors because the readOnly properties were incorrectly left exposed in the TypeScript request interfaces.

(FYI: A similar fix was recently merged in #24275 for modelGeneric.mustache. This PR applies the same fix to apis.mustache to complete the resolution for issue #19572).

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 #19572 by using camelCase TypeScript property names in Omit for readOnly fields in typescript-fetch API request interfaces. This prevents typing errors; runtime payloads are unchanged.

  • Bug Fixes
    • Use 'name' instead of 'baseName' when building Omit for readOnly props in apis.mustache.
    • Added test and sample spec to ensure camelCase fields (e.g., createdAt, updatedAt) are used in generated request types.

Written for commit 89622d6. 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.

No issues found across 3 files

Re-trigger cubic

@wing328 wing328 merged commit 1fc1ed1 into OpenAPITools:master Jul 12, 2026
15 checks passed
@wing328 wing328 added this to the 7.24.0 milestone Jul 12, 2026
@KannaKim KannaKim deleted the issue-19572 branch July 12, 2026 16:49
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] Api has parameter naming discrepency between generated models and API

2 participants