Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FromStringShapeDeserializer } from "@smithy/core/protocols";
import { NormalizedSchema } from "@smithy/core/schema";
import { getValueFromTextNode } from "@smithy/smithy-client";
import { Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
import type { Schema, SerdeFunctions, ShapeDeserializer } from "@smithy/types";
import { toUtf8 } from "@smithy/util-utf8";
import { XMLParser } from "fast-xml-parser";

import { SerdeContextConfig } from "../ConfigurableSerdeContext";
import { XmlSettings } from "./XmlCodec";
import type { XmlSettings } from "./XmlCodec";

/**
* @alpha
Expand Down Expand Up @@ -59,11 +59,10 @@ export class XmlShapeDeserializer extends SerdeContextConfig implements ShapeDes
public readSchema(_schema: Schema, value: any): any {
const ns = NormalizedSchema.of(_schema);
const traits = ns.getMergedTraits();
const schema = ns.getSchema();

if (ns.isListSchema() && !Array.isArray(value)) {
// single item in what should have been a list.
return this.readSchema(schema, [value]);
return this.readSchema(ns, [value]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the change: pass NormalizedSchema instead of a raw schema object to the recursive call.

Passing a raw Schema loses the member context.

}

if (value == null) {
Expand Down Expand Up @@ -132,17 +131,17 @@ export class XmlShapeDeserializer extends SerdeContextConfig implements ShapeDes
}

throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${ns.getName(true)}`);
} else {
// non-object aggregate type.
if (ns.isListSchema()) {
return [];
} else if (ns.isMapSchema() || ns.isStructSchema()) {
return {} as any;
}

// simple
return this.stringDeserializer.read(ns, value as string);
}
// non-object aggregate type.
if (ns.isListSchema()) {
return [];
}
if (ns.isMapSchema() || ns.isStructSchema()) {
return {} as any;
}

// simple
return this.stringDeserializer.read(ns, value as string);
}

protected parseXml(xml: string): any {
Expand Down
Loading