diff --git a/docs/source/spec/xml.rst b/docs/source/spec/xml.rst index 856ab02ac23..a00df557ef1 100644 --- a/docs/source/spec/xml.rst +++ b/docs/source/spec/xml.rst @@ -98,7 +98,7 @@ Summary Moves serialized collection members from their collection element to that of the collection's container. Trait selector - ``collection`` + ``:test(collection, member:of(structure) > collection)`` *Any list or set* Value type diff --git a/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude-traits.smithy b/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude-traits.smithy index 1252fd14e99..96a34fb0819 100644 --- a/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude-traits.smithy +++ b/smithy-model/src/main/resources/software/amazon/smithy/model/loader/prelude-traits.smithy @@ -148,7 +148,7 @@ structure xmlAttribute {} /// Moves serialized collection members from their collection element to that of /// the collection's container. -@trait(selector: "collection") +@trait(selector: ":test(collection, member:of(structure) > collection)") @tags(["diff.error.const"]) structure xmlFlattened {} diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/xml-flattened.errors b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/xml-flattened.errors new file mode 100644 index 00000000000..e69de29bb2d diff --git a/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/xml-flattened.json b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/xml-flattened.json new file mode 100644 index 00000000000..85bb0871548 --- /dev/null +++ b/smithy-model/src/test/resources/software/amazon/smithy/model/errorfiles/validators/xml-flattened.json @@ -0,0 +1,37 @@ +{ + "smithy": "0.4.0", + "ns.foo": { + "shapes": { + "FlatCollection": { + "type": "list", + "member": { + "target": "smithy.api#String" + }, + "smithy.api#xmlFlattened": true + }, + "NotFlatCollection": { + "type": "list", + "member": { + "target": "smithy.api#String" + } + }, + "ValidStructure1": { + "type": "structure", + "members": { + "flatList": { + "target": "FlatCollection" + } + } + }, + "ValidStructure2": { + "type": "structure", + "members": { + "flatList": { + "target": "NotFlatCollection", + "smithy.api#xmlFlattened": true + } + } + } + } + } +} \ No newline at end of file