|
1 | 1 | import { FromStringShapeDeserializer } from "@smithy/core/protocols";
|
2 | 2 | import { NormalizedSchema } from "@smithy/core/schema";
|
3 | 3 | import { getValueFromTextNode } from "@smithy/smithy-client";
|
4 |
| -import { Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types"; |
| 4 | +import type { Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types"; |
5 | 5 | import { toUtf8 } from "@smithy/util-utf8";
|
6 | 6 | import { XMLParser } from "fast-xml-parser";
|
7 | 7 |
|
8 | 8 | import { SerdeContextConfig } from "../ConfigurableSerdeContext";
|
9 |
| -import { XmlSettings } from "./XmlCodec"; |
| 9 | +import type { XmlSettings } from "./XmlCodec"; |
10 | 10 |
|
11 | 11 | /**
|
12 | 12 | * @alpha
|
@@ -59,11 +59,10 @@ export class XmlShapeDeserializer extends SerdeContextConfig implements ShapeDes
|
59 | 59 | public readSchema(_schema: Schema, value: any): any {
|
60 | 60 | const ns = NormalizedSchema.of(_schema);
|
61 | 61 | const traits = ns.getMergedTraits();
|
62 |
| - const schema = ns.getSchema(); |
63 | 62 |
|
64 | 63 | if (ns.isListSchema() && !Array.isArray(value)) {
|
65 | 64 | // single item in what should have been a list.
|
66 |
| - return this.readSchema(schema, [value]); |
| 65 | + return this.readSchema(ns, [value]); |
67 | 66 | }
|
68 | 67 |
|
69 | 68 | if (value == null) {
|
@@ -132,17 +131,17 @@ export class XmlShapeDeserializer extends SerdeContextConfig implements ShapeDes
|
132 | 131 | }
|
133 | 132 |
|
134 | 133 | 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); |
145 | 134 | }
|
| 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); |
146 | 145 | }
|
147 | 146 |
|
148 | 147 | protected parseXml(xml: string): any {
|
|
0 commit comments