-
Notifications
You must be signed in to change notification settings - Fork 33
feat: schema based XML #1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dayaffe
wants to merge
45
commits into
epic/sbs
Choose a base branch
from
day/schema-xml
base: epic/sbs
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: schema based XML #1047
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
e5a13dd
feat: Schema-based RestXML serialization/deserialization
dayaffe bfe3316
fix: Update MockHTTPRestXMLProtocolGenerator for schema-based
dayaffe 2a34000
fix: Code review fixes
dayaffe d4413ee
cleanup: Remove dead code in Serializer.writeScalar
dayaffe c521feb
cleanup: Remove unnecessary comments, match CBOR comment patterns
dayaffe d31e482
cleanup: Remove MARK comments to match codebase pattern
dayaffe abae2ab
refactor: Rewrite Serializer to wrap SmithyXML.Writer
dayaffe 60bc387
fix: SwiftLint - sort imports and fix line length
dayaffe d7390b4
fix: Delete obsolete XML serde tests and update test models
dayaffe 6c3e7a3
fix: Resolve ktlint function-signature violations
dayaffe 7cfeac4
Merge epic/sbs into day/schema-xml
dayaffe 0e562ca
fix: Generate HTTP binding providers for schema-based RestXML
dayaffe 20e21bf
chore: Retrigger CI to pick up companion fix (SmithyRestXML dep in pr…
dayaffe 7bdc134
fix(SmithyRestXML): Avoid libxml2 parse on empty response body
dayaffe 5ecbe05
feat(SmithyRestXML): Extract HTTP response bindings in schema-based d…
dayaffe 8cc3ba5
Merge remote-tracking branch 'origin/epic/sbs' into day/schema-xml
dayaffe 8caa4b7
fix: Resolve SwiftLint line_length violation in Deserializer
dayaffe 0616fa4
fix(SmithyRestXML): Enumerate synthesized children for list-typed HTT…
dayaffe 8db27d1
fix(SmithyRestXML): Timestamp-header default format + prefix-headers map
dayaffe 7bd40a0
fix(SmithyRestXML): Add SmithyCodeGeneratorPlugin, HTTP traits, fix s…
dayaffe dbf35ef
fix(SmithyCodegenCore): Add XmlNameTrait to synthetic input/output sh…
dayaffe 8620209
fix: XmlNameTrait inheritance, payload xmlName, service xmlNamespace,…
dayaffe 6a8a705
fix(SmithyRestXML): Narrow unwrapped-output check to leaf nodes only
dayaffe 2f5455f
fix(SmithyRestXML): Handle streaming @httpPayload without consuming b…
dayaffe 8ddf59c
fix(SmithyRestXML): Detect streaming body by ByteStream case, not sch…
dayaffe 88e00fa
fix: Resolve swiftlint line_length violations in Serializer.swift
dayaffe 31ea1fe
fix: Resolve swiftlint sorted_imports violations
dayaffe 882e210
fix: Resolve remaining swiftlint sorted_imports violation in Serializ…
dayaffe 6d95570
fix(SmithyRestXML): Restore schema-based streaming payload detection
dayaffe 7e21375
fix: Repair merged import line in HTTPClientProtocol.swift
dayaffe 308b5d0
test: Update PackageManifestGeneratorTests for new plugin in schema-b…
dayaffe 87bf42f
fix(SmithyRestXML): Handle streaming @httpPayload in Deserializer and…
dayaffe 609c3e1
fix(SmithyRestXML): Handle streaming @httpPayload in serialization an…
dayaffe 3d21fdd
fix(SmithyRestXML): Handle empty-body 404 as NotFound error for S3 He…
dayaffe 4a5ccac
Merge branch 'epic/sbs' into day/schema-xml
dayaffe f4b1676
fix: Add @_spi(SchemaBasedSerde) to all trait and SmithyRestXML publi…
dayaffe d2ce4f8
fix: Add SchemaBasedSerde SPI to SmithyRestXMLTypes.kt
dayaffe dcb0aef
fix: Render empty struct XML elements and remove unused import
dayaffe a35d4fa
fix: Handle event stream responses in RestXML deserialization
dayaffe 3c715a2
fix: Detect event streams via schema instead of content-type
dayaffe efaceec
fix: RestXML event stream target + error resolver hook
dayaffe 3281048
fix: skip XML parsing for blob event payloads
dayaffe 61e7e6d
Merge branch 'epic/sbs' into day/schema-xml
dayaffe b7bd655
fix: style consistency in RawBlobDeserializer + error message
dayaffe 6f7ca6b
fixup: deslop + epic-pattern alignment for SBS RestXML
dayaffe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct HttpHeaderTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "httpHeader") } | ||
| public let value: String | ||
| public var node: Node { .string(value) } | ||
|
|
||
| public init(node: Node) throws { | ||
| guard case .string(let value) = node else { | ||
| throw TraitError("httpHeader trait requires a string value") | ||
| } | ||
| self.value = value | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct HttpLabelTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "httpLabel") } | ||
| public var node: Node { [:] } | ||
| public init(node: Node) throws {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct HttpPayloadTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "httpPayload") } | ||
| public var node: Node { [:] } | ||
| public init(node: Node) throws {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct HttpPrefixHeadersTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "httpPrefixHeaders") } | ||
| public let value: String | ||
| public var node: Node { .string(value) } | ||
|
|
||
| public init(node: Node) throws { | ||
| guard case .string(let value) = node else { | ||
| throw TraitError("httpPrefixHeaders trait requires a string value") | ||
| } | ||
| self.value = value | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct HttpQueryParamsTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "httpQueryParams") } | ||
| public var node: Node { [:] } | ||
| public init(node: Node) throws {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct HttpQueryTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "httpQuery") } | ||
| public let value: String | ||
| public var node: Node { .string(value) } | ||
|
|
||
| public init(node: Node) throws { | ||
| guard case .string(let value) = node else { | ||
| throw TraitError("httpQuery trait requires a string value") | ||
| } | ||
| self.value = value | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct HttpResponseCodeTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "httpResponseCode") } | ||
| public var node: Node { [:] } | ||
| public init(node: Node) throws {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct XmlAttributeTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "xmlAttribute") } | ||
| public var node: Node { [:] } | ||
| public init(node: Node) throws {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct XmlFlattenedTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "xmlFlattened") } | ||
| public var node: Node { [:] } | ||
| public init(node: Node) throws {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct XmlNameTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "xmlName") } | ||
| public let value: String | ||
| public var node: Node { .string(value) } | ||
|
|
||
| public init(node: Node) throws { | ||
| guard case .string(let value) = node else { | ||
| throw TraitError("xmlName trait requires a string value") | ||
| } | ||
| self.value = value | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // | ||
| // Copyright Amazon.com Inc. or its affiliates. | ||
| // All Rights Reserved. | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| @_spi(SchemaBasedSerde) | ||
| public struct XmlNamespaceTrait: Trait { | ||
| public static var id: ShapeID { .init("smithy.api", "xmlNamespace") } | ||
| public let uri: String | ||
| public let prefix: String? | ||
| public var node: Node { | ||
| var dict: [String: Node] = ["uri": .string(uri)] | ||
| if let prefix { dict["prefix"] = .string(prefix) } | ||
| return .object(dict) | ||
| } | ||
|
|
||
| public init(node: Node) throws { | ||
| guard case .object(let dict) = node else { | ||
| throw TraitError("xmlNamespace trait requires an object value") | ||
| } | ||
| guard case .string(let uri) = dict["uri"] else { | ||
| throw TraitError("xmlNamespace trait requires a 'uri' string") | ||
| } | ||
| self.uri = uri | ||
| if case .string(let prefix) = dict["prefix"] { | ||
| self.prefix = prefix | ||
| } else { | ||
| self.prefix = nil | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,11 +32,17 @@ struct EventContentDeserializer: ShapeDeserializer { | |
|
|
||
| // Deserialize the event payload, to the member marked with @eventPayload if it exists, | ||
| // to the structure's members otherwise. | ||
| // Use a deserializer for the protocol in use, by making it from the codec. | ||
| let payloadDeserializer = try codec.makeDeserializer(data: message.payload) | ||
| if let payloadMember = schema.members.first(where: { $0.hasTrait(EventPayloadTrait.self) }) { | ||
| try T.readConsumer(payloadMember, &value, payloadDeserializer) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the spec for event payload, it can be a blob, string, structure, or union. We should probably just refactor this to do all 4. |
||
| // Skip codec for blob payloads — codec would parse as XML/JSON. | ||
| if (payloadMember.target ?? payloadMember).type == .blob { | ||
| let blobDeserializer = RawBlobDeserializer(data: message.payload) | ||
| try T.readConsumer(payloadMember, &value, blobDeserializer) | ||
| } else { | ||
| let payloadDeserializer = try codec.makeDeserializer(data: message.payload) | ||
| try T.readConsumer(payloadMember, &value, payloadDeserializer) | ||
| } | ||
| } else { | ||
| let payloadDeserializer = try codec.makeDeserializer(data: message.payload) | ||
| try payloadDeserializer.readStruct(schema, &value) | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simpler way: