From 8fd6d2a7a1e977c9c5aac149f70841eefbfc2338 Mon Sep 17 00:00:00 2001 From: Antonio Aranda <102337110+arandito@users.noreply.github.com> Date: Fri, 20 Mar 2026 14:31:40 -0400 Subject: [PATCH 1/2] smithy-core: add xml binding traits --- ...ment-80e80edee8a7461d99ca5f28c2547e59.json | 4 ++ .../smithy-core/src/smithy_core/traits.py | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 packages/smithy-core/.changes/next-release/smithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json diff --git a/packages/smithy-core/.changes/next-release/smithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json b/packages/smithy-core/.changes/next-release/smithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json new file mode 100644 index 000000000..36cac6613 --- /dev/null +++ b/packages/smithy-core/.changes/next-release/smithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json @@ -0,0 +1,4 @@ +{ + "type": "enhancement", + "description": "Added XML binding traits: `XMNameTrait`, `XMLNamespaceTrait`, `XMLFlattenedTrait`, and `XMLAttributeTrait`." +} \ No newline at end of file diff --git a/packages/smithy-core/src/smithy_core/traits.py b/packages/smithy-core/src/smithy_core/traits.py index d7dfd22cf..ed8f3702e 100644 --- a/packages/smithy-core/src/smithy_core/traits.py +++ b/packages/smithy-core/src/smithy_core/traits.py @@ -350,3 +350,43 @@ def name(self) -> str: @property def scheme(self) -> str | None: return self.document_value.get("scheme") # type: ignore + + +@dataclass(init=False, frozen=True) +class XMLNameTrait(Trait, id=ShapeID("smithy.api#xmlName")): + document_value: str | None = None + + def __post_init__(self): + assert isinstance(self.document_value, str) + + @property + def value(self) -> str: + return self.document_value # type: ignore + + +@dataclass(init=False, frozen=True) +class XMLNamespaceTrait(Trait, id=ShapeID("smithy.api#xmlNamespace")): + def __post_init__(self): + assert isinstance(self.document_value, Mapping) + assert isinstance(self.document_value["uri"], str) + assert isinstance(self.document_value.get("prefix"), str | None) + + @property + def uri(self) -> str: + return self.document_value["uri"] # type: ignore + + @property + def prefix(self) -> str | None: + return self.document_value.get("prefix") # type: ignore + + +@dataclass(init=False, frozen=True) +class XMLFlattenedTrait(Trait, id=ShapeID("smithy.api#xmlFlattened")): + def __post_init__(self): + assert self.document_value is None + + +@dataclass(init=False, frozen=True) +class XMLAttributeTrait(Trait, id=ShapeID("smithy.api#xmlAttribute")): + def __post_init__(self): + assert self.document_value is None From 3b290b16d6791e39aea1691b7ae1ed0ef9f1ce0e Mon Sep 17 00:00:00 2001 From: Antonio Aranda <102337110+arandito@users.noreply.github.com> Date: Fri, 20 Mar 2026 14:48:42 -0400 Subject: [PATCH 2/2] Fix type in changelog Co-authored-by: jonathan343 <43360731+jonathan343@users.noreply.github.com> --- ...mithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/smithy-core/.changes/next-release/smithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json b/packages/smithy-core/.changes/next-release/smithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json index 36cac6613..ae06e0a5f 100644 --- a/packages/smithy-core/.changes/next-release/smithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json +++ b/packages/smithy-core/.changes/next-release/smithy-core-enhancement-80e80edee8a7461d99ca5f28c2547e59.json @@ -1,4 +1,4 @@ { "type": "enhancement", - "description": "Added XML binding traits: `XMNameTrait`, `XMLNamespaceTrait`, `XMLFlattenedTrait`, and `XMLAttributeTrait`." + "description": "Added XML binding traits: `XMLNameTrait`, `XMLNamespaceTrait`, `XMLFlattenedTrait`, and `XMLAttributeTrait`." } \ No newline at end of file