From 4a81be8ab932a9db765bfe52be0fa74f74be8d5c Mon Sep 17 00:00:00 2001 From: Rikki Gibson Date: Tue, 27 Mar 2018 15:33:10 -0700 Subject: [PATCH] Handle empty list cases --- lib/serializer.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/serializer.ts b/lib/serializer.ts index 4012ad8..7c34423 100644 --- a/lib/serializer.ts +++ b/lib/serializer.ts @@ -434,7 +434,8 @@ export class Serializer { name: "Composite" } }; - if (responseBody !== null && responseBody !== undefined) { + responseBody = responseBody || {}; + if (responseBody) { let modelProps = mapper.type.modelProperties; if (!modelProps) { if (!mapper.type.className) { @@ -461,7 +462,7 @@ export class Serializer { } if (this.isXML) { - if (propertyMapper.xmlIsAttribute) { + if (propertyMapper.xmlIsAttribute && responseBody.attributes) { instance[key] = this.deserialize(propertyMapper, responseBody.attributes[propertyMapper.xmlName!], propertyObjectName); } else { const propertyName = propertyMapper.xmlElementName || propertyMapper.xmlName;