Skip to content

fix(typescript-fetch): map-of-arrays responses and multipart arrays of models - #10

Merged
xseman merged 3 commits into
masterfrom
fix/ts-fetch-map-array-multipart-json
Oct 6, 2026
Merged

xseman merged 3 commits into
masterfrom
fix/ts-fetch-map-array-multipart-json

Conversation

@xseman

@xseman xseman commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Two typescript-fetch fixes, one commit each.

Map of arrays response ({ [key: string]: Array<X>; }). It rendered mapValues(jsonValue, Array&lt;X&gt;FromJSON) and imported a non-existent ArrayX.

  • Cause: the map's base type is the string Array<X>.
  • Fix: the parser now fills returnProperty, so the template emits (items) => items.map(XFromJSON) and imports X.

Multipart array of models. It was csv-joined into "[object Object],…".

  • Fix: it now goes as one JSON Blob part of value.map(XToJSON), like a single model part.
  • Unchanged: arrays of files, primitives, enum $refs and primitive aliases.

Tests

  • New parser and render tests fail without the fix.
  • make test passes and make lint reports 0 issues.
  • Regenerating the ssd client differs only in getStreets and storePhotos. Strict tsc passes, and the consumer's 763 tests pass.

Not fixed here (also broken on master): multipart without a file field uses URLSearchParams, so a JSON part arrives as "[object Blob]".

xseman added 2 commits October 6, 2026 15:58
A response typed { [key: string]: Array<X>; } rendered
runtime.mapValues(jsonValue, Array&lt;X&gt;FromJSON) and imported a
non-existent ArrayX, because the map's base type is the value type
"Array<X>". The parser now fills returnProperty (the Java field) so the
template maps each value with (items) => items.map(XFromJSON), imports X,
and passes maps of primitive or nested-container arrays through unmapped.
ReturnBaseType is unchanged: dart-fetch's map cast relies on it.
An array-of-model form field was csv-joined into "[object Object],…".
It now goes as one application/json Blob of value.map(XToJSON), like a
single model part already does (plain value under withoutRuntimeChecks,
Array.from for uniqueItems). Arrays of files keep one append per file;
arrays of primitives and of $ref to an enum or primitive schema stay csv.
@xseman xseman self-assigned this Oct 6, 2026
@xseman
xseman merged commit 300e307 into master Oct 6, 2026
3 checks passed
@xseman
xseman deleted the fix/ts-fetch-map-array-multipart-json branch October 25, 2026 16:09
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.

1 participant