Skip to content

fix(typescript-fetch): convert model items of array alias models - #25822

Merged
macjohnny merged 1 commit into
OpenAPITools:masterfrom
thekhegay:typescript-fetch-alias-array-models
Nov 25, 2026
Merged

macjohnny merged 1 commit into
OpenAPITools:masterfrom
thekhegay:typescript-fetch-alias-array-models

Conversation

@thekhegay

@thekhegay thekhegay commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

With generateAliasAsModel array alias model (CarList = Array<Car>) has no vars, so CarListFromJSONTyped and CarListToJSONTyped just return json and items are not converted, Date fields of Car stay strings. API methods and properties that use CarList go through these functions too

Now for array alias with model items both functions map items through CarFromJSON / CarToJSON, same expression as for array properties. Arrays of primitives and map aliases stay as before. Checked generated client with tsc 6 --strict and at runtime: builtAt becomes Date, null passes through. Added test in TypeScriptFetchClientCodegenTest, no typescript-fetch config uses generateAliasAsModel so samples dont change

Fixes #17533

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
    
    Commit all changed files.
  • 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 @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim


Summary by cubic

Fixes #17533: with generateAliasAsModel enabled, array alias models like CarList = Array<Car> now convert their model items in FromJSONTyped/ToJSONTyped, so Date fields are properly parsed instead of remaining strings.

  • Generated functions map items through the item model's FromJSON/ToJSON.
  • Primitive and map aliases still return the value unchanged.
  • Added a regression test using a minimal spec.

Written for commit 47fb866. 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.

All reported issues were addressed across 3 files

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

View guided diff | Re-trigger cubic

@macjohnny macjohnny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for your contribution

@macjohnny
macjohnny merged commit 32ec7f5 into OpenAPITools:master Nov 25, 2026
15 checks passed
@thekhegay
thekhegay deleted the typescript-fetch-alias-array-models branch November 26, 2026 03:50
@wing328 wing328 added this to the 7.28.0 milestone Nov 26, 2026
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] Missing type mappers if generateAliasAsModel is set to true

3 participants