From 4beee6c8c477b818071926b188c14be7d750e2f8 Mon Sep 17 00:00:00 2001 From: Jonas Reichert <75073818+Jonas1893@users.noreply.github.com> Date: Wed, 5 Oct 2022 14:30:33 +0200 Subject: [PATCH] [swift5] adds configuration of response success ranges (#13598) * add successfulCodeRange to configuration * generate samples --- .../src/main/resources/swift5/Configuration.mustache | 8 ++++++-- .../src/main/resources/swift5/Extensions.mustache | 2 +- .../libraries/alamofire/AlamofireImplementations.mustache | 4 ++-- .../Classes/OpenAPIs/AlamofireImplementations.swift | 4 ++-- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 6 +++++- .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- .../Sources/PetstoreClient/Configuration.swift | 4 ++++ .../Sources/PetstoreClient/Extensions.swift | 2 +- .../PetstoreClient/Classes/OpenAPIs/Configuration.swift | 4 ++++ .../PetstoreClient/Classes/OpenAPIs/Extensions.swift | 2 +- 34 files changed, 87 insertions(+), 23 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache b/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache index 9ff02499b8c..0f3013e792e 100644 --- a/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache +++ b/modules/openapi-generator/src/main/resources/swift5/Configuration.mustache @@ -21,7 +21,11 @@ extension {{projectName}}API { // This value is used to configure the date formatter that is used to serialize dates into JSON format. // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") - {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"{{/useVapor}}{{#useAlamofire}} + {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static var successfulStatusCodeRange: Range = 200..<300{{/useVapor}}{{#useAlamofire}} /// ResponseSerializer that will be used by the generator for `Data` responses /// /// If unchanged, Alamofires default `DataResponseSerializer` will be used. @@ -33,7 +37,7 @@ extension {{projectName}}API { } {{#useAlamofire}} -/// Type-erased response serializer +/// Type-erased ResponseSerializer /// /// This is needed in order to use `ResponseSerializer` as a Type in `Configuration`. Obsolete with `any` keyword in Swift >= 5.7 {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} struct AnyResponseSerializer: ResponseSerializer { diff --git a/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache b/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache index b18821ae14b..22b69165927 100644 --- a/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache +++ b/modules/openapi-generator/src/main/resources/swift5/Extensions.mustache @@ -190,7 +190,7 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } }{{/useVapor}}{{#usePromiseKit}} diff --git a/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache b/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache index 27e1355d5cb..dd936dd68fb 100644 --- a/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache +++ b/modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache @@ -165,7 +165,7 @@ private var managerStore = SynchronizedDictionary() managerStore[managerId] = nil } - let validatedRequest = request.validate() + let validatedRequest = request.validate(statusCode: Configuration.successfulStatusCodeRange) switch T.self { case is Void.Type: @@ -259,7 +259,7 @@ private var managerStore = SynchronizedDictionary() managerStore[managerId] = nil } - let validatedRequest = request.validate() + let validatedRequest = request.validate(statusCode: Configuration.successfulStatusCodeRange) switch T.self { case is String.Type: diff --git a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift index f8e2688bd18..bc4759a803f 100644 --- a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift +++ b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift @@ -165,7 +165,7 @@ open class AlamofireRequestBuilder: RequestBuilder { managerStore[managerId] = nil } - let validatedRequest = request.validate() + let validatedRequest = request.validate(statusCode: Configuration.successfulStatusCodeRange) switch T.self { case is Void.Type: @@ -259,7 +259,7 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuild managerStore[managerId] = nil } - let validatedRequest = request.validate() + let validatedRequest = request.validate(statusCode: Configuration.successfulStatusCodeRange) switch T.self { case is String.Type: diff --git a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift index c1a321c804a..def40552f74 100644 --- a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -13,6 +13,10 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 /// ResponseSerializer that will be used by the generator for `Data` responses /// /// If unchanged, Alamofires default `DataResponseSerializer` will be used. @@ -23,7 +27,7 @@ open class Configuration { public static var stringResponseSerializer: AnyResponseSerializer = AnyResponseSerializer(StringResponseSerializer()) } -/// Type-erased response serializer +/// Type-erased ResponseSerializer /// /// This is needed in order to use `ResponseSerializer` as a Type in `Configuration`. Obsolete with `any` keyword in Swift >= 5.7 public struct AnyResponseSerializer: ResponseSerializer { 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/alamofireLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/asyncAwaitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/frozenEnums/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 5be96e4e203..84d878ff6c2 100644 --- a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ internal class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") internal static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + internal static var successfulStatusCodeRange: Range = 200..<300 } 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 c7e2df56bc9..8a64d78d3c7 100644 --- a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/oneOf/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 af90bc2ac5d..cf9a2470b85 100644 --- a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -189,7 +189,7 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 f7d0efdcb74..f82084988de 100644 --- a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift +++ b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Extensions.swift @@ -102,6 +102,6 @@ extension JSONEncodable where Self: Encodable { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Configuration.swift b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Configuration.swift index c5224b89eb1..399495722c6 100644 --- a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Configuration.swift +++ b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Configuration.swift @@ -16,6 +16,10 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } } diff --git a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Extensions.swift b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Extensions.swift index 0b17438a7c8..f78d206e330 100644 --- a/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Extensions.swift +++ b/samples/client/petstore/swift5/urlsessionLibrary/Sources/PetstoreClient/Extensions.swift @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } } diff --git a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/Configuration.swift b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/Configuration.swift index 8fb05331889..03789f4b492 100644 --- a/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/Configuration.swift +++ b/samples/client/petstore/swift5/x-swift-hashable/PetstoreClient/Classes/OpenAPIs/Configuration.swift @@ -12,4 +12,8 @@ open class Configuration { // You must set it prior to encoding any dates, and it will only be read once. @available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.") public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" + /// Configures the range of HTTP status codes that will result in a successful response + /// + /// If a HTTP status code is outside of this range the response will be interpreted as failed. + public static var successfulStatusCodeRange: Range = 200..<300 } 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 0b17438a7c8..f78d206e330 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 @@ -188,6 +188,6 @@ extension KeyedDecodingContainerProtocol { extension HTTPURLResponse { var isStatusCodeSuccessful: Bool { - return (200 ..< 300).contains(statusCode) + return Configuration.successfulStatusCodeRange.contains(statusCode) } }