[swift5][client] make AnyCodable optional (#9479)

* [swift5][client] make AnyCodable usage optional

* [swift5][client] update sample projects
This commit is contained in:
Bruno Coelho
2021-05-18 16:47:26 +01:00
committed by GitHub
parent 6b5794df9d
commit f48311dac4
441 changed files with 908 additions and 26 deletions

View File

@@ -5,7 +5,9 @@
//
import Foundation
import AnyCodable{{#usePromiseKit}}
#if canImport(AnyCodable)
import AnyCodable
#endif{{#usePromiseKit}}
import PromiseKit{{/usePromiseKit}}
extension Bool: JSONEncodable {
@@ -201,6 +203,7 @@ extension RequestBuilder {
}
}{{/usePromiseKit}}
#if canImport(AnyCodable)
extension AnyCodable: Hashable {
public func hash(into hasher: inout Hasher) {
switch value {
@@ -240,4 +243,5 @@ extension AnyCodable: Hashable {
hasher.combine(0)
}
}
}
}
#endif

View File

@@ -11,8 +11,8 @@ targets:
settings:
APPLICATION_EXTENSION_API_ONLY: true
scheme: {}
{{#useAlamofire}}dependencies:{{/useAlamofire}}{{^useAlamofire}}{{#useRxSwift}}dependencies:{{/useRxSwift}}{{/useAlamofire}}{{^useAlamofire}}{{^useRxSwift}}{{#usePromiseKit}}dependencies:{{/usePromiseKit}}{{/useRxSwift}}{{/useAlamofire}}{{#useAlamofire}}
dependencies:
- carthage: AnyCodable{{#useAlamofire}}
- carthage: Alamofire{{/useAlamofire}}{{#useRxSwift}}
- carthage: RxSwift{{/useRxSwift}}{{#usePromiseKit}}
- carthage: PromiseKit{{/usePromiseKit}}
- carthage: AnyCodable

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
{{#description}}
/** {{description}} */{{/description}}{{#isDeprecated}}

View File

@@ -5,7 +5,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
extension Bool: JSONEncodable {
func encodeToJSON() -> Any { return self as Any }
@@ -185,6 +187,7 @@ extension HTTPURLResponse {
}
}
#if canImport(AnyCodable)
extension AnyCodable: Hashable {
public func hash(into hasher: inout Hasher) {
switch value {
@@ -224,4 +227,5 @@ extension AnyCodable: Hashable {
hasher.combine(0)
}
}
}
}
#endif

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesClass: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Animal: Codable, Hashable {

View File

@@ -6,6 +6,8 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public typealias AnimalFarm = [Animal]

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ApiResponse: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ArrayOfArrayOfNumberOnly: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ArrayOfNumberOnly: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ArrayTest: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Capitalization: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Cat: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct CatAllOf: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Category: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Model for testing model with \"_class\" property */
public struct ClassModel: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Client: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Dog: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct DogAllOf: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct EnumArrays: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public enum EnumClass: String, Codable, CaseIterable {
case abc = "_abc"

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct EnumTest: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Must be named `File` for test. */
public struct File: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct FileSchemaTestClass: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct FormatTest: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct HasOnlyReadOnly: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct List: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct MapTest: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Model for testing model name starting with number */
public struct Model200Response: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Model for testing model name same as property name */
public struct Name: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct NumberOnly: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Order: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct OuterComposite: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public enum OuterEnum: String, Codable, CaseIterable {
case placed = "placed"

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Pet: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ReadOnlyFirst: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Model for testing reserved words */
public struct Return: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct SpecialModelName: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct StringBooleanMap: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Tag: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct TypeHolderDefault: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct TypeHolderExample: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct User: Codable, Hashable {

View File

@@ -12,5 +12,5 @@ targets:
APPLICATION_EXTENSION_API_ONLY: true
scheme: {}
dependencies:
- carthage: Alamofire
- carthage: AnyCodable
- carthage: Alamofire

View File

@@ -5,7 +5,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
extension Bool: JSONEncodable {
func encodeToJSON() -> Any { return self as Any }
@@ -185,6 +187,7 @@ extension HTTPURLResponse {
}
}
#if canImport(AnyCodable)
extension AnyCodable: Hashable {
public func hash(into hasher: inout Hasher) {
switch value {
@@ -224,4 +227,5 @@ extension AnyCodable: Hashable {
hasher.combine(0)
}
}
}
}
#endif

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesClass: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Animal: Codable, Hashable {

View File

@@ -6,6 +6,8 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public typealias AnimalFarm = [Animal]

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ApiResponse: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ArrayOfArrayOfNumberOnly: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ArrayOfNumberOnly: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ArrayTest: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Capitalization: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Cat: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct CatAllOf: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Category: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Model for testing model with \"_class\" property */
public struct ClassModel: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Client: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Dog: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct DogAllOf: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct EnumArrays: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public enum EnumClass: String, Codable, CaseIterable {
case abc = "_abc"

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct EnumTest: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Must be named `File` for test. */
public struct File: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct FileSchemaTestClass: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct FormatTest: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct HasOnlyReadOnly: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct List: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct MapTest: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Model for testing model name starting with number */
public struct Model200Response: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Model for testing model name same as property name */
public struct Name: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct NumberOnly: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Order: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct OuterComposite: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public enum OuterEnum: String, Codable, CaseIterable {
case placed = "placed"

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Pet: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ReadOnlyFirst: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
/** Model for testing reserved words */
public struct Return: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct SpecialModelName: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct StringBooleanMap: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Tag: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct TypeHolderDefault: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct TypeHolderExample: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct User: Codable, Hashable {

View File

@@ -11,5 +11,5 @@ targets:
settings:
APPLICATION_EXTENSION_API_ONLY: true
scheme: {}
dependencies:
- carthage: AnyCodable

View File

@@ -5,7 +5,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
extension Bool: JSONEncodable {
func encodeToJSON() -> Any { return self as Any }
@@ -185,6 +187,7 @@ extension HTTPURLResponse {
}
}
#if canImport(AnyCodable)
extension AnyCodable: Hashable {
public func hash(into hasher: inout Hasher) {
switch value {
@@ -224,4 +227,5 @@ extension AnyCodable: Hashable {
hasher.combine(0)
}
}
}
}
#endif

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesAnyType: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesArray: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesBoolean: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesClass: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesInteger: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesNumber: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesObject: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct AdditionalPropertiesString: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct Animal: Codable, Hashable {

View File

@@ -6,6 +6,8 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public typealias AnimalFarm = [Animal]

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ApiResponse: Codable, Hashable {

View File

@@ -6,7 +6,9 @@
//
import Foundation
#if canImport(AnyCodable)
import AnyCodable
#endif
public struct ArrayOfArrayOfNumberOnly: Codable, Hashable {

Some files were not shown because too many files have changed in this diff Show More