[typescript-fetch] Guard array mapping against undefined on optional array model properties (#2324)

* [typescript-fetch] Guard array mapping against undefined on optional array model properties (#2323)

* [typescript-fetch] Update samples
This commit is contained in:
Lukas S 2019-03-08 16:13:55 +01:00 committed by William Cheng
parent c6a5017a13
commit a797dd668b
5 changed files with 5 additions and 5 deletions

View File

@ -74,7 +74,7 @@ export function {{classname}}ToJSON(value?: {{classname}}): any {
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isContainer}}
'{{baseName}}': (value.{{name}} as Array<any>).map({{#items}}{{datatype}}{{/items}}ToJSON),
'{{baseName}}': {{^required}}value.{{name}} === undefined ? undefined : {{/required}}(value.{{name}} as Array<any>).map({{#items}}{{datatype}}{{/items}}ToJSON),
{{/isContainer}}
{{^isContainer}}
'{{baseName}}': {{datatype}}ToJSON(value.{{name}}),

View File

@ -85,7 +85,7 @@ export function PetToJSON(value?: Pet): any {
'category': CategoryToJSON(value.category),
'name': value.name,
'photoUrls': value.photoUrls,
'tags': (value.tags as Array<any>).map(TagToJSON),
'tags': value.tags === undefined ? undefined : (value.tags as Array<any>).map(TagToJSON),
'status': value.status,
};
}

View File

@ -85,7 +85,7 @@ export function PetToJSON(value?: Pet): any {
'category': CategoryToJSON(value.category),
'name': value.name,
'photoUrls': value.photoUrls,
'tags': (value.tags as Array<any>).map(TagToJSON),
'tags': value.tags === undefined ? undefined : (value.tags as Array<any>).map(TagToJSON),
'status': value.status,
};
}

View File

@ -85,7 +85,7 @@ export function PetToJSON(value?: Pet): any {
'category': CategoryToJSON(value.category),
'name': value.name,
'photoUrls': value.photoUrls,
'tags': (value.tags as Array<any>).map(TagToJSON),
'tags': value.tags === undefined ? undefined : (value.tags as Array<any>).map(TagToJSON),
'status': value.status,
};
}

View File

@ -85,7 +85,7 @@ export function PetToJSON(value?: Pet): any {
'category': CategoryToJSON(value.category),
'name': value.name,
'photoUrls': value.photoUrls,
'tags': (value.tags as Array<any>).map(TagToJSON),
'tags': value.tags === undefined ? undefined : (value.tags as Array<any>).map(TagToJSON),
'status': value.status,
};
}