From 08ee36dea15d462cfd5ad1f6548ec21441bc5f60 Mon Sep 17 00:00:00 2001 From: Jonas Reichert Date: Mon, 26 Sep 2022 16:34:12 +0200 Subject: [PATCH] generate samples --- docs/generators/swift5.md | 2 +- .../alamofireLibrary/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/Extensions.swift | 6 -- ...ime.swift => OpenAPIDateWithoutTime.swift} | 14 ++-- .../.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/Extensions.swift | 6 -- ...ime.swift => OpenAPIDateWithoutTime.swift} | 14 ++-- .../combineLibrary/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/Extensions.swift | 6 -- ...ime.swift => OpenAPIDateWithoutTime.swift} | 14 ++-- .../swift5/default/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/Extensions.swift | 6 -- ...ime.swift => OpenAPIDateWithoutTime.swift} | 14 ++-- .../deprecated/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../frozenEnums/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../nonPublicApi/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/Extensions.swift | 6 -- ...ime.swift => OpenAPIDateWithoutTime.swift} | 14 ++-- .../objcCompatible/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../swift5/oneOf/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../resultLibrary/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../rxswiftLibrary/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../.openapi-generator/FILES | 2 +- .../PetstoreClient/DateWithoutTime.swift | 63 ----------------- .../Sources/PetstoreClient/Extensions.swift | 6 -- .../OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../vaporLibrary/.openapi-generator/FILES | 2 +- .../PetstoreClient/DateWithoutTime.swift | 63 ----------------- .../OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ .../x-swift-hashable/.openapi-generator/FILES | 2 +- .../Classes/OpenAPIs/DateWithoutTime.swift | 63 ----------------- .../Classes/OpenAPIs/Extensions.swift | 6 -- .../OpenAPIs/OpenAPIDateWithoutTime.swift | 69 +++++++++++++++++++ 59 files changed, 826 insertions(+), 820 deletions(-) rename samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/{DateWithoutTime.swift => OpenAPIDateWithoutTime.swift} (86%) rename samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/{DateWithoutTime.swift => OpenAPIDateWithoutTime.swift} (86%) rename samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/{DateWithoutTime.swift => OpenAPIDateWithoutTime.swift} (86%) rename samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/{DateWithoutTime.swift => OpenAPIDateWithoutTime.swift} (86%) delete mode 100644 samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift rename samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/{DateWithoutTime.swift => OpenAPIDateWithoutTime.swift} (86%) delete mode 100644 samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/OpenAPIDateWithoutTime.swift delete mode 100644 samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift create mode 100644 samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift diff --git a/docs/generators/swift5.md b/docs/generators/swift5.md index ac908739b72a..1d080ac87fe4 100644 --- a/docs/generators/swift5.md +++ b/docs/generators/swift5.md @@ -78,13 +78,13 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • Character
  • Data
  • Date
  • -
  • DateWithoutTime
  • Decimal
  • Double
  • Float
  • Int
  • Int32
  • Int64
  • +
  • OpenAPIDateWithoutTime
  • String
  • URL
  • UUID
  • diff --git a/samples/client/petstore/swift5/alamofireLibrary/.openapi-generator/FILES b/samples/client/petstore/swift5/alamofireLibrary/.openapi-generator/FILES index c24a9ebd47f5..f1bd751eb1c3 100644 --- a/samples/client/petstore/swift5/alamofireLibrary/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/alamofireLibrary/.openapi-generator/FILES @@ -14,7 +14,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -59,6 +58,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift README.md diff --git a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift similarity index 86% rename from samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift rename to samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift index fc3c597c49f7..93d52871dd78 100644 --- a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -1,4 +1,4 @@ -// DateWithoutTime.swift +// OpenAPIDateWithoutTime.swift // // Generated by openapi-generator // https://openapi-generator.tech @@ -15,7 +15,7 @@ import Foundation /// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. /// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate /// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { public let wrappedDate: Date public let timezone: TimeZone @@ -40,7 +40,7 @@ public struct DateWithoutTime: Codable, Hashable, Equatable { self.init(wrappedDate: wrappedDate, timezone: timezone) } - /// Designated Initializer for `DateWithoutTime` + /// Designated Initializer for `OpenAPIDateWithoutTime` /// /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) @@ -56,8 +56,14 @@ public struct DateWithoutTime: Codable, Hashable, Equatable { } /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { + fileprivate func normalizedWrappedDate() -> Date { return wrappedDate.addingTimeInterval( Double(timezone.secondsFromGMT(for: wrappedDate))) } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } } \ No newline at end of file diff --git a/samples/client/petstore/swift5/asyncAwaitLibrary/.openapi-generator/FILES b/samples/client/petstore/swift5/asyncAwaitLibrary/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/asyncAwaitLibrary/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/asyncAwaitLibrary/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift similarity index 86% rename from samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift rename to samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift index fc3c597c49f7..93d52871dd78 100644 --- a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -1,4 +1,4 @@ -// DateWithoutTime.swift +// OpenAPIDateWithoutTime.swift // // Generated by openapi-generator // https://openapi-generator.tech @@ -15,7 +15,7 @@ import Foundation /// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. /// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate /// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { public let wrappedDate: Date public let timezone: TimeZone @@ -40,7 +40,7 @@ public struct DateWithoutTime: Codable, Hashable, Equatable { self.init(wrappedDate: wrappedDate, timezone: timezone) } - /// Designated Initializer for `DateWithoutTime` + /// Designated Initializer for `OpenAPIDateWithoutTime` /// /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) @@ -56,8 +56,14 @@ public struct DateWithoutTime: Codable, Hashable, Equatable { } /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { + fileprivate func normalizedWrappedDate() -> Date { return wrappedDate.addingTimeInterval( Double(timezone.secondsFromGMT(for: wrappedDate))) } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } } \ No newline at end of file diff --git a/samples/client/petstore/swift5/combineLibrary/.openapi-generator/FILES b/samples/client/petstore/swift5/combineLibrary/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/combineLibrary/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/combineLibrary/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift similarity index 86% rename from samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift rename to samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift index fc3c597c49f7..93d52871dd78 100644 --- a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -1,4 +1,4 @@ -// DateWithoutTime.swift +// OpenAPIDateWithoutTime.swift // // Generated by openapi-generator // https://openapi-generator.tech @@ -15,7 +15,7 @@ import Foundation /// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. /// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate /// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { public let wrappedDate: Date public let timezone: TimeZone @@ -40,7 +40,7 @@ public struct DateWithoutTime: Codable, Hashable, Equatable { self.init(wrappedDate: wrappedDate, timezone: timezone) } - /// Designated Initializer for `DateWithoutTime` + /// Designated Initializer for `OpenAPIDateWithoutTime` /// /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) @@ -56,8 +56,14 @@ public struct DateWithoutTime: Codable, Hashable, Equatable { } /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { + fileprivate func normalizedWrappedDate() -> Date { return wrappedDate.addingTimeInterval( Double(timezone.secondsFromGMT(for: wrappedDate))) } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } } \ No newline at end of file diff --git a/samples/client/petstore/swift5/default/.openapi-generator/FILES b/samples/client/petstore/swift5/default/.openapi-generator/FILES index e8a32531383c..9c21c3f9431a 100644 --- a/samples/client/petstore/swift5/default/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/default/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -68,6 +67,7 @@ PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift PetstoreClient/Classes/OpenAPIs/Models/XmlItem.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift similarity index 86% rename from samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift rename to samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift index fc3c597c49f7..93d52871dd78 100644 --- a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -1,4 +1,4 @@ -// DateWithoutTime.swift +// OpenAPIDateWithoutTime.swift // // Generated by openapi-generator // https://openapi-generator.tech @@ -15,7 +15,7 @@ import Foundation /// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. /// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate /// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { public let wrappedDate: Date public let timezone: TimeZone @@ -40,7 +40,7 @@ public struct DateWithoutTime: Codable, Hashable, Equatable { self.init(wrappedDate: wrappedDate, timezone: timezone) } - /// Designated Initializer for `DateWithoutTime` + /// Designated Initializer for `OpenAPIDateWithoutTime` /// /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) @@ -56,8 +56,14 @@ public struct DateWithoutTime: Codable, Hashable, Equatable { } /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { + fileprivate func normalizedWrappedDate() -> Date { return wrappedDate.addingTimeInterval( Double(timezone.secondsFromGMT(for: wrappedDate))) } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } } \ No newline at end of file diff --git a/samples/client/petstore/swift5/deprecated/.openapi-generator/FILES b/samples/client/petstore/swift5/deprecated/.openapi-generator/FILES index c7c05ab778f8..8465191975a5 100644 --- a/samples/client/petstore/swift5/deprecated/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/deprecated/.openapi-generator/FILES @@ -10,7 +10,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -21,6 +20,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Order.swift PetstoreClient/Classes/OpenAPIs/Models/Pet.swift PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/frozenEnums/.openapi-generator/FILES b/samples/client/petstore/swift5/frozenEnums/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/frozenEnums/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/frozenEnums/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/nonPublicApi/.openapi-generator/FILES b/samples/client/petstore/swift5/nonPublicApi/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/nonPublicApi/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/nonPublicApi/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Extensions.swift index c51a3bef5eb4..c7e2df56bc9d 100644 --- a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift similarity index 86% rename from samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift rename to samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift index 6c68e4533ecf..f464c258b93c 100644 --- a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -1,4 +1,4 @@ -// DateWithoutTime.swift +// OpenAPIDateWithoutTime.swift // // Generated by openapi-generator // https://openapi-generator.tech @@ -15,7 +15,7 @@ import Foundation /// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. /// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate /// can be used safely. -internal struct DateWithoutTime: Codable, Hashable, Equatable { +internal struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { internal let wrappedDate: Date internal let timezone: TimeZone @@ -40,7 +40,7 @@ internal struct DateWithoutTime: Codable, Hashable, Equatable { self.init(wrappedDate: wrappedDate, timezone: timezone) } - /// Designated Initializer for `DateWithoutTime` + /// Designated Initializer for `OpenAPIDateWithoutTime` /// /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) @@ -56,8 +56,14 @@ internal struct DateWithoutTime: Codable, Hashable, Equatable { } /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { + fileprivate func normalizedWrappedDate() -> Date { return wrappedDate.addingTimeInterval( Double(timezone.secondsFromGMT(for: wrappedDate))) } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } } \ No newline at end of file diff --git a/samples/client/petstore/swift5/objcCompatible/.openapi-generator/FILES b/samples/client/petstore/swift5/objcCompatible/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/objcCompatible/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/objcCompatible/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/oneOf/.openapi-generator/FILES b/samples/client/petstore/swift5/oneOf/.openapi-generator/FILES index 134b51162ac2..9a0112d2db99 100644 --- a/samples/client/petstore/swift5/oneOf/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/oneOf/.openapi-generator/FILES @@ -8,7 +8,6 @@ PetstoreClient/Classes/OpenAPIs/APIs.swift PetstoreClient/Classes/OpenAPIs/APIs/DefaultAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -16,6 +15,7 @@ PetstoreClient/Classes/OpenAPIs/Models.swift PetstoreClient/Classes/OpenAPIs/Models/Apple.swift PetstoreClient/Classes/OpenAPIs/Models/Banana.swift PetstoreClient/Classes/OpenAPIs/Models/Fruit.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/promisekitLibrary/.openapi-generator/FILES b/samples/client/petstore/swift5/promisekitLibrary/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/promisekitLibrary/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/promisekitLibrary/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift index c15832a798b4..af90bc2ac5dc 100644 --- a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -92,12 +92,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/readonlyProperties/.openapi-generator/FILES b/samples/client/petstore/swift5/readonlyProperties/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/readonlyProperties/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/readonlyProperties/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/resultLibrary/.openapi-generator/FILES b/samples/client/petstore/swift5/resultLibrary/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/resultLibrary/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/resultLibrary/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/rxswiftLibrary/.openapi-generator/FILES b/samples/client/petstore/swift5/rxswiftLibrary/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/rxswiftLibrary/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/rxswiftLibrary/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 604df4795f47..f7d0efdcb74e 100644 --- a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/urlsessionLibrary/.openapi-generator/FILES b/samples/client/petstore/swift5/urlsessionLibrary/.openapi-generator/FILES index 56972f190379..4f7a5100412c 100644 --- a/samples/client/petstore/swift5/urlsessionLibrary/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/urlsessionLibrary/.openapi-generator/FILES @@ -14,7 +14,6 @@ Sources/PetstoreClient/APIs/StoreAPI.swift Sources/PetstoreClient/APIs/UserAPI.swift Sources/PetstoreClient/CodableHelper.swift Sources/PetstoreClient/Configuration.swift -Sources/PetstoreClient/DateWithoutTime.swift Sources/PetstoreClient/Extensions.swift Sources/PetstoreClient/JSONDataEncoding.swift Sources/PetstoreClient/JSONEncodingHelper.swift @@ -59,6 +58,7 @@ Sources/PetstoreClient/Models/Tag.swift Sources/PetstoreClient/Models/TypeHolderDefault.swift Sources/PetstoreClient/Models/TypeHolderExample.swift Sources/PetstoreClient/Models/User.swift +Sources/PetstoreClient/OpenAPIDateWithoutTime.swift Sources/PetstoreClient/OpenISO8601DateFormatter.swift Sources/PetstoreClient/SynchronizedDictionary.swift Sources/PetstoreClient/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/DateWithoutTime.swift b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Extensions.swift b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Extensions.swift +++ b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/vaporLibrary/.openapi-generator/FILES b/samples/client/petstore/swift5/vaporLibrary/.openapi-generator/FILES index db75bfb90b53..bf06055ea9ac 100644 --- a/samples/client/petstore/swift5/vaporLibrary/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/vaporLibrary/.openapi-generator/FILES @@ -10,7 +10,6 @@ Sources/PetstoreClient/APIs/PetAPI.swift Sources/PetstoreClient/APIs/StoreAPI.swift Sources/PetstoreClient/APIs/UserAPI.swift Sources/PetstoreClient/Configuration.swift -Sources/PetstoreClient/DateWithoutTime.swift Sources/PetstoreClient/Extensions.swift Sources/PetstoreClient/Models/AdditionalPropertiesAnyType.swift Sources/PetstoreClient/Models/AdditionalPropertiesArray.swift @@ -62,6 +61,7 @@ Sources/PetstoreClient/Models/TypeHolderDefault.swift Sources/PetstoreClient/Models/TypeHolderExample.swift Sources/PetstoreClient/Models/User.swift Sources/PetstoreClient/Models/XmlItem.swift +Sources/PetstoreClient/OpenAPIDateWithoutTime.swift Sources/PetstoreClient/OpenISO8601DateFormatter.swift docs/AdditionalPropertiesAnyType.md docs/AdditionalPropertiesArray.md diff --git a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/DateWithoutTime.swift b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/vaporLibrary/Sources/PetstoreClient/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file diff --git a/samples/client/petstore/swift5/x-swift-hashable/.openapi-generator/FILES b/samples/client/petstore/swift5/x-swift-hashable/.openapi-generator/FILES index 45aedb1d502a..002bc0e20d24 100644 --- a/samples/client/petstore/swift5/x-swift-hashable/.openapi-generator/FILES +++ b/samples/client/petstore/swift5/x-swift-hashable/.openapi-generator/FILES @@ -13,7 +13,6 @@ PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift PetstoreClient/Classes/OpenAPIs/CodableHelper.swift PetstoreClient/Classes/OpenAPIs/Configuration.swift -PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/Extensions.swift PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift @@ -58,6 +57,7 @@ PetstoreClient/Classes/OpenAPIs/Models/Tag.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift PetstoreClient/Classes/OpenAPIs/Models/User.swift +PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift diff --git a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift deleted file mode 100644 index fc3c597c49f7..000000000000 --- a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/DateWithoutTime.swift +++ /dev/null @@ -1,63 +0,0 @@ -// DateWithoutTime.swift -// -// Generated by openapi-generator -// https://openapi-generator.tech -// - -import Foundation - -/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API -/// -/// This type is used as a representation for openapi specs `date` format which does not contain -/// time information as opposed to the `date-time` format. Although it internally uses `Date` for -/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. -/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add -/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. -/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate -/// can be used safely. -public struct DateWithoutTime: Codable, Hashable, Equatable { - public let wrappedDate: Date - public let timezone: TimeZone - - public enum CodingKeys: CodingKey, CaseIterable { - case wrappedDate - case timezone - } - - /// On decoding ISO8601 timezone is assumed - public init(from decoder: Decoder) throws { - let container = try decoder.singleValueContainer() - self.wrappedDate = try container.decode(Date.self) - self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone - } - - /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers - public init?(wrappedDate: Date?, timezone: TimeZone = .current) { - guard let wrappedDate = wrappedDate else { - return nil - } - - self.init(wrappedDate: wrappedDate, timezone: timezone) - } - - /// Designated Initializer for `DateWithoutTime` - /// - /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware - // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) - public init(wrappedDate: Date, timezone: TimeZone) { - self.wrappedDate = wrappedDate - self.timezone = timezone - } - - /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone - public func encode(to encoder: Encoder) throws { - var container = encoder.singleValueContainer() - try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) - } - - /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone - internal func normalizedWrappedDate() -> Date { - return wrappedDate.addingTimeInterval( - Double(timezone.secondsFromGMT(for: wrappedDate))) - } -} \ No newline at end of file diff --git a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/Extensions.swift b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/Extensions.swift index 5fceb90be830..0b17438a7c87 100644 --- a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -91,12 +91,6 @@ extension Date: JSONEncodable { } } -extension DateWithoutTime: JSONEncodable { - func encodeToJSON() -> Any { - return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) - } -} - extension JSONEncodable where Self: Encodable { func encodeToJSON() -> Any { guard let data = try? CodableHelper.jsonEncoder.encode(self) else { diff --git a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift new file mode 100644 index 000000000000..93d52871dd78 --- /dev/null +++ b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/OpenAPIDateWithoutTime.swift @@ -0,0 +1,69 @@ +// OpenAPIDateWithoutTime.swift +// +// Generated by openapi-generator +// https://openapi-generator.tech +// + +import Foundation + +/// Represents a date without time information (e.g. a birthday) for transmission from and to a REST API +/// +/// This type is used as a representation for openapi specs `date` format which does not contain +/// time information as opposed to the `date-time` format. Although it internally uses `Date` for +/// (de-)serialization as well the generator needs to be able to distinguish between the two formats. +/// - note: As `Date` is agnostic to timezones (and calendars), timezone information is needed to be able to add +/// an appropriate padding in order to transform to GMT+0 which is the assumed timezone in ISO 8601. +/// When decoding, GMT+0 can be assumed (again: ISO8601) so there is no padding necessary and wrappedDate +/// can be used safely. +public struct OpenAPIDateWithoutTime: Codable, Hashable, Equatable { + public let wrappedDate: Date + public let timezone: TimeZone + + public enum CodingKeys: CodingKey, CaseIterable { + case wrappedDate + case timezone + } + + /// On decoding ISO8601 timezone is assumed + public init(from decoder: Decoder) throws { + let container = try decoder.singleValueContainer() + self.wrappedDate = try container.decode(Date.self) + self.timezone = OpenISO8601DateFormatter.withoutTime.timeZone + } + + /// Convenience Initializer which is useful when dealing with optionals a lot like e.g. in API mappers + public init?(wrappedDate: Date?, timezone: TimeZone = .current) { + guard let wrappedDate = wrappedDate else { + return nil + } + + self.init(wrappedDate: wrappedDate, timezone: timezone) + } + + /// Designated Initializer for `OpenAPIDateWithoutTime` + /// + /// Since usually `Date`s without time components - as e.g. birthdays - are created Calendar- and timezone-aware + // it is important to also provide a timezone so that the generator is able to normalize the supplied Date to ISO8601 (GMT+0) + public init(wrappedDate: Date, timezone: TimeZone) { + self.wrappedDate = wrappedDate + self.timezone = timezone + } + + /// Only the wrappedDate is encoded normalized to GMT+0 with an offset derived from the supplied Timezone + public func encode(to encoder: Encoder) throws { + var container = encoder.singleValueContainer() + try container.encode(OpenISO8601DateFormatter.withoutTime.string(from: normalizedWrappedDate())) + } + + /// Normalizes the wrappedDate to GMT+0 according to the supplied timezone + fileprivate func normalizedWrappedDate() -> Date { + return wrappedDate.addingTimeInterval( + Double(timezone.secondsFromGMT(for: wrappedDate))) + } +} + +extension OpenAPIDateWithoutTime: JSONEncodable { + func encodeToJSON() -> Any { + return OpenISO8601DateFormatter.withoutTime.string(from: self.normalizedWrappedDate()) + } +} \ No newline at end of file