← Back to Pull requests

fix(typescript-fetch): convert models inside nested arrays and maps #25672

Open
unknown opened this pull request with 427 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 14, 2026 10:37 UTC
Author

Core marks a container whose items are containers again as primitive (Array/Map base type is language primitive), so model template copies such property as is. For map of arrays of models (this issue), and same for array of arrays, array of maps and map of maps, FromJSON returns raw json: nested Date stays string, and ToJSON does not drop readOnly fields

TypeScriptFetchClientCodegen now builds conversion for such properties when innermost items are models and puts it into x-nestedFromJson / x-nestedToJson, e.g. mapValues(json['x'], (v0: any) => (v0 as Array<any>).map(BarFromJSON)). Template uses them with same null/undefined gaurds as existing array branch. Nested containers of primitives, enums, free-form objects or with uniqueItems keep current output

Added test in TypeScriptFetchClientCodegenTest for all four shapes, it fails on master. Sample changes: ArrayTest.arrayArrayOfModel in 3 typescript-fetch builds (default-v3.0, kebab-case, snakecase-discriminator), other 90 typescript configs unchanged. Typescript tests pass. Generated client for the test spec passes tsc --strict, ran it under node: nested when is Date after FromJSON and ISO string after ToJSON

Fixes #21730

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

    <!-- This is an auto-generated description by cubic. -->
    ---

    Summary by cubic


    Fixes #21730 by generating explicit FromJSON/ToJSON conversions for models nested inside arrays and maps in the typescript-fetch client.

    Previously, nested containers of models were copied as-is, so FromJSON returned raw JSON (e.g. Date values stayed strings) and ToJSON kept readOnly fields. Now the generator detects when the innermost items are models and emits level-by-level conversion using map and mapValues, preserving null/undefined inner containers along the way. Nested containers of primitives, enums, free-form objects, or with uniqueItems keep the current output.

    <sup>Written for commit 207ff8abba5ba7856bd06a23e2f7612cb16f0a5e. Summary will update on new commits.</sup>

    <a href="https://cubic.dev/pr/OpenAPITools/openapi-generator/pull/25672?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>

    <!-- End of auto-generated description by cubic. -->

    Diff: 427 lines (+320 / -107) across 5 files Reviewer: thekhegay Review duration: 122m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 427 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.363
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #25672"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.1% (MEDIUM) · Higher = larger blast radius
    45.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24% · Safe to merge
    24%