Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Core marks a container whose items are containers again as primitive (
Array/Mapbase 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,FromJSONreturns raw json: nestedDatestays string, andToJSONdoes not drop readOnly fieldsTypeScriptFetchClientCodegennow builds conversion for such properties when innermost items are models and puts it intox-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 outputAdded test in
TypeScriptFetchClientCodegenTestfor all four shapes, it fails on master. Sample changes:ArrayTest.arrayArrayOfModelin 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 passestsc --strict, ran it under node: nestedwhenisDateafterFromJSONand ISO string afterToJSONFixes #21730
PR checklist
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
Summary by cubic
Fixes #21730 by generating explicit
FromJSON/ToJSONconversions for models nested inside arrays and maps in thetypescript-fetchclient.Previously, nested containers of models were copied as-is, so
FromJSONreturned raw JSON (e.g.Datevalues stayed strings) andToJSONkept readOnly fields. Now the generator detects when the innermost items are models and emits level-by-level conversion usingmapandmapValues, preserving null/undefined inner containers along the way. Nested containers of primitives, enums, free-form objects, or withuniqueItemskeep the current output.Written for commit 207ff8a. Summary will update on new commits.