Skip to content

Commit

Permalink
[typescript-fetch] Fixed issue where unique arrays (sets) of primitiv…
Browse files Browse the repository at this point in the history
…e values aren't initialized properly (#19521)

* Fix for #19520

* Removed redundant Array<any> cast

* Fixed modelGeneric.mustache

* Updated samples
  • Loading branch information
davidomid authored Sep 5, 2024
1 parent 2f54a2f commit 2bc0e5f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
{{/additionalPropertiesType}}
{{#vars}}
{{#isPrimitiveType}}
{{#isArray}}
{{#uniqueItems}}
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}{{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}new Set(json['{{baseName}}']),
{{/uniqueItems}}
{{^uniqueItems}}
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}{{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}json['{{baseName}}'],
{{/uniqueItems}}
{{/isArray}}
{{^isArray}}
{{#isDateType}}
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])),
{{/isDateType}}
Expand All @@ -66,6 +75,7 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
'{{name}}': {{^required}}json['{{baseName}}'] == null ? undefined : {{/required}}json['{{baseName}}'],
{{/isDateTimeType}}
{{/isDateType}}
{{/isArray}}
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isArray}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet {
'id': json['id'] == null ? undefined : json['id'],
'category': json['category'] == null ? undefined : CategoryFromJSON(json['category']),
'name': json['name'],
'photoUrls': json['photoUrls'],
'photoUrls': new Set(json['photoUrls']),
'tags': json['tags'] == null ? undefined : ((json['tags'] as Array<any>).map(TagFromJSON)),
'status': json['status'] == null ? undefined : json['status'],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet {
'id': json['id'] == null ? undefined : json['id'],
'category': json['category'] == null ? undefined : CategoryFromJSON(json['category']),
'name': json['name'],
'photoUrls': json['photoUrls'],
'photoUrls': new Set(json['photoUrls']),
'tags': json['tags'] == null ? undefined : ((json['tags'] as Array<any>).map(TagFromJSON)),
'status': json['status'] == null ? undefined : json['status'],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function PetFromJSONTyped(json: any, ignoreDiscriminator: boolean): Pet {
'id': json['id'] == null ? undefined : json['id'],
'category': json['category'] == null ? undefined : CategoryFromJSON(json['category']),
'name': json['name'],
'photoUrls': json['photoUrls'],
'photoUrls': new Set(json['photoUrls']),
'tags': json['tags'] == null ? undefined : ((json['tags'] as Array<any>).map(TagFromJSON)),
'status': json['status'] == null ? undefined : json['status'],
};
Expand Down

0 comments on commit 2bc0e5f

Please sign in to comment.