Skip to content

Commit 7061230

Browse files
authored
chore(core/protocols): fix for XML shape deser (#7160)
* chore(core/protocols): fix for XML shape deser * chore: unused import
1 parent 8a37039 commit 7061230

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

packages/core/src/submodules/protocols/xml/XmlShapeDeserializer.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { FromStringShapeDeserializer } from "@smithy/core/protocols";
22
import { NormalizedSchema } from "@smithy/core/schema";
33
import { getValueFromTextNode } from "@smithy/smithy-client";
4-
import { Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
4+
import type { Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
55
import { toUtf8 } from "@smithy/util-utf8";
66
import { XMLParser } from "fast-xml-parser";
77

88
import { SerdeContextConfig } from "../ConfigurableSerdeContext";
9-
import { XmlSettings } from "./XmlCodec";
9+
import type { XmlSettings } from "./XmlCodec";
1010

1111
/**
1212
* @alpha
@@ -59,11 +59,10 @@ export class XmlShapeDeserializer extends SerdeContextConfig implements ShapeDes
5959
public readSchema(_schema: Schema, value: any): any {
6060
const ns = NormalizedSchema.of(_schema);
6161
const traits = ns.getMergedTraits();
62-
const schema = ns.getSchema();
6362

6463
if (ns.isListSchema() && !Array.isArray(value)) {
6564
// single item in what should have been a list.
66-
return this.readSchema(schema, [value]);
65+
return this.readSchema(ns, [value]);
6766
}
6867

6968
if (value == null) {
@@ -132,17 +131,17 @@ export class XmlShapeDeserializer extends SerdeContextConfig implements ShapeDes
132131
}
133132

134133
throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
135-
} else {
136-
// non-object aggregate type.
137-
if (ns.isListSchema()) {
138-
return [];
139-
} else if (ns.isMapSchema() || ns.isStructSchema()) {
140-
return {} as any;
141-
}
142-
143-
// simple
144-
return this.stringDeserializer.read(ns, value as string);
145134
}
135+
// non-object aggregate type.
136+
if (ns.isListSchema()) {
137+
return [];
138+
}
139+
if (ns.isMapSchema() || ns.isStructSchema()) {
140+
return {} as any;
141+
}
142+
143+
// simple
144+
return this.stringDeserializer.read(ns, value as string);
146145
}
147146

148147
protected parseXml(xml: string): any {

0 commit comments

Comments
 (0)