diff --git a/Package.swift b/Package.swift index c37375913..5252d500a 100644 --- a/Package.swift +++ b/Package.swift @@ -103,7 +103,7 @@ let package = Package( ), .target( name: "SmithyReadWrite", - dependencies: ["SmithyTimestamps"] + dependencies: ["Smithy", "SmithyTimestamps"] ), .target( name: "SmithyXML", diff --git a/Sources/ClientRuntime/Networking/Http/HTTPResponse+WireDataProviding.swift b/Sources/ClientRuntime/Networking/Http/HTTPResponse+WireDataProviding.swift index dcd71d44d..38b514db5 100644 --- a/Sources/ClientRuntime/Networking/Http/HTTPResponse+WireDataProviding.swift +++ b/Sources/ClientRuntime/Networking/Http/HTTPResponse+WireDataProviding.swift @@ -7,9 +7,10 @@ import class SmithyHTTPAPI.HTTPResponse import enum Smithy.ByteStream -import protocol SmithyReadWrite.WireDataProviding +@_spi(SmithyReadWrite) import protocol SmithyReadWrite.WireDataProviding import struct Foundation.Data +@_spi(SmithyReadWrite) extension HTTPResponse: WireDataProviding { public func data() async throws -> Data { diff --git a/Sources/ClientRuntime/Networking/Http/Middlewares/DeserializeMiddleware.swift b/Sources/ClientRuntime/Networking/Http/Middlewares/DeserializeMiddleware.swift index 82441e401..fe5c82c88 100644 --- a/Sources/ClientRuntime/Networking/Http/Middlewares/DeserializeMiddleware.swift +++ b/Sources/ClientRuntime/Networking/Http/Middlewares/DeserializeMiddleware.swift @@ -6,7 +6,7 @@ // import SmithyHTTPAPI -import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyReadWrite import class Foundation.DateFormatter import struct Foundation.Locale import struct Foundation.TimeInterval @@ -15,6 +15,7 @@ import struct Foundation.UUID import class Smithy.Context import protocol Smithy.ResponseMessageDeserializer +@_spi(SmithyReadWrite) public struct DeserializeMiddleware { public var id: String = "Deserialize" let wireResponseClosure: WireResponseOutputClosure diff --git a/Sources/ClientRuntime/Networking/Http/Middlewares/RequestBody/BodyMiddleware.swift b/Sources/ClientRuntime/Networking/Http/Middlewares/RequestBody/BodyMiddleware.swift index 703f095c3..46308d05e 100644 --- a/Sources/ClientRuntime/Networking/Http/Middlewares/RequestBody/BodyMiddleware.swift +++ b/Sources/ClientRuntime/Networking/Http/Middlewares/RequestBody/BodyMiddleware.swift @@ -8,9 +8,10 @@ import Smithy import SmithyHTTPAPI import struct Foundation.Data -import protocol SmithyReadWrite.SmithyWriter -import typealias SmithyReadWrite.WritingClosure +@_spi(SmithyReadWrite) import protocol SmithyReadWrite.SmithyWriter +@_spi(SmithyReadWrite) import typealias SmithyReadWrite.WritingClosure +@_spi(SmithyReadWrite) public struct BodyMiddleware { diff --git a/Sources/ClientRuntime/Networking/Http/Middlewares/RequestBody/EventStreamBodyMiddleware.swift b/Sources/ClientRuntime/Networking/Http/Middlewares/RequestBody/EventStreamBodyMiddleware.swift index 62bef3436..f35eeccd9 100644 --- a/Sources/ClientRuntime/Networking/Http/Middlewares/RequestBody/EventStreamBodyMiddleware.swift +++ b/Sources/ClientRuntime/Networking/Http/Middlewares/RequestBody/EventStreamBodyMiddleware.swift @@ -11,7 +11,7 @@ import SmithyEventStreams import SmithyEventStreamsAPI import SmithyEventStreamsAuthAPI import struct Foundation.Data -import typealias SmithyReadWrite.WritingClosure +@_spi(SmithyReadWrite) import typealias SmithyReadWrite.WritingClosure import SmithyHTTPAPI public struct EventStreamBodyMiddleware Data diff --git a/Sources/SmithyReadWrite/ReadingClosure.swift b/Sources/SmithyReadWrite/ReadingClosure.swift index e85339249..d030f71d7 100644 --- a/Sources/SmithyReadWrite/ReadingClosure.swift +++ b/Sources/SmithyReadWrite/ReadingClosure.swift @@ -7,10 +7,12 @@ import struct Foundation.Data import struct Foundation.Date -import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyTimestamps) import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyReadWrite) public typealias ReadingClosure = (Reader) throws -> T +@_spi(SmithyReadWrite) public func mapReadingClosure( valueReadingClosure: @escaping ReadingClosure, keyNodeInfo: Reader.NodeInfo, @@ -27,6 +29,7 @@ public func mapReadingClosure( } } +@_spi(SmithyReadWrite) public func mapReadingClosure( valueReadingClosure: @escaping ReadingClosure, keyNodeInfo: Reader.NodeInfo, @@ -43,6 +46,7 @@ public func mapReadingClosure( } } +@_spi(SmithyReadWrite) public func listReadingClosure( memberReadingClosure: @escaping ReadingClosure, memberNodeInfo: Reader.NodeInfo, @@ -57,6 +61,7 @@ public func listReadingClosure( } } +@_spi(SmithyReadWrite) public func listReadingClosure( memberReadingClosure: @escaping ReadingClosure, memberNodeInfo: Reader.NodeInfo, @@ -71,18 +76,21 @@ public func listReadingClosure( } } +@_spi(SmithyReadWrite) public func timestampReadingClosure(format: TimestampFormat) -> ReadingClosure { return { reader in try reader.readTimestamp(format: format) } } +@_spi(SmithyReadWrite) public func timestampReadingClosure(format: TimestampFormat) -> ReadingClosure { return { reader in try reader.readTimestampIfPresent(format: format) } } +@_spi(SmithyReadWrite) public struct ReadingClosureBox { public init() {} @@ -104,6 +112,7 @@ public struct ReadingClosureBox { } } +@_spi(SmithyReadWrite) public enum ReadingClosures { public static func readString(from reader: Reader) throws -> String { @@ -163,6 +172,7 @@ public enum ReadingClosures { } } +@_spi(SmithyReadWrite) public func optionalFormOf( readingClosure: @escaping ReadingClosure ) -> ReadingClosure { diff --git a/Sources/SmithyReadWrite/SmithyReader.swift b/Sources/SmithyReadWrite/SmithyReader.swift index 3fdd960d1..657550040 100644 --- a/Sources/SmithyReadWrite/SmithyReader.swift +++ b/Sources/SmithyReadWrite/SmithyReader.swift @@ -7,8 +7,9 @@ import struct Foundation.Data import struct Foundation.Date -import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyTimestamps) import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyReadWrite) public protocol SmithyReader: AnyObject { associatedtype NodeInfo diff --git a/Sources/SmithyReadWrite/SmithyWriter.swift b/Sources/SmithyReadWrite/SmithyWriter.swift index 21a21a45c..a44ad64ce 100644 --- a/Sources/SmithyReadWrite/SmithyWriter.swift +++ b/Sources/SmithyReadWrite/SmithyWriter.swift @@ -7,8 +7,10 @@ import struct Foundation.Data import struct Foundation.Date -import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyTimestamps) import enum SmithyTimestamps.TimestampFormat +import enum Smithy.ByteStream +@_spi(SmithyReadWrite) public protocol SmithyWriter: AnyObject { associatedtype NodeInfo @@ -47,6 +49,17 @@ public protocol SmithyWriter: AnyObject { public extension SmithyWriter { + func write(_ value: ByteStream?) throws { + // This serialization will never be performed in practice, since + // a ByteStream will never be a part of + // a XML body - if there is a streaming member in a restXml + // input shape, the rest of the input members must all be bound + // to HTML components outside the body. + // + // This empty implementation is only provided to quiet the + // compiler when a structure with a ByteSteam is code-generated. + } + static func write( _ value: T, rootNodeInfo: NodeInfo, diff --git a/Sources/SmithyReadWrite/WireResponseErrorClosure.swift b/Sources/SmithyReadWrite/WireResponseErrorClosure.swift index 9fa09697d..0d384a9cb 100644 --- a/Sources/SmithyReadWrite/WireResponseErrorClosure.swift +++ b/Sources/SmithyReadWrite/WireResponseErrorClosure.swift @@ -6,4 +6,5 @@ // /// Defines a closure that can be used to convert a wire response to a Swift `Error`. +@_spi(SmithyReadWrite) public typealias WireResponseErrorClosure = (WireResponse) async throws -> Error diff --git a/Sources/SmithyReadWrite/WireResponseOutputClosure.swift b/Sources/SmithyReadWrite/WireResponseOutputClosure.swift index 5bf7fc67d..d8a7d6f82 100644 --- a/Sources/SmithyReadWrite/WireResponseOutputClosure.swift +++ b/Sources/SmithyReadWrite/WireResponseOutputClosure.swift @@ -6,5 +6,6 @@ // /// Defines a closure that can be used to convert a wire response to an output value. +@_spi(SmithyReadWrite) public typealias WireResponseOutputClosure = (WireResponse) async throws -> OperationStackOutput diff --git a/Sources/SmithyReadWrite/WritingClosure.swift b/Sources/SmithyReadWrite/WritingClosure.swift index 7dc845939..61fba771c 100644 --- a/Sources/SmithyReadWrite/WritingClosure.swift +++ b/Sources/SmithyReadWrite/WritingClosure.swift @@ -7,10 +7,12 @@ import struct Foundation.Data import struct Foundation.Date -import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyTimestamps) import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyReadWrite) public typealias WritingClosure = (T, Writer) throws -> Void +@_spi(SmithyReadWrite) public func mapWritingClosure( valueWritingClosure: @escaping WritingClosure, keyNodeInfo: Writer.NodeInfo, @@ -28,6 +30,7 @@ public func mapWritingClosure( } } +@_spi(SmithyReadWrite) public func listWritingClosure( memberWritingClosure: @escaping WritingClosure, memberNodeInfo: Writer.NodeInfo, @@ -43,12 +46,14 @@ public func listWritingClosure( } } +@_spi(SmithyReadWrite) public func timestampWritingClosure(format: TimestampFormat) -> WritingClosure { return { date, writer in try writer.writeTimestamp(date, format: format) } } +@_spi(SmithyReadWrite) public struct WritingClosureBox { public init() {} @@ -62,6 +67,7 @@ public struct WritingClosureBox { } } +@_spi(SmithyReadWrite) public enum WritingClosures { public static func writeString(value: String?, to writer: Writer) throws { @@ -101,6 +107,7 @@ public enum WritingClosures { } } +@_spi(SmithyReadWrite) public func sparseFormOf( writingClosure: @escaping WritingClosure ) -> WritingClosure { diff --git a/Sources/SmithyTestUtil/Errors/TestBaseError.swift b/Sources/SmithyTestUtil/Errors/TestBaseError.swift index 3c3943cef..69be4491b 100644 --- a/Sources/SmithyTestUtil/Errors/TestBaseError.swift +++ b/Sources/SmithyTestUtil/Errors/TestBaseError.swift @@ -8,8 +8,9 @@ import protocol ClientRuntime.BaseError import enum ClientRuntime.BaseErrorDecodeError import class SmithyHTTPAPI.HTTPResponse -import class SmithyJSON.Reader +@_spi(SmithyReadWrite) import class SmithyJSON.Reader +@_spi(SmithyReadWrite) public struct TestBaseError: BaseError { public let code: String public let message: String? diff --git a/Sources/SmithyTestUtil/RequestTestUtil/MockDeserializeMiddleware.swift b/Sources/SmithyTestUtil/RequestTestUtil/MockDeserializeMiddleware.swift index 6b941856a..cf26c6421 100644 --- a/Sources/SmithyTestUtil/RequestTestUtil/MockDeserializeMiddleware.swift +++ b/Sources/SmithyTestUtil/RequestTestUtil/MockDeserializeMiddleware.swift @@ -7,9 +7,10 @@ import Smithy import SmithyHTTPAPI -import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyReadWrite import ClientRuntime +@_spi(SmithyReadWrite) public struct MockDeserializeMiddleware { public var id: String let responseClosure: WireResponseOutputClosure diff --git a/Sources/SmithyTimestamps/DateFormatters.swift b/Sources/SmithyTimestamps/DateFormatters.swift index 9c9db396c..e31f666f8 100644 --- a/Sources/SmithyTimestamps/DateFormatters.swift +++ b/Sources/SmithyTimestamps/DateFormatters.swift @@ -10,6 +10,7 @@ import struct Foundation.Date public typealias DateFormatter = Foundation.DateFormatter +@_spi(SmithyTimestamps) extension DateFormatter { /// A date formatter that converts between dates and the IMF-fixdate, with fractional seconds, string representation in RFC 7231#section-7.1.1.1 (for example, Sun, 02 Jan 2000 20:34:56.000 GMT) /// https://tools.ietf.org/html/rfc7231.html#section-7.1.1.1 @@ -44,6 +45,7 @@ extension DateFormatter { } } +@_spi(SmithyTimestamps) extension Date { /// Returns a string representation of the date in the ISO8601 format using the date-time production in RFC3339 section 5.6 with no UTC offset and with fractional seconds (for example, 1985-04-12T23:20:50.52Z) func iso8601WithFractionalSeconds() -> String { diff --git a/Sources/SmithyTimestamps/TimestampSerdeUtils.swift b/Sources/SmithyTimestamps/TimestampSerdeUtils.swift index a749d2755..26310cae2 100644 --- a/Sources/SmithyTimestamps/TimestampSerdeUtils.swift +++ b/Sources/SmithyTimestamps/TimestampSerdeUtils.swift @@ -10,6 +10,7 @@ import struct Foundation.Date /// Custom timestamp serialization formats /// https://smithy.io/2.0/spec/protocol-traits.html#smithy-api-timestampformat-trait +@_spi(SmithyTimestamps) public enum TimestampFormat: CaseIterable { /// Also known as Unix time, the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, with optional fractional precision (for example, 1515531081.1234). case epochSeconds @@ -22,6 +23,7 @@ public enum TimestampFormat: CaseIterable { } /// A formatter that converts between dates and their smithy timestamp string representations. +@_spi(SmithyTimestamps) public struct TimestampFormatter { /// The timestamp serialization format let format: TimestampFormat @@ -84,6 +86,7 @@ public struct TimestampFormatter { } } +@_spi(SmithyTimestamps) extension Date { /// Creates a date from a string using the given formatters. /// The date returned will be from the first formatter, in the given formatters list, that is able to successfully convert the date to a string. diff --git a/Sources/SmithyXML/NodeInfo.swift b/Sources/SmithyXML/NodeInfo.swift index 87d6a9b9b..c84259ab9 100644 --- a/Sources/SmithyXML/NodeInfo.swift +++ b/Sources/SmithyXML/NodeInfo.swift @@ -5,6 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // +@_spi(SmithyReadWrite) public struct NodeInfo: Equatable { public enum Location { diff --git a/Sources/SmithyXML/Reader/Reader.swift b/Sources/SmithyXML/Reader/Reader.swift index 5b7dff712..ef62555ae 100644 --- a/Sources/SmithyXML/Reader/Reader.swift +++ b/Sources/SmithyXML/Reader/Reader.swift @@ -5,14 +5,15 @@ // SPDX-License-Identifier: Apache-2.0 // -import protocol SmithyReadWrite.SmithyReader +@_spi(SmithyReadWrite) import protocol SmithyReadWrite.SmithyReader import enum SmithyReadWrite.Document -import typealias SmithyReadWrite.ReadingClosure +@_spi(SmithyReadWrite) import typealias SmithyReadWrite.ReadingClosure import struct Foundation.Date import struct Foundation.Data -import enum SmithyTimestamps.TimestampFormat -import struct SmithyTimestamps.TimestampFormatter +@_spi(SmithyTimestamps) import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyTimestamps) import struct SmithyTimestamps.TimestampFormatter +@_spi(SmithyReadWrite) public final class Reader: SmithyReader { public typealias ReaderNodeInfo = NodeInfo public internal(set) var children: [Reader] = [] diff --git a/Sources/SmithyXML/Writer/Writer.swift b/Sources/SmithyXML/Writer/Writer.swift index ec1ba9af9..f9b5ec84e 100644 --- a/Sources/SmithyXML/Writer/Writer.swift +++ b/Sources/SmithyXML/Writer/Writer.swift @@ -5,13 +5,13 @@ // SPDX-License-Identifier: Apache-2.0 // -import protocol SmithyReadWrite.SmithyWriter +@_spi(SmithyReadWrite) import protocol SmithyReadWrite.SmithyWriter import enum SmithyReadWrite.Document import struct Foundation.Date import struct Foundation.Data -import typealias SmithyReadWrite.WritingClosure -import enum SmithyTimestamps.TimestampFormat -import struct SmithyTimestamps.TimestampFormatter +@_spi(SmithyReadWrite) import typealias SmithyReadWrite.WritingClosure +@_spi(SmithyTimestamps) import enum SmithyTimestamps.TimestampFormat +@_spi(SmithyTimestamps) import struct SmithyTimestamps.TimestampFormatter /// A class used to encode a tree of model data as XML. /// @@ -21,6 +21,7 @@ import struct SmithyTimestamps.TimestampFormatter /// This writer will write all Swift types used by Smithy models, and will also write Swift /// `Array` and `Dictionary` (optionally as flattened XML) given a writing closure for /// their enclosed data types. +@_spi(SmithyReadWrite) public final class Writer: SmithyWriter { var content: String? var children: [Writer] = [] diff --git a/Tests/ClientRuntimeTests/MiddlewareTests/ProviderTests.swift b/Tests/ClientRuntimeTests/MiddlewareTests/ProviderTests.swift index fdd32ec57..626b4382b 100644 --- a/Tests/ClientRuntimeTests/MiddlewareTests/ProviderTests.swift +++ b/Tests/ClientRuntimeTests/MiddlewareTests/ProviderTests.swift @@ -9,7 +9,7 @@ import Smithy import SmithyHTTPAPI import XCTest import ClientRuntime -import SmithyTestUtil +@_spi(SmithyReadWrite) import SmithyTestUtil class ProviderTests: HttpRequestTestBase { diff --git a/Tests/ClientRuntimeTests/NetworkingTests/Http/MiddlewareTests/ContentLengthMiddlewareTests.swift b/Tests/ClientRuntimeTests/NetworkingTests/Http/MiddlewareTests/ContentLengthMiddlewareTests.swift index 75f53dfcc..eac4b7469 100644 --- a/Tests/ClientRuntimeTests/NetworkingTests/Http/MiddlewareTests/ContentLengthMiddlewareTests.swift +++ b/Tests/ClientRuntimeTests/NetworkingTests/Http/MiddlewareTests/ContentLengthMiddlewareTests.swift @@ -4,7 +4,7 @@ import Smithy import SmithyHTTPAPI import XCTest -import SmithyTestUtil +@_spi(SmithyReadWrite) import SmithyTestUtil @testable import ClientRuntime import class SmithyStreams.BufferedStream diff --git a/Tests/ClientRuntimeTests/NetworkingTests/Http/MiddlewareTests/MutateHeaderMiddlewareTests.swift b/Tests/ClientRuntimeTests/NetworkingTests/Http/MiddlewareTests/MutateHeaderMiddlewareTests.swift index 322867b06..aeed58473 100644 --- a/Tests/ClientRuntimeTests/NetworkingTests/Http/MiddlewareTests/MutateHeaderMiddlewareTests.swift +++ b/Tests/ClientRuntimeTests/NetworkingTests/Http/MiddlewareTests/MutateHeaderMiddlewareTests.swift @@ -9,7 +9,7 @@ import Smithy import SmithyHTTPAPI import XCTest @testable import ClientRuntime -import SmithyTestUtil +@_spi(SmithyReadWrite) import SmithyTestUtil class MutateHeaderMiddlewareTests: XCTestCase { var httpClientConfiguration: HttpClientConfiguration! = nil diff --git a/Tests/ClientRuntimeTests/OrchestratorTests/OrchestratorTests.swift b/Tests/ClientRuntimeTests/OrchestratorTests/OrchestratorTests.swift index f300e3e0b..2e63544b6 100644 --- a/Tests/ClientRuntimeTests/OrchestratorTests/OrchestratorTests.swift +++ b/Tests/ClientRuntimeTests/OrchestratorTests/OrchestratorTests.swift @@ -13,7 +13,8 @@ import XCTest @testable import ClientRuntime import SmithyRetriesAPI import SmithyRetries -import SmithyJSON +@_spi(SmithyReadWrite) import SmithyJSON +@_spi(SmithyReadWrite) import SmithyReadWrite class OrchestratorTests: XCTestCase { struct TestInput { diff --git a/Tests/SmithyFormURLTests/FormURLEncoderTests.swift b/Tests/SmithyFormURLTests/FormURLEncoderTests.swift index 16aa6bc51..5a74c4d53 100644 --- a/Tests/SmithyFormURLTests/FormURLEncoderTests.swift +++ b/Tests/SmithyFormURLTests/FormURLEncoderTests.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -import SmithyFormURL +@_spi(SmithyReadWrite) import SmithyFormURL import XCTest @testable import ClientRuntime diff --git a/Tests/SmithyFormURLTests/Models/QueryListsInput.swift b/Tests/SmithyFormURLTests/Models/QueryListsInput.swift index e6abec327..31b07c77b 100644 --- a/Tests/SmithyFormURLTests/Models/QueryListsInput.swift +++ b/Tests/SmithyFormURLTests/Models/QueryListsInput.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import SmithyReadWrite -import SmithyFormURL +@_spi(SmithyReadWrite) import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyFormURL @testable import ClientRuntime public struct QueryListsInput: Equatable { @@ -23,6 +23,7 @@ public struct QueryListsInput: Equatable { } } +@_spi(SmithyReadWrite) extension QueryListsInput { static func write(value: QueryListsInput?, to writer: SmithyFormURL.Writer) throws { diff --git a/Tests/SmithyFormURLTests/Models/QueryMapsInput.swift b/Tests/SmithyFormURLTests/Models/QueryMapsInput.swift index 0128041bb..c56b06511 100644 --- a/Tests/SmithyFormURLTests/Models/QueryMapsInput.swift +++ b/Tests/SmithyFormURLTests/Models/QueryMapsInput.swift @@ -5,8 +5,8 @@ // SPDX-License-Identifier: Apache-2.0 // -import SmithyReadWrite -import SmithyFormURL +@_spi(SmithyReadWrite) import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyFormURL @testable import ClientRuntime public struct QueryMapsInput: Equatable { @@ -23,6 +23,7 @@ public struct QueryMapsInput: Equatable { } } +@_spi(SmithyReadWrite) extension QueryMapsInput: Encodable { static func write(value: QueryMapsInput?, to writer: SmithyFormURL.Writer) throws { diff --git a/Tests/SmithyJSONTests/ReaderTests.swift b/Tests/SmithyJSONTests/ReaderTests.swift index 6354f67c2..76a10b30f 100644 --- a/Tests/SmithyJSONTests/ReaderTests.swift +++ b/Tests/SmithyJSONTests/ReaderTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import SmithyJSON +@testable @_spi(SmithyReadWrite) import SmithyJSON class ReaderTests: XCTestCase { diff --git a/Tests/SmithyJSONTests/WriterTests.swift b/Tests/SmithyJSONTests/WriterTests.swift index 4d5c72595..642bc8002 100644 --- a/Tests/SmithyJSONTests/WriterTests.swift +++ b/Tests/SmithyJSONTests/WriterTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import SmithyJSON +@testable @_spi(SmithyReadWrite) import SmithyJSON class WriterTests: XCTestCase { diff --git a/Tests/SmithyTestUtilTests/RequestTestUtilTests/HttpRequestTestBaseTests.swift b/Tests/SmithyTestUtilTests/RequestTestUtilTests/HttpRequestTestBaseTests.swift index e9b62b67d..4cf3bb420 100644 --- a/Tests/SmithyTestUtilTests/RequestTestUtilTests/HttpRequestTestBaseTests.swift +++ b/Tests/SmithyTestUtilTests/RequestTestUtilTests/HttpRequestTestBaseTests.swift @@ -5,9 +5,9 @@ import Smithy import SmithyHTTPAPI -import SmithyReadWrite -import SmithyJSON -import SmithyTestUtil +@_spi(SmithyReadWrite) import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyJSON +@_spi(SmithyReadWrite) import SmithyTestUtil import ClientRuntime import XCTest diff --git a/Tests/SmithyTimestampsTests/DateFormatterTests.swift b/Tests/SmithyTimestampsTests/DateFormatterTests.swift index e40f9644c..227d45d03 100644 --- a/Tests/SmithyTimestampsTests/DateFormatterTests.swift +++ b/Tests/SmithyTimestampsTests/DateFormatterTests.swift @@ -4,7 +4,7 @@ */ import XCTest -@testable import SmithyTimestamps +@_spi(SmithyTimestamps) @testable import SmithyTimestamps class DateFormatterTests: XCTestCase { diff --git a/Tests/SmithyTimestampsTests/TimestampSerdeUtilsTests.swift b/Tests/SmithyTimestampsTests/TimestampSerdeUtilsTests.swift index 1e9666553..0e86343fb 100644 --- a/Tests/SmithyTimestampsTests/TimestampSerdeUtilsTests.swift +++ b/Tests/SmithyTimestampsTests/TimestampSerdeUtilsTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import SmithyTimestamps +@_spi(SmithyTimestamps) @testable import SmithyTimestamps class TimestampSerdeUtilsTests: XCTestCase { diff --git a/Tests/SmithyXMLTests/FloatReaderTests.swift b/Tests/SmithyXMLTests/FloatReaderTests.swift index 3325a3958..d9044ed5a 100644 --- a/Tests/SmithyXMLTests/FloatReaderTests.swift +++ b/Tests/SmithyXMLTests/FloatReaderTests.swift @@ -6,7 +6,8 @@ // import XCTest -@testable import SmithyXML +@_spi(SmithyReadWrite) import SmithyReadWrite +@testable @_spi(SmithyReadWrite) import SmithyXML class FloatReaderTests: XCTestCase { diff --git a/Tests/SmithyXMLTests/FloatWriterTests.swift b/Tests/SmithyXMLTests/FloatWriterTests.swift index 9b26bab0e..732aa041b 100644 --- a/Tests/SmithyXMLTests/FloatWriterTests.swift +++ b/Tests/SmithyXMLTests/FloatWriterTests.swift @@ -6,8 +6,8 @@ // import XCTest -import SmithyXML -import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyXML +@_spi(SmithyReadWrite) import SmithyReadWrite class FloatWriterTests: XCTestCase { diff --git a/Tests/SmithyXMLTests/NamespaceReaderTests.swift b/Tests/SmithyXMLTests/NamespaceReaderTests.swift index 4ba4c89dc..29b27c7e3 100644 --- a/Tests/SmithyXMLTests/NamespaceReaderTests.swift +++ b/Tests/SmithyXMLTests/NamespaceReaderTests.swift @@ -6,9 +6,8 @@ // import SmithyHTTPAPI -import SmithyReadWrite -import SmithyXML -import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyXML +@_spi(SmithyReadWrite) import SmithyReadWrite import ClientRuntime import XCTest diff --git a/Tests/SmithyXMLTests/NodeInfoTests.swift b/Tests/SmithyXMLTests/NodeInfoTests.swift index 84fccc757..a4ad2df8a 100644 --- a/Tests/SmithyXMLTests/NodeInfoTests.swift +++ b/Tests/SmithyXMLTests/NodeInfoTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import SmithyXML +@testable @_spi(SmithyReadWrite) import SmithyXML class NodeInfoTests: XCTestCase { diff --git a/Tests/SmithyXMLTests/ReaderTests.swift b/Tests/SmithyXMLTests/ReaderTests.swift index 3bdcdfae6..34af35b8d 100644 --- a/Tests/SmithyXMLTests/ReaderTests.swift +++ b/Tests/SmithyXMLTests/ReaderTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import SmithyXML +@testable @_spi(SmithyReadWrite) import SmithyXML class ReaderTests: XCTestCase { let xmlData = Data(""" diff --git a/Tests/SmithyXMLTests/WriterTests.swift b/Tests/SmithyXMLTests/WriterTests.swift index 5c75e3299..6a19f69bb 100644 --- a/Tests/SmithyXMLTests/WriterTests.swift +++ b/Tests/SmithyXMLTests/WriterTests.swift @@ -5,9 +5,9 @@ // SPDX-License-Identifier: Apache-2.0 // -import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyReadWrite +@_spi(SmithyReadWrite) import SmithyXML import XCTest -@_spi(SmithyXML) import SmithyXML class WriterTests: XCTestCase { diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftImportContainer.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftImportContainer.kt index e27ebb362..292d44edc 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftImportContainer.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftImportContainer.kt @@ -14,7 +14,7 @@ class SwiftImportContainer : ImportContainer { fun addImport( packageName: String, isTestable: Boolean = false, - internalSPIName: String? = null, + internalSPINames: List = emptyList(), importOnlyIfCanImport: Boolean = false ) { if (packageName.isEmpty()) { return } @@ -22,14 +22,11 @@ class SwiftImportContainer : ImportContainer { // Update isTestable to true if needed it.isTestable = it.isTestable || isTestable // If we have an existing import with the same package name, then add the SPI name to the existing list - if (internalSPIName != null) { - it.internalSPINames.add(internalSPIName) - } + internalSPINames.forEach { name -> it.internalSPINames.add(name) } // Update importOnlyIfCanImport to true if needed it.importOnlyIfCanImport = it.importOnlyIfCanImport || importOnlyIfCanImport } ?: run { - val internalSPINames = listOf(internalSPIName).mapNotNull { it }.toMutableSet() - importStatements.add(ImportStatement(packageName, isTestable, internalSPINames, importOnlyIfCanImport)) + importStatements.add(ImportStatement(packageName, isTestable, internalSPINames.toMutableSet(), importOnlyIfCanImport)) } } diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftWriter.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftWriter.kt index 2bee94e35..3abaa7057 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftWriter.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftWriter.kt @@ -28,6 +28,7 @@ import software.amazon.smithy.swift.codegen.model.isGeneric import software.amazon.smithy.swift.codegen.model.isOptional import software.amazon.smithy.swift.codegen.model.isServiceNestedNamespace import java.util.function.BiFunction +import kotlin.jvm.optionals.getOrElse import kotlin.jvm.optionals.getOrNull /** @@ -104,7 +105,7 @@ class SwiftWriter( fun addImport(symbol: Symbol) { symbol.references.forEach { addImport(it.symbol) } if (symbol.isBuiltIn || symbol.isServiceNestedNamespace || symbol.namespace.isEmpty()) return - val spiName = symbol.getProperty("spiName").getOrNull()?.toString() + val spiNames = symbol.getProperty("spiNames").getOrElse { emptyList() } as List val decl = symbol.getProperty("decl").getOrNull()?.toString() decl?.let { // No need to import Foundation types individually because: @@ -118,21 +119,23 @@ class SwiftWriter( if (symbol.namespace == "Foundation") { addImport(symbol.namespace) } else { - addImport("$it ${symbol.namespace}.${symbol.name}", internalSPIName = spiName) + addImport("$it ${symbol.namespace}.${symbol.name}", internalSPINames = spiNames) } } ?: run { - addImport(symbol.namespace, internalSPIName = spiName) + addImport(symbol.namespace, internalSPINames = spiNames) } symbol.dependencies.forEach { addDependency(it) } + val additionalImports = symbol.getProperty("additionalImports").getOrElse { emptyList() } as List + additionalImports.forEach { addImport(it) } } fun addImport( packageName: String, isTestable: Boolean = false, - internalSPIName: String? = null, + internalSPINames: List = emptyList(), importOnlyIfCanImport: Boolean = false ) { - importContainer.addImport(packageName, isTestable, internalSPIName, importOnlyIfCanImport) + importContainer.addImport(packageName, isTestable, internalSPINames, importOnlyIfCanImport) } fun addImportReferences(symbol: Symbol, vararg options: SymbolReference.ContextOption) { diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/config/DefaultClientConfiguration.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/config/DefaultClientConfiguration.kt index 2aaf5193c..39dce4895 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/config/DefaultClientConfiguration.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/config/DefaultClientConfiguration.kt @@ -42,7 +42,7 @@ class DefaultClientConfiguration : ClientConfiguration { ), ConfigProperty( "interceptorProviders", - ClientRuntimeTypes.Core.InterceptorProviders, + ClientRuntimeTypes.Composite.InterceptorProviders, { "[]" }, accessModifier = AccessModifier.PublicPrivateSet ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/config/DefaultHttpClientConfiguration.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/config/DefaultHttpClientConfiguration.kt index f3d459d72..d478e186f 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/config/DefaultHttpClientConfiguration.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/config/DefaultHttpClientConfiguration.kt @@ -44,7 +44,7 @@ class DefaultHttpClientConfiguration : ClientConfiguration { ), ConfigProperty( "httpInterceptorProviders", - ClientRuntimeTypes.Core.HttpInterceptorProviders, + ClientRuntimeTypes.Composite.HttpInterceptorProviders, { "[]" }, accessModifier = AccessModifier.PublicPrivateSet ), diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingErrorGenerator.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingErrorGenerator.kt index f19c5fe6d..6549c3ce5 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingErrorGenerator.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingErrorGenerator.kt @@ -9,12 +9,14 @@ import software.amazon.smithy.aws.traits.protocols.RestXmlTrait import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.model.shapes.OperationShape import software.amazon.smithy.model.shapes.StructureShape +import software.amazon.smithy.swift.codegen.SwiftDependency import software.amazon.smithy.swift.codegen.integration.HTTPProtocolCustomizable import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.serde.struct.readerSymbol import software.amazon.smithy.swift.codegen.model.getTrait import software.amazon.smithy.swift.codegen.model.toUpperCamelCase import software.amazon.smithy.swift.codegen.swiftmodules.SmithyHTTPAPITypes +import software.amazon.smithy.swift.codegen.swiftmodules.SwiftSymbol import software.amazon.smithy.swift.codegen.swiftmodules.SwiftTypes import software.amazon.smithy.swift.codegen.utils.ModelFileUtils import software.amazon.smithy.swift.codegen.utils.errorShapeName @@ -83,6 +85,7 @@ class HTTPResponseBindingErrorGenerator( .map { ctx.model.expectShape(it) as StructureShape } .toSet() .sorted() + writer.addImport(SwiftSymbol.make("ClientRuntime", null, SwiftDependency.CLIENT_RUNTIME, emptyList(), listOf("SmithyReadWrite"))) writer.write("let data = try await httpResponse.data()") writer.write("let responseReader = try \$N.from(data: data)", ctx.service.readerSymbol) val noErrorWrapping = ctx.service.getTrait()?.isNoErrorWrapping ?: false diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingErrorInitGenerator.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingErrorInitGenerator.kt index 028a62c83..15a1ceba7 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingErrorInitGenerator.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingErrorInitGenerator.kt @@ -13,6 +13,7 @@ import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SectionId import software.amazon.smithy.swift.codegen.integration.httpResponse.bindingTraits.HTTPResponseTraitPayload import software.amazon.smithy.swift.codegen.integration.httpResponse.bindingTraits.HTTPResponseTraitResponseCode +import software.amazon.smithy.swift.codegen.integration.serde.struct.readerSymbol import software.amazon.smithy.swift.codegen.utils.ModelFileUtils class HTTPResponseBindingErrorInitGenerator( @@ -50,6 +51,7 @@ class HTTPResponseBindingErrorInitGenerator( errorShape, ) { if (needsReader) { + writer.addImport(ctx.service.readerSymbol) writer.write("let reader = baseError.errorBodyReader") } if (needsResponse) { diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingOutputGenerator.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingOutputGenerator.kt index 24ef7a4fe..d680f39b0 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingOutputGenerator.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/HTTPResponseBindingOutputGenerator.kt @@ -8,6 +8,7 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.StreamingTrait import software.amazon.smithy.model.traits.TimestampFormatTrait +import software.amazon.smithy.swift.codegen.SwiftDependency import software.amazon.smithy.swift.codegen.SwiftWriter import software.amazon.smithy.swift.codegen.integration.HTTPProtocolCustomizable import software.amazon.smithy.swift.codegen.integration.HttpBindingDescriptor @@ -21,6 +22,7 @@ import software.amazon.smithy.swift.codegen.integration.serde.readwrite.awsProto import software.amazon.smithy.swift.codegen.integration.serde.struct.readerSymbol import software.amazon.smithy.swift.codegen.model.hasTrait import software.amazon.smithy.swift.codegen.swiftmodules.SmithyHTTPAPITypes +import software.amazon.smithy.swift.codegen.swiftmodules.SwiftSymbol import software.amazon.smithy.swift.codegen.utils.ModelFileUtils class HTTPResponseBindingOutputGenerator( @@ -60,6 +62,7 @@ class HTTPResponseBindingOutputGenerator( writer.write("return \$N()", outputSymbol) } else { if (needsAReader(ctx, responseBindings)) { + writer.addImport(SwiftSymbol.make("ClientRuntime", null, SwiftDependency.CLIENT_RUNTIME, emptyList(), listOf("SmithyReadWrite"))) writer.write("let data = try await httpResponse.data()") writer.write("let responseReader = try \$N.from(data: data)", ctx.service.readerSymbol) writer.write("let reader = \$L", reader(ctx, op, writer)) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeDecodeGenerator.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeDecodeGenerator.kt index 094ae0fcf..9548555af 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeDecodeGenerator.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeDecodeGenerator.kt @@ -44,6 +44,7 @@ import software.amazon.smithy.swift.codegen.model.getTrait import software.amazon.smithy.swift.codegen.model.hasTrait import software.amazon.smithy.swift.codegen.model.isError import software.amazon.smithy.swift.codegen.swiftEnumCaseName +import software.amazon.smithy.swift.codegen.swiftmodules.SmithyTimestampsTypes open class MemberShapeDecodeGenerator( private val ctx: ProtocolGenerator.GenerationContext, @@ -118,10 +119,11 @@ open class MemberShapeDecodeGenerator( val memberTimestampFormatTrait = memberShape.getTrait() val swiftTimestampFormatCase = TimestampUtils.timestampFormat(ctx, memberTimestampFormatTrait, timestampShape) return writer.format( - "try \$L.\$L(format: \$L)", + "try \$L.\$L(format: \$N\$L)", reader(memberShape, false), readMethodName("readTimestamp"), - swiftTimestampFormatCase + SmithyTimestampsTypes.TimestampFormat, + swiftTimestampFormatCase, ) } diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeEncodeGenerator.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeEncodeGenerator.kt index 2092a77a6..ba53bd397 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeEncodeGenerator.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeEncodeGenerator.kt @@ -23,6 +23,7 @@ import software.amazon.smithy.swift.codegen.integration.serde.readwrite.awsProto import software.amazon.smithy.swift.codegen.integration.serde.readwrite.requestWireProtocol import software.amazon.smithy.swift.codegen.model.getTrait import software.amazon.smithy.swift.codegen.model.hasTrait +import software.amazon.smithy.swift.codegen.swiftmodules.SmithyTimestampsTypes abstract class MemberShapeEncodeGenerator( private val ctx: ProtocolGenerator.GenerationContext, @@ -79,11 +80,12 @@ abstract class MemberShapeEncodeGenerator( val memberTimestampFormatTrait = memberShape.getTrait() val swiftTimestampFormatCase = TimestampUtils.timestampFormat(ctx, memberTimestampFormatTrait, timestampShape) writer.write( - "try writer[\$L].writeTimestamp(\$L\$L, format: \$L)", + "try writer[\$L].writeTimestamp(\$L\$L, format: \$N\$L)", timestampKey, prefix, memberName, - swiftTimestampFormatCase + SmithyTimestampsTypes.TimestampFormat, + swiftTimestampFormatCase, ) } diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/readwrite/ReadingClosureUtils.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/readwrite/ReadingClosureUtils.kt index 556e6f278..9c1908cbc 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/readwrite/ReadingClosureUtils.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/readwrite/ReadingClosureUtils.kt @@ -18,6 +18,7 @@ import software.amazon.smithy.swift.codegen.integration.serde.json.TimestampUtil import software.amazon.smithy.swift.codegen.model.getTrait import software.amazon.smithy.swift.codegen.model.hasTrait import software.amazon.smithy.swift.codegen.swiftmodules.SmithyReadWriteTypes +import software.amazon.smithy.swift.codegen.swiftmodules.SmithyTimestampsTypes class ReadingClosureUtils( val ctx: ProtocolGenerator.GenerationContext, @@ -61,9 +62,10 @@ class ReadingClosureUtils( } shape is TimestampShape -> { writer.format( - "\$N(format: \$L)", + "\$N(format: \$N\$L)", SmithyReadWriteTypes.timestampReadingClosure, - TimestampUtils.timestampFormat(ctx, memberTimestampFormatTrait, shape) + SmithyTimestampsTypes.TimestampFormat, + TimestampUtils.timestampFormat(ctx, memberTimestampFormatTrait, shape), ) } shape is EnumShape || shape is IntEnumShape || shape.hasTrait() -> { diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/readwrite/WritingClosureUtils.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/readwrite/WritingClosureUtils.kt index ac236c5f8..926197439 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/readwrite/WritingClosureUtils.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/readwrite/WritingClosureUtils.kt @@ -19,6 +19,7 @@ import software.amazon.smithy.swift.codegen.integration.serde.json.TimestampUtil import software.amazon.smithy.swift.codegen.model.getTrait import software.amazon.smithy.swift.codegen.model.hasTrait import software.amazon.smithy.swift.codegen.swiftmodules.SmithyReadWriteTypes +import software.amazon.smithy.swift.codegen.swiftmodules.SmithyTimestampsTypes class WritingClosureUtils( val ctx: ProtocolGenerator.GenerationContext, @@ -69,9 +70,10 @@ class WritingClosureUtils( } shape is TimestampShape -> { writer.format( - "\$N(format: \$L)", + "\$N(format: \$N\$L)", SmithyReadWriteTypes.timestampWritingClosure, - TimestampUtils.timestampFormat(ctx, memberTimestampFormatTrait, shape) + SmithyTimestampsTypes.TimestampFormat, + TimestampUtils.timestampFormat(ctx, memberTimestampFormatTrait, shape), ) } shape is EnumShape || shape is IntEnumShape || shape.hasTrait() -> { diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/ClientRuntimeTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/ClientRuntimeTypes.kt index 957715532..51b195cab 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/ClientRuntimeTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/ClientRuntimeTypes.kt @@ -3,6 +3,8 @@ package software.amazon.smithy.swift.codegen.swiftmodules import software.amazon.smithy.codegen.core.Symbol import software.amazon.smithy.swift.codegen.SwiftDeclaration import software.amazon.smithy.swift.codegen.SwiftDependency +import software.amazon.smithy.swift.codegen.swiftmodules.ClientRuntimeTypes.Core.HttpInterceptorProvider +import software.amazon.smithy.swift.codegen.swiftmodules.ClientRuntimeTypes.Core.InterceptorProvider /** * Commonly used runtime types. Provides a single definition of a runtime symbol such that codegen isn't littered @@ -23,7 +25,7 @@ object ClientRuntimeTypes { val ContentLengthMiddleware = runtimeSymbol("ContentLengthMiddleware", SwiftDeclaration.STRUCT) val ContentTypeMiddleware = runtimeSymbol("ContentTypeMiddleware", SwiftDeclaration.STRUCT) val ContentMD5Middleware = runtimeSymbol("ContentMD5Middleware", SwiftDeclaration.STRUCT) - val DeserializeMiddleware = runtimeSymbol("DeserializeMiddleware", SwiftDeclaration.STRUCT) + val DeserializeMiddleware = runtimeSymbol("DeserializeMiddleware", SwiftDeclaration.STRUCT, emptyList(), listOf("SmithyReadWrite")) val MutateHeadersMiddleware = runtimeSymbol("MutateHeadersMiddleware", SwiftDeclaration.STRUCT) val URLHostMiddleware = runtimeSymbol("URLHostMiddleware", SwiftDeclaration.STRUCT) val URLPathMiddleware = runtimeSymbol("URLPathMiddleware", SwiftDeclaration.STRUCT) @@ -33,7 +35,7 @@ object ClientRuntimeTypes { runtimeSymbol("IdempotencyTokenMiddleware", SwiftDeclaration.STRUCT) val SignerMiddleware = runtimeSymbol("SignerMiddleware", SwiftDeclaration.STRUCT) val AuthSchemeMiddleware = runtimeSymbol("AuthSchemeMiddleware", SwiftDeclaration.STRUCT) - val BodyMiddleware = runtimeSymbol("BodyMiddleware", SwiftDeclaration.STRUCT) + val BodyMiddleware = runtimeSymbol("BodyMiddleware", SwiftDeclaration.STRUCT, emptyList(), listOf("SmithyReadWrite")) val PayloadBodyMiddleware = runtimeSymbol("PayloadBodyMiddleware", SwiftDeclaration.STRUCT) val EventStreamBodyMiddleware = runtimeSymbol("EventStreamBodyMiddleware", SwiftDeclaration.STRUCT) val BlobStreamBodyMiddleware = runtimeSymbol("BlobStreamBodyMiddleware", SwiftDeclaration.STRUCT) @@ -86,24 +88,26 @@ object ClientRuntimeTypes { val splitHeaderListValues = runtimeSymbol("splitHeaderListValues", SwiftDeclaration.FUNC) val splitHttpDateHeaderListValues = runtimeSymbol("splitHttpDateHeaderListValues", SwiftDeclaration.FUNC) val OrchestratorBuilder = runtimeSymbol("OrchestratorBuilder", SwiftDeclaration.CLASS) - val InterceptorProviders = runtimeSymbolWithoutNamespace("[ClientRuntime.InterceptorProvider]") val InterceptorProvider = runtimeSymbol("InterceptorProvider", SwiftDeclaration.PROTOCOL) - val HttpInterceptorProviders = runtimeSymbolWithoutNamespace("[ClientRuntime.HttpInterceptorProvider]") val HttpInterceptorProvider = runtimeSymbol("HttpInterceptorProvider", SwiftDeclaration.PROTOCOL) val HttpInterceptor = runtimeSymbol("HttpInterceptor", SwiftDeclaration.PROTOCOL) } -} -private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( - name, - declaration, - SwiftDependency.CLIENT_RUNTIME, - null, -) + object Composite { + val InterceptorProviders = runtimeSymbol("[ClientRuntime.InterceptorProvider]", null, listOf(InterceptorProvider)) + val HttpInterceptorProviders = runtimeSymbol("[ClientRuntime.HttpInterceptorProvider]", null, listOf(HttpInterceptorProvider)) + } +} -private fun runtimeSymbolWithoutNamespace(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( +private fun runtimeSymbol( + name: String, + declaration: SwiftDeclaration?, + additionalImports: List = emptyList(), + spiName: List = emptyList(), +): Symbol = SwiftSymbol.make( name, declaration, - null, - null, + SwiftDependency.CLIENT_RUNTIME.takeIf { additionalImports.isEmpty() }, + additionalImports, + spiName, ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyEventStreamsAPITypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyEventStreamsAPITypes.kt index d3ec28712..9e941c640 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyEventStreamsAPITypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyEventStreamsAPITypes.kt @@ -23,5 +23,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_EVENT_STREAMS_API, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyEventStreamsTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyEventStreamsTypes.kt index 425abd168..f265f2814 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyEventStreamsTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyEventStreamsTypes.kt @@ -21,5 +21,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_EVENT_STREAMS, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyFormURLTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyFormURLTypes.kt index 0fb432db2..0aa180f3f 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyFormURLTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyFormURLTypes.kt @@ -9,12 +9,17 @@ import software.amazon.smithy.swift.codegen.SwiftDeclaration import software.amazon.smithy.swift.codegen.SwiftDependency object SmithyFormURLTypes { - val Writer = runtimeSymbol("Writer", SwiftDeclaration.CLASS) + val Writer = runtimeSymbol("Writer", SwiftDeclaration.CLASS, listOf(SmithyReadWriteTypes.SmithyWriter)) } -private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( +private fun runtimeSymbol( + name: String, + declaration: SwiftDeclaration, + additionalImports: List = emptyList(), +): Symbol = SwiftSymbol.make( name, declaration, SwiftDependency.SMITHY_FORM_URL, - null, + additionalImports, + listOf("SmithyReadWrite"), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAPITypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAPITypes.kt index 74357e40f..585cd22b7 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAPITypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAPITypes.kt @@ -25,5 +25,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_HTTP_API, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAuthAPITypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAuthAPITypes.kt index f76fa44e6..aeff3d4a8 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAuthAPITypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAuthAPITypes.kt @@ -23,12 +23,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_HTTP_AUTH_API, - null, -) - -private fun runtimeSymbolWithoutNamespace(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( - name, - declaration, - null, - null, + emptyList(), + emptyList() ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAuthTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAuthTypes.kt index 5daf8bb8d..92a2157af 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAuthTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyHTTPAuthTypes.kt @@ -12,5 +12,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_HTTP_AUTH, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyIdentityTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyIdentityTypes.kt index 433bef385..a450b09fe 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyIdentityTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyIdentityTypes.kt @@ -15,5 +15,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_IDENTITY, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyJSONTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyJSONTypes.kt index a4eaa50ba..3d4a743eb 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyJSONTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyJSONTypes.kt @@ -9,13 +9,18 @@ import software.amazon.smithy.swift.codegen.SwiftDeclaration import software.amazon.smithy.swift.codegen.SwiftDependency object SmithyJSONTypes { - val Writer = runtimeSymbol("Writer", SwiftDeclaration.CLASS) - val Reader = runtimeSymbol("Reader", SwiftDeclaration.CLASS) + val Writer = runtimeSymbol("Writer", SwiftDeclaration.CLASS, listOf(SmithyReadWriteTypes.SmithyWriter)) + val Reader = runtimeSymbol("Reader", SwiftDeclaration.CLASS, listOf(SmithyReadWriteTypes.SmithyReader)) } -private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( +private fun runtimeSymbol( + name: String, + declaration: SwiftDeclaration, + additionalImports: List = emptyList(), +): Symbol = SwiftSymbol.make( name, declaration, SwiftDependency.SMITHY_JSON, - null, + additionalImports, + listOf("SmithyReadWrite"), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyReadWriteTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyReadWriteTypes.kt index e60626d15..87677cf75 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyReadWriteTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyReadWriteTypes.kt @@ -11,8 +11,10 @@ import software.amazon.smithy.swift.codegen.SwiftDependency * NOTE: Not all symbols need be added here but it doesn't hurt to define runtime symbols once. */ object SmithyReadWriteTypes { - val Document = runtimeSymbol("Document", SwiftDeclaration.ENUM) - val ReaderError = runtimeSymbol("ReaderError", SwiftDeclaration.ENUM) + val SmithyReader = runtimeSymbol("SmithyReader", SwiftDeclaration.PROTOCOL) + val SmithyWriter = runtimeSymbol("SmithyWriter", SwiftDeclaration.PROTOCOL) + val Document = runtimeSymbol("Document", SwiftDeclaration.ENUM, emptyList()) + val ReaderError = runtimeSymbol("ReaderError", SwiftDeclaration.ENUM, emptyList()) val mapWritingClosure = runtimeSymbol("mapWritingClosure", SwiftDeclaration.FUNC) val listWritingClosure = runtimeSymbol("listWritingClosure", SwiftDeclaration.FUNC) val timestampWritingClosure = runtimeSymbol("timestampWritingClosure", SwiftDeclaration.FUNC) @@ -27,9 +29,14 @@ object SmithyReadWriteTypes { val WritingClosureBox = runtimeSymbol("WritingClosureBox", SwiftDeclaration.STRUCT) } -private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( +private fun runtimeSymbol( + name: String, + declaration: SwiftDeclaration, + spiName: List = listOf("SmithyReadWrite") +): Symbol = SwiftSymbol.make( name, declaration, SwiftDependency.SMITHY_READ_WRITE, - null, + emptyList(), + spiName, ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyRetriesAPITypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyRetriesAPITypes.kt index 3d4462f4f..ebf7aec58 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyRetriesAPITypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyRetriesAPITypes.kt @@ -18,5 +18,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_RETRIES_API, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyRetriesTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyRetriesTypes.kt index bf7120467..1e31b97d2 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyRetriesTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyRetriesTypes.kt @@ -18,5 +18,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_RETRIES, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyStreamsTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyStreamsTypes.kt index de3baaef5..80243c4ea 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyStreamsTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyStreamsTypes.kt @@ -11,9 +11,10 @@ object SmithyStreamsTypes { } } -private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null, spiName: String? = null): Symbol = SwiftSymbol.make( +private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( name, declaration, SwiftDependency.SMITHY_STREAMS, - spiName, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyTimestampsTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyTimestampsTypes.kt index ee026828d..164f384ed 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyTimestampsTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyTimestampsTypes.kt @@ -10,11 +10,16 @@ import software.amazon.smithy.swift.codegen.SwiftDependency object SmithyTimestampsTypes { val TimestampFormatter = runtimeSymbol("TimestampFormatter", SwiftDeclaration.STRUCT) + val TimestampFormat = runtimeSymbol("TimestampFormat", SwiftDeclaration.ENUM) } -private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( +private fun runtimeSymbol( + name: String, + declaration: SwiftDeclaration +): Symbol = SwiftSymbol.make( name, declaration, SwiftDependency.SMITHY_TIMESTAMPS, - null, + emptyList(), + listOf("SmithyTimestamps"), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyTypes.kt index 0b4e88013..3a7ea73c8 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyTypes.kt @@ -25,5 +25,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyWaitersAPITypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyWaitersAPITypes.kt index bb56cde91..739636e80 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyWaitersAPITypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyWaitersAPITypes.kt @@ -16,5 +16,6 @@ private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SMITHY_WAITERS_API, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyXMLTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyXMLTypes.kt index b79d5ac93..a5a941ce7 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyXMLTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SmithyXMLTypes.kt @@ -5,16 +5,22 @@ package software.amazon.smithy.swift.codegen import software.amazon.smithy.codegen.core.Symbol +import software.amazon.smithy.swift.codegen.swiftmodules.SmithyReadWriteTypes import software.amazon.smithy.swift.codegen.swiftmodules.SwiftSymbol object SmithyXMLTypes { - val Writer = runtimeSymbol("Writer", SwiftDeclaration.CLASS) - val Reader = runtimeSymbol("Reader", SwiftDeclaration.CLASS) + val Writer = runtimeSymbol("Writer", SwiftDeclaration.CLASS, listOf(SmithyReadWriteTypes.SmithyWriter)) + val Reader = runtimeSymbol("Reader", SwiftDeclaration.CLASS, listOf(SmithyReadWriteTypes.SmithyReader)) } -private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( +private fun runtimeSymbol( + name: String, + declaration: SwiftDeclaration, + additionalImports: List = emptyList(), +): Symbol = SwiftSymbol.make( name, declaration, SwiftDependency.SMITHY_XML, - null, + additionalImports, + listOf("SmithyReadWrite"), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SwiftSymbol.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SwiftSymbol.kt index 612869bef..eb8736938 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SwiftSymbol.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SwiftSymbol.kt @@ -12,11 +12,13 @@ class SwiftSymbol { name: String, declaration: SwiftDeclaration?, dependency: Dependency?, - spiName: String? + additionalImports: List, + spiNames: List, ): Symbol = buildSymbol { this.name = name declaration?.let { this.setProperty("decl", it.keyword) } - spiName?.let { this.setProperty("spiName", it) } + this.setProperty("additionalImports", additionalImports) + this.setProperty("spiNames", spiNames) dependency?.let { this.namespace = it.target this.dependency(it) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SwiftTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SwiftTypes.kt index 784d3776c..166e2bc4a 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SwiftTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/SwiftTypes.kt @@ -38,5 +38,6 @@ private fun builtInSymbol(name: String, declaration: SwiftDeclaration? = null): name, declaration, SwiftDependency.SWIFT, - null, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/XCTestTypes.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/XCTestTypes.kt index ff81c000a..9a7b60f65 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/XCTestTypes.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/swiftmodules/XCTestTypes.kt @@ -13,9 +13,10 @@ object XCTestTypes { val XCTestCase = runtimeSymbol("XCTestCase") } -private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null, spiName: String? = null): Symbol = SwiftSymbol.make( +private fun runtimeSymbol(name: String, declaration: SwiftDeclaration? = null): Symbol = SwiftSymbol.make( name, declaration, SwiftDependency.NONE, - spiName, + emptyList(), + emptyList(), ) diff --git a/smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationTests.kt index 969c6e51b..1f040d881 100644 --- a/smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationTests.kt @@ -95,12 +95,12 @@ extension TimestampInputInput { static func write(value: TimestampInputInput?, to writer: SmithyJSON.Writer) throws { guard let value else { return } - try writer["dateTime"].writeTimestamp(value.dateTime, format: .dateTime) - try writer["epochSeconds"].writeTimestamp(value.epochSeconds, format: .epochSeconds) - try writer["httpDate"].writeTimestamp(value.httpDate, format: .httpDate) - try writer["inheritedTimestamp"].writeTimestamp(value.inheritedTimestamp, format: .httpDate) - try writer["normal"].writeTimestamp(value.normal, format: .epochSeconds) - try writer["timestampList"].writeList(value.timestampList, memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .dateTime), memberNodeInfo: "member", isFlattened: false) + try writer["dateTime"].writeTimestamp(value.dateTime, format: SmithyTimestamps.TimestampFormat.dateTime) + try writer["epochSeconds"].writeTimestamp(value.epochSeconds, format: SmithyTimestamps.TimestampFormat.epochSeconds) + try writer["httpDate"].writeTimestamp(value.httpDate, format: SmithyTimestamps.TimestampFormat.httpDate) + try writer["inheritedTimestamp"].writeTimestamp(value.inheritedTimestamp, format: SmithyTimestamps.TimestampFormat.httpDate) + try writer["normal"].writeTimestamp(value.normal, format: SmithyTimestamps.TimestampFormat.epochSeconds) + try writer["timestampList"].writeList(value.timestampList, memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.dateTime), memberNodeInfo: "member", isFlattened: false) } } """ @@ -117,7 +117,7 @@ extension MapInputInput { static func write(value: MapInputInput?, to writer: SmithyJSON.Writer) throws { guard let value else { return } try writer["blobMap"].writeMap(value.blobMap, valueWritingClosure: SmithyReadWrite.WritingClosures.writeData(value:to:), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) - try writer["dateMap"].writeMap(value.dateMap, valueWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .httpDate), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) + try writer["dateMap"].writeMap(value.dateMap, valueWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.httpDate), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) try writer["enumMap"].writeMap(value.enumMap, valueWritingClosure: SmithyReadWrite.WritingClosureBox().write(value:to:), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) try writer["intMap"].writeMap(value.intMap, valueWritingClosure: SmithyReadWrite.WritingClosures.writeInt(value:to:), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) try writer["structMap"].writeMap(value.structMap, valueWritingClosure: ReachableOnlyThroughMap.write(value:to:), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) @@ -229,7 +229,7 @@ extension JsonListsInput { try writer["sparseStringList"].writeList(value.sparseStringList, memberWritingClosure: SmithyReadWrite.sparseFormOf(writingClosure: SmithyReadWrite.WritingClosures.writeString(value:to:)), memberNodeInfo: "member", isFlattened: false) try writer["stringList"].writeList(value.stringList, memberWritingClosure: SmithyReadWrite.WritingClosures.writeString(value:to:), memberNodeInfo: "member", isFlattened: false) try writer["stringSet"].writeList(value.stringSet, memberWritingClosure: SmithyReadWrite.WritingClosures.writeString(value:to:), memberNodeInfo: "member", isFlattened: false) - try writer["timestampList"].writeList(value.timestampList, memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .dateTime), memberNodeInfo: "member", isFlattened: false) + try writer["timestampList"].writeList(value.timestampList, memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.dateTime), memberNodeInfo: "member", isFlattened: false) } } """ diff --git a/smithy-swift-codegen/src/test/kotlin/SwiftImportContainerTest.kt b/smithy-swift-codegen/src/test/kotlin/SwiftImportContainerTest.kt index c5ee87b87..ed6b429fe 100644 --- a/smithy-swift-codegen/src/test/kotlin/SwiftImportContainerTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/SwiftImportContainerTest.kt @@ -51,32 +51,32 @@ class SwiftImportContainerTest { @Test fun `it renders a single @_spi() declaration`() { val subject = SwiftImportContainer() - subject.addImport("MyPackage", false, "MyInternalAPI") + subject.addImport("MyPackage", false, listOf("MyInternalAPI")) assertEquals("@_spi(MyInternalAPI) import MyPackage", subject.toString()) } @Test fun `it renders a single @_spi() and @testable declaration`() { val subject = SwiftImportContainer() - subject.addImport("MyPackage", true, "MyInternalAPI") + subject.addImport("MyPackage", true, listOf("MyInternalAPI")) assertEquals("@testable @_spi(MyInternalAPI) import MyPackage", subject.toString()) } @Test fun `it renders multiple @_spi() declarations`() { val subject = SwiftImportContainer() - subject.addImport("MyPackage", false, "MyInternalAPI1") - subject.addImport("MyPackage", false, "MyInternalAPI2") + subject.addImport("MyPackage", false, listOf("MyInternalAPI1")) + subject.addImport("MyPackage", false, listOf("MyInternalAPI2")) assertEquals("@_spi(MyInternalAPI1) @_spi(MyInternalAPI2) import MyPackage", subject.toString()) } @Test fun `it deduplicates @_spi() declarations`() { val subject = SwiftImportContainer() - subject.addImport("MyPackage", false, "MyInternalAPI1") - subject.addImport("MyPackage", false, "MyInternalAPI2") - subject.addImport("MyPackage", false, "MyInternalAPI1") - subject.addImport("MyPackage", false, "MyInternalAPI2") + subject.addImport("MyPackage", false, listOf("MyInternalAPI1")) + subject.addImport("MyPackage", false, listOf("MyInternalAPI2")) + subject.addImport("MyPackage", false, listOf("MyInternalAPI1")) + subject.addImport("MyPackage", false, listOf("MyInternalAPI2")) assertEquals("@_spi(MyInternalAPI1) @_spi(MyInternalAPI2) import MyPackage", subject.toString()) } } diff --git a/smithy-swift-codegen/src/test/kotlin/UnionDecodeGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/UnionDecodeGeneratorTests.kt index 27b96f836..5986a3e9e 100644 --- a/smithy-swift-codegen/src/test/kotlin/UnionDecodeGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/UnionDecodeGeneratorTests.kt @@ -49,7 +49,7 @@ extension ExampleClientTypes.MyUnion { case let .enumvalue(enumvalue): try writer["enumValue"].write(enumvalue) case let .inheritedtimestamp(inheritedtimestamp): - try writer["inheritedTimestamp"].writeTimestamp(inheritedtimestamp, format: .httpDate) + try writer["inheritedTimestamp"].writeTimestamp(inheritedtimestamp, format: SmithyTimestamps.TimestampFormat.httpDate) case let .listvalue(listvalue): try writer["listValue"].writeList(listvalue, memberWritingClosure: SmithyReadWrite.WritingClosures.writeString(value:to:), memberNodeInfo: "member", isFlattened: false) case let .mapvalue(mapvalue): @@ -61,7 +61,7 @@ extension ExampleClientTypes.MyUnion { case let .structurevalue(structurevalue): try writer["structureValue"].write(structurevalue, with: ExampleClientTypes.GreetingWithErrorsOutput.write(value:to:)) case let .timestampvalue(timestampvalue): - try writer["timestampValue"].writeTimestamp(timestampvalue, format: .epochSeconds) + try writer["timestampValue"].writeTimestamp(timestampvalue, format: SmithyTimestamps.TimestampFormat.epochSeconds) case let .sdkUnknown(sdkUnknown): try writer["sdkUnknown"].write(sdkUnknown) } @@ -80,9 +80,9 @@ extension ExampleClientTypes.MyUnion { case "blobValue": return .blobvalue(try reader["blobValue"].read()) case "timestampValue": - return .timestampvalue(try reader["timestampValue"].readTimestamp(format: .epochSeconds)) + return .timestampvalue(try reader["timestampValue"].readTimestamp(format: SmithyTimestamps.TimestampFormat.epochSeconds)) case "inheritedTimestamp": - return .inheritedtimestamp(try reader["inheritedTimestamp"].readTimestamp(format: .httpDate)) + return .inheritedtimestamp(try reader["inheritedTimestamp"].readTimestamp(format: SmithyTimestamps.TimestampFormat.httpDate)) case "enumValue": return .enumvalue(try reader["enumValue"].read()) case "listValue": diff --git a/smithy-swift-codegen/src/test/kotlin/UnionEncodeGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/UnionEncodeGeneratorTests.kt index e5f18ec33..1fd2706b5 100644 --- a/smithy-swift-codegen/src/test/kotlin/UnionEncodeGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/UnionEncodeGeneratorTests.kt @@ -77,7 +77,7 @@ extension ExampleClientTypes.MyUnion { case let .enumvalue(enumvalue): try writer["enumValue"].write(enumvalue) case let .inheritedtimestamp(inheritedtimestamp): - try writer["inheritedTimestamp"].writeTimestamp(inheritedtimestamp, format: .httpDate) + try writer["inheritedTimestamp"].writeTimestamp(inheritedtimestamp, format: SmithyTimestamps.TimestampFormat.httpDate) case let .listvalue(listvalue): try writer["listValue"].writeList(listvalue, memberWritingClosure: SmithyReadWrite.WritingClosures.writeString(value:to:), memberNodeInfo: "member", isFlattened: false) case let .mapvalue(mapvalue): @@ -89,7 +89,7 @@ extension ExampleClientTypes.MyUnion { case let .structurevalue(structurevalue): try writer["structureValue"].write(structurevalue, with: ExampleClientTypes.GreetingWithErrorsOutput.write(value:to:)) case let .timestampvalue(timestampvalue): - try writer["timestampValue"].writeTimestamp(timestampvalue, format: .epochSeconds) + try writer["timestampValue"].writeTimestamp(timestampvalue, format: SmithyTimestamps.TimestampFormat.epochSeconds) case let .sdkUnknown(sdkUnknown): try writer["sdkUnknown"].write(sdkUnknown) } @@ -108,9 +108,9 @@ extension ExampleClientTypes.MyUnion { case "blobValue": return .blobvalue(try reader["blobValue"].read()) case "timestampValue": - return .timestampvalue(try reader["timestampValue"].readTimestamp(format: .epochSeconds)) + return .timestampvalue(try reader["timestampValue"].readTimestamp(format: SmithyTimestamps.TimestampFormat.epochSeconds)) case "inheritedTimestamp": - return .inheritedtimestamp(try reader["inheritedTimestamp"].readTimestamp(format: .httpDate)) + return .inheritedtimestamp(try reader["inheritedTimestamp"].readTimestamp(format: SmithyTimestamps.TimestampFormat.httpDate)) case "enumValue": return .enumvalue(try reader["enumValue"].read()) case "listValue": diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/ListEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/serde/xml/ListEncodeXMLGenerationTests.kt index bed848737..0d542a689 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/ListEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/serde/xml/ListEncodeXMLGenerationTests.kt @@ -153,7 +153,7 @@ extension XmlTimestampsNestedFlattenedInput { static func write(value: XmlTimestampsNestedFlattenedInput?, to writer: SmithyXML.Writer) throws { guard let value else { return } - try writer["nestedTimestampList"].writeList(value.nestedTimestampList, memberWritingClosure: SmithyReadWrite.listWritingClosure(memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .epochSeconds), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: .init("nestedMember", namespaceDef: .init(prefix: "baz", uri: "http://baz.com")), isFlattened: true) + try writer["nestedTimestampList"].writeList(value.nestedTimestampList, memberWritingClosure: SmithyReadWrite.listWritingClosure(memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: .init("nestedMember", namespaceDef: .init(prefix: "baz", uri: "http://baz.com")), isFlattened: true) } } """ diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/MapDecodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/serde/xml/MapDecodeXMLGenerationTests.kt index dc7bf8cc9..e56cd166d 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/MapDecodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/serde/xml/MapDecodeXMLGenerationTests.kt @@ -343,7 +343,7 @@ extension XmlMapsTimestampsOutput { let responseReader = try SmithyXML.Reader.from(data: data) let reader = responseReader var value = XmlMapsTimestampsOutput() - value.timestampMap = try reader["timestampMap"].readMapIfPresent(valueReadingClosure: SmithyReadWrite.timestampReadingClosure(format: .epochSeconds), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) + value.timestampMap = try reader["timestampMap"].readMapIfPresent(valueReadingClosure: SmithyReadWrite.timestampReadingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) return value } } @@ -363,7 +363,7 @@ extension XmlMapsFlattenedTimestampsOutput { let responseReader = try SmithyXML.Reader.from(data: data) let reader = responseReader var value = XmlMapsFlattenedTimestampsOutput() - value.timestampMap = try reader["timestampMap"].readMapIfPresent(valueReadingClosure: SmithyReadWrite.timestampReadingClosure(format: .epochSeconds), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: true) + value.timestampMap = try reader["timestampMap"].readMapIfPresent(valueReadingClosure: SmithyReadWrite.timestampReadingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: true) return value } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/MapEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/serde/xml/MapEncodeXMLGenerationTests.kt index 17d7fe74f..47bb0dbea 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/MapEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/serde/xml/MapEncodeXMLGenerationTests.kt @@ -273,7 +273,7 @@ extension XmlMapsTimestampsInput { static func write(value: XmlMapsTimestampsInput?, to writer: SmithyXML.Writer) throws { guard let value else { return } - try writer["timestampMap"].writeMap(value.timestampMap, valueWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .epochSeconds), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) + try writer["timestampMap"].writeMap(value.timestampMap, valueWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: false) } } """ @@ -289,7 +289,7 @@ extension XmlMapsFlattenedTimestampsInput { static func write(value: XmlMapsFlattenedTimestampsInput?, to writer: SmithyXML.Writer) throws { guard let value else { return } - try writer["timestampMap"].writeMap(value.timestampMap, valueWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .epochSeconds), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: true) + try writer["timestampMap"].writeMap(value.timestampMap, valueWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), keyNodeInfo: "key", valueNodeInfo: "value", isFlattened: true) } } """ diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampDecodeGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampDecodeGenerationTests.kt index e32a43d40..eeb9e2382 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampDecodeGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampDecodeGenerationTests.kt @@ -25,10 +25,10 @@ extension XmlTimestampsOutput { let responseReader = try SmithyXML.Reader.from(data: data) let reader = responseReader var value = XmlTimestampsOutput() - value.dateTime = try reader["dateTime"].readTimestampIfPresent(format: .dateTime) - value.epochSeconds = try reader["epochSeconds"].readTimestampIfPresent(format: .epochSeconds) - value.httpDate = try reader["httpDate"].readTimestampIfPresent(format: .httpDate) - value.normal = try reader["normal"].readTimestampIfPresent(format: .dateTime) + value.dateTime = try reader["dateTime"].readTimestampIfPresent(format: SmithyTimestamps.TimestampFormat.dateTime) + value.epochSeconds = try reader["epochSeconds"].readTimestampIfPresent(format: SmithyTimestamps.TimestampFormat.epochSeconds) + value.httpDate = try reader["httpDate"].readTimestampIfPresent(format: SmithyTimestamps.TimestampFormat.httpDate) + value.normal = try reader["normal"].readTimestampIfPresent(format: SmithyTimestamps.TimestampFormat.dateTime) return value } } @@ -48,7 +48,7 @@ extension XmlTimestampsNestedOutput { let responseReader = try SmithyXML.Reader.from(data: data) let reader = responseReader var value = XmlTimestampsNestedOutput() - value.nestedTimestampList = try reader["nestedTimestampList"].readListIfPresent(memberReadingClosure: SmithyReadWrite.listReadingClosure(memberReadingClosure: SmithyReadWrite.timestampReadingClosure(format: .epochSeconds), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: "member", isFlattened: false) + value.nestedTimestampList = try reader["nestedTimestampList"].readListIfPresent(memberReadingClosure: SmithyReadWrite.listReadingClosure(memberReadingClosure: SmithyReadWrite.timestampReadingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: "member", isFlattened: false) return value } } @@ -68,7 +68,7 @@ extension XmlTimestampsNestedHTTPDateOutput { let responseReader = try SmithyXML.Reader.from(data: data) let reader = responseReader var value = XmlTimestampsNestedHTTPDateOutput() - value.nestedTimestampList = try reader["nestedTimestampList"].readListIfPresent(memberReadingClosure: SmithyReadWrite.listReadingClosure(memberReadingClosure: SmithyReadWrite.timestampReadingClosure(format: .httpDate), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: "member", isFlattened: false) + value.nestedTimestampList = try reader["nestedTimestampList"].readListIfPresent(memberReadingClosure: SmithyReadWrite.listReadingClosure(memberReadingClosure: SmithyReadWrite.timestampReadingClosure(format: SmithyTimestamps.TimestampFormat.httpDate), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: "member", isFlattened: false) return value } } @@ -88,7 +88,7 @@ extension XmlTimestampsNestedXmlNameOutput { let responseReader = try SmithyXML.Reader.from(data: data) let reader = responseReader var value = XmlTimestampsNestedXmlNameOutput() - value.nestedTimestampList = try reader["nestedTimestampList"].readListIfPresent(memberReadingClosure: SmithyReadWrite.listReadingClosure(memberReadingClosure: SmithyReadWrite.timestampReadingClosure(format: .epochSeconds), memberNodeInfo: "nestedTag2", isFlattened: false), memberNodeInfo: "nestedTag1", isFlattened: false) + value.nestedTimestampList = try reader["nestedTimestampList"].readListIfPresent(memberReadingClosure: SmithyReadWrite.listReadingClosure(memberReadingClosure: SmithyReadWrite.timestampReadingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), memberNodeInfo: "nestedTag2", isFlattened: false), memberNodeInfo: "nestedTag1", isFlattened: false) return value } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampEncodeGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampEncodeGenerationTests.kt index 3caeaebef..bda9e17b5 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampEncodeGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampEncodeGenerationTests.kt @@ -22,10 +22,10 @@ extension XmlTimestampsInput { static func write(value: XmlTimestampsInput?, to writer: SmithyXML.Writer) throws { guard let value else { return } - try writer["dateTime"].writeTimestamp(value.dateTime, format: .dateTime) - try writer["epochSeconds"].writeTimestamp(value.epochSeconds, format: .epochSeconds) - try writer["httpDate"].writeTimestamp(value.httpDate, format: .httpDate) - try writer["normal"].writeTimestamp(value.normal, format: .dateTime) + try writer["dateTime"].writeTimestamp(value.dateTime, format: SmithyTimestamps.TimestampFormat.dateTime) + try writer["epochSeconds"].writeTimestamp(value.epochSeconds, format: SmithyTimestamps.TimestampFormat.epochSeconds) + try writer["httpDate"].writeTimestamp(value.httpDate, format: SmithyTimestamps.TimestampFormat.httpDate) + try writer["normal"].writeTimestamp(value.normal, format: SmithyTimestamps.TimestampFormat.dateTime) } } """ @@ -41,7 +41,7 @@ extension XmlTimestampsNestedInput { static func write(value: XmlTimestampsNestedInput?, to writer: SmithyXML.Writer) throws { guard let value else { return } - try writer["nestedTimestampList"].writeList(value.nestedTimestampList, memberWritingClosure: SmithyReadWrite.listWritingClosure(memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .epochSeconds), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: "member", isFlattened: false) + try writer["nestedTimestampList"].writeList(value.nestedTimestampList, memberWritingClosure: SmithyReadWrite.listWritingClosure(memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: "member", isFlattened: false) } } """ @@ -57,7 +57,7 @@ extension XmlTimestampsNestedHTTPDateInput { static func write(value: XmlTimestampsNestedHTTPDateInput?, to writer: SmithyXML.Writer) throws { guard let value else { return } - try writer["nestedTimestampList"].writeList(value.nestedTimestampList, memberWritingClosure: SmithyReadWrite.listWritingClosure(memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .httpDate), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: "member", isFlattened: false) + try writer["nestedTimestampList"].writeList(value.nestedTimestampList, memberWritingClosure: SmithyReadWrite.listWritingClosure(memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.httpDate), memberNodeInfo: "member", isFlattened: false), memberNodeInfo: "member", isFlattened: false) } } """ @@ -73,7 +73,7 @@ extension XmlTimestampsNestedXmlNameInput { static func write(value: XmlTimestampsNestedXmlNameInput?, to writer: SmithyXML.Writer) throws { guard let value else { return } - try writer["nestedTimestampList"].writeList(value.nestedTimestampList, memberWritingClosure: SmithyReadWrite.listWritingClosure(memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: .epochSeconds), memberNodeInfo: "nestedTag2", isFlattened: false), memberNodeInfo: "nestedTag1", isFlattened: false) + try writer["nestedTimestampList"].writeList(value.nestedTimestampList, memberWritingClosure: SmithyReadWrite.listWritingClosure(memberWritingClosure: SmithyReadWrite.timestampWritingClosure(format: SmithyTimestamps.TimestampFormat.epochSeconds), memberNodeInfo: "nestedTag2", isFlattened: false), memberNodeInfo: "nestedTag1", isFlattened: false) } } """ @@ -89,8 +89,8 @@ extension XmlTimestampsXmlNameInput { static func write(value: XmlTimestampsXmlNameInput?, to writer: SmithyXML.Writer) throws { guard let value else { return } - try writer["dateTime"].writeTimestamp(value.dateTime, format: .dateTime) - try writer["notNormalName"].writeTimestamp(value.normal, format: .dateTime) + try writer["dateTime"].writeTimestamp(value.dateTime, format: SmithyTimestamps.TimestampFormat.dateTime) + try writer["notNormalName"].writeTimestamp(value.normal, format: SmithyTimestamps.TimestampFormat.dateTime) } } """ diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/UnionEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/serde/xml/UnionEncodeXMLGenerationTests.kt index d29ec9b79..1e24755af 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/UnionEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/serde/xml/UnionEncodeXMLGenerationTests.kt @@ -34,7 +34,7 @@ extension RestXmlProtocolClientTypes.XmlUnionShape { case let .structvalue(structvalue): try writer["structValue"].write(structvalue, with: RestXmlProtocolClientTypes.XmlNestedUnionStruct.write(value:to:)) case let .timestampvalue(timestampvalue): - try writer["timeStampValue"].writeTimestamp(timestampvalue, format: .dateTime) + try writer["timeStampValue"].writeTimestamp(timestampvalue, format: SmithyTimestamps.TimestampFormat.dateTime) case let .unionvalue(unionvalue): try writer["unionValue"].write(unionvalue, with: RestXmlProtocolClientTypes.XmlUnionShape.write(value:to:)) case let .sdkUnknown(sdkUnknown): @@ -59,7 +59,7 @@ extension RestXmlProtocolClientTypes.XmlUnionShape { case "stringList": return .stringlist(try reader["stringList"].readList(memberReadingClosure: SmithyReadWrite.ReadingClosures.readString(from:), memberNodeInfo: "member", isFlattened: false)) case "timeStampValue": - return .timestampvalue(try reader["timeStampValue"].readTimestamp(format: .dateTime)) + return .timestampvalue(try reader["timeStampValue"].readTimestamp(format: SmithyTimestamps.TimestampFormat.dateTime)) default: return .sdkUnknown(name ?? "") }