Skip to content

Commit 50cca17

Browse files
committed
[Swift6] Remove QueryStringEncodable for models
1 parent 28daa68 commit 50cca17

File tree

413 files changed

+442
-610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

413 files changed

+442
-610
lines changed

modules/openapi-generator/src/main/resources/swift6/Extensions.mustache

+3-15
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import FoundationNetworking
1111
@preconcurrency import PromiseKit{{/usePromiseKit}}{{#useVapor}}
1212
import Vapor{{/useVapor}}{{^useVapor}}
1313

14-
extension QueryStringEncodable {
15-
@_disfavoredOverload
16-
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
17-
}
18-
1914
extension Bool: QueryStringEncodable {
2015
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
2116
}
@@ -57,7 +52,9 @@ extension UUID: QueryStringEncodable {
5752
}
5853

5954
extension RawRepresentable where RawValue: QueryStringEncodable {
60-
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: rawValue) }
55+
func encodeToQueryString(codableHelper: CodableHelper) -> String {
56+
rawValue.encodeToQueryString(codableHelper: codableHelper)
57+
}
6158
}
6259

6360
private func encodeIfPossible<T>(_ object: T, codableHelper: CodableHelper) -> String {
@@ -100,15 +97,6 @@ extension Date: QueryStringEncodable {
10097
func encodeToQueryString(codableHelper: CodableHelper) -> String {
10198
return codableHelper.dateFormatter.string(from: self)
10299
}
103-
}
104-
105-
extension QueryStringEncodable where Self: Encodable {
106-
func encodeToQueryString(codableHelper: CodableHelper) -> String {
107-
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
108-
fatalError("Could not encode to json: \(self)")
109-
}
110-
return data.encodeToQueryString(codableHelper: codableHelper)
111-
}
112100
}{{/useVapor}}{{#generateModelAdditionalProperties}}
113101

114102
extension String: @retroactive CodingKey {

modules/openapi-generator/src/main/resources/swift6/modelObject.mustache

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{{classname}}}: {{^useClasses}}Sendable, {{/useClasses}}{{#useClasses}}{{#readonlyProperties}}@unchecked Sendable, {{/readonlyProperties}}{{/useClasses}}{{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{#useJsonEncodable}}, QueryStringEncodable{{/useJsonEncodable}}{{/useVapor}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
2-
{{/objcCompatible}}{{#objcCompatible}}@objcMembers {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable{{#useJsonEncodable}}, QueryStringEncodable{{/useJsonEncodable}} {
1+
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{{classname}}}: {{^useClasses}}Sendable, {{/useClasses}}{{#useClasses}}{{#readonlyProperties}}@unchecked Sendable, {{/readonlyProperties}}{{/useClasses}}{{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{/useVapor}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
2+
{{/objcCompatible}}{{#objcCompatible}}@objcMembers {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable {
33
{{/objcCompatible}}
44

55
{{#allVars}}

modules/openapi-generator/src/main/resources/swift6/modelOneOf.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{classname}}: {{^useClasses}}Sendable, {{/useClasses}}{{#useClasses}}{{#readonlyProperties}}Sendable, {{/readonlyProperties}}{{/useClasses}}{{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{#useJsonEncodable}}, QueryStringEncodable{{/useJsonEncodable}}{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}}{{/useVapor}} {
1+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum {{classname}}: {{^useClasses}}Sendable, {{/useClasses}}{{#useClasses}}{{#readonlyProperties}}Sendable, {{/readonlyProperties}}{{/useClasses}}{{#useVapor}}Content{{/useVapor}}{{^useVapor}}Codable{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}}{{/useVapor}} {
22
{{#oneOf}}
33
case type{{#transformArrayType}}{{.}}{{/transformArrayType}}({{.}})
44
{{/oneOf}}

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Infrastructure/Extensions.swift

+3-15
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import Foundation
99
import FoundationNetworking
1010
#endif
1111

12-
extension QueryStringEncodable {
13-
@_disfavoredOverload
14-
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
15-
}
16-
1712
extension Bool: QueryStringEncodable {
1813
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: self) }
1914
}
@@ -55,7 +50,9 @@ extension UUID: QueryStringEncodable {
5550
}
5651

5752
extension RawRepresentable where RawValue: QueryStringEncodable {
58-
func encodeToQueryString(codableHelper: CodableHelper) -> String { String(describing: rawValue) }
53+
func encodeToQueryString(codableHelper: CodableHelper) -> String {
54+
rawValue.encodeToQueryString(codableHelper: codableHelper)
55+
}
5956
}
6057

6158
private func encodeIfPossible<T>(_ object: T, codableHelper: CodableHelper) -> String {
@@ -100,15 +97,6 @@ extension Date: QueryStringEncodable {
10097
}
10198
}
10299

103-
extension QueryStringEncodable where Self: Encodable {
104-
func encodeToQueryString(codableHelper: CodableHelper) -> String {
105-
guard let data = try? codableHelper.jsonEncoder.encode(self) else {
106-
fatalError("Could not encode to json: \(self)")
107-
}
108-
return data.encodeToQueryString(codableHelper: codableHelper)
109-
}
110-
}
111-
112100
extension String: @retroactive CodingKey {
113101

114102
public var stringValue: String {

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/AdditionalPropertiesClass.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct AdditionalPropertiesClass: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct AdditionalPropertiesClass: Sendable, Codable, Hashable {
1111

1212
public var mapString: [String: String]?
1313
public var mapMapString: [String: [String: String]]?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Animal.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Animal: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Animal: Sendable, Codable, Hashable {
1111

1212
public var className: String
1313
public var color: String? = "red"

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/ApiResponse.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct ApiResponse: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct ApiResponse: Sendable, Codable, Hashable {
1111

1212
public var code: Int?
1313
public var type: String?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/ArrayOfArrayOfNumberOnly.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct ArrayOfArrayOfNumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct ArrayOfArrayOfNumberOnly: Sendable, Codable, Hashable {
1111

1212
public var arrayArrayNumber: [[Double]]?
1313

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/ArrayOfNumberOnly.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct ArrayOfNumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct ArrayOfNumberOnly: Sendable, Codable, Hashable {
1111

1212
public var arrayNumber: [Double]?
1313

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/ArrayTest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct ArrayTest: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct ArrayTest: Sendable, Codable, Hashable {
1111

1212
public var arrayOfString: [String]?
1313
public var arrayArrayOfInteger: [[Int64]]?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Capitalization.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Capitalization: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Capitalization: Sendable, Codable, Hashable {
1111

1212
public var smallCamel: String?
1313
public var capitalCamel: String?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Cat.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Cat: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Cat: Sendable, Codable, Hashable {
1111

1212
public var className: String
1313
public var color: String? = "red"

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Category.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Category: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Category: Sendable, Codable, Hashable {
1111

1212
public var id: Int64?
1313
public var name: String? = "default-name"

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/ClassModel.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/** Model for testing model with \&quot;_class\&quot; property */
11-
public struct ClassModel: Sendable, Codable, QueryStringEncodable, Hashable {
11+
public struct ClassModel: Sendable, Codable, Hashable {
1212

1313
public var _class: String?
1414

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Client.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Client: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Client: Sendable, Codable, Hashable {
1111

1212
public var client: String?
1313

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Dog.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Dog: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Dog: Sendable, Codable, Hashable {
1111

1212
public var className: String
1313
public var color: String? = "red"

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/EnumArrays.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct EnumArrays: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct EnumArrays: Sendable, Codable, Hashable {
1111

1212
public enum JustSymbol: String, Sendable, Codable, CaseIterable {
1313
case greaterThanOrEqualTo = ">="

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/EnumTest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct EnumTest: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct EnumTest: Sendable, Codable, Hashable {
1111

1212
public enum EnumString: String, Sendable, Codable, CaseIterable {
1313
case upper = "UPPER"

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/File.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/** Must be named &#x60;File&#x60; for test. */
11-
public struct File: Sendable, Codable, QueryStringEncodable, Hashable {
11+
public struct File: Sendable, Codable, Hashable {
1212

1313
/** Test capitalization */
1414
public var sourceURI: String?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/FileSchemaTestClass.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct FileSchemaTestClass: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct FileSchemaTestClass: Sendable, Codable, Hashable {
1111

1212
public var file: File?
1313
public var files: [File]?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/FormatTest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct FormatTest: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct FormatTest: Sendable, Codable, Hashable {
1111

1212
public static let integerRule = NumericRule<Int>(minimum: 10, exclusiveMinimum: false, maximum: 100, exclusiveMaximum: false, multipleOf: nil)
1313
public static let int32Rule = NumericRule<Int>(minimum: 20, exclusiveMinimum: false, maximum: 200, exclusiveMaximum: false, multipleOf: nil)

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/HasOnlyReadOnly.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct HasOnlyReadOnly: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct HasOnlyReadOnly: Sendable, Codable, Hashable {
1111

1212
public var bar: String?
1313
public var foo: String?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/List.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct List: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct List: Sendable, Codable, Hashable {
1111

1212
public var _123list: String?
1313

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/MapTest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct MapTest: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct MapTest: Sendable, Codable, Hashable {
1111

1212
public enum MapOfEnumString: String, Sendable, Codable, CaseIterable {
1313
case upper = "UPPER"

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/MixedPropertiesAndAdditionalPropertiesClass.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct MixedPropertiesAndAdditionalPropertiesClass: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct MixedPropertiesAndAdditionalPropertiesClass: Sendable, Codable, Hashable {
1111

1212
public var uuid: UUID?
1313
public var dateTime: Date?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Model200Response.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/** Model for testing model name starting with number */
11-
public struct Model200Response: Sendable, Codable, QueryStringEncodable, Hashable {
11+
public struct Model200Response: Sendable, Codable, Hashable {
1212

1313
public var name: Int?
1414
public var _class: String?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Name.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/** Model for testing model name same as property name */
11-
public struct Name: Sendable, Codable, QueryStringEncodable, Hashable {
11+
public struct Name: Sendable, Codable, Hashable {
1212

1313
public var name: Int
1414
public var snakeCase: NullEncodable<Int> = .encodeValue(11033)

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/NumberOnly.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct NumberOnly: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct NumberOnly: Sendable, Codable, Hashable {
1111

1212
public var justNumber: Double?
1313

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Order.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Order: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Order: Sendable, Codable, Hashable {
1111

1212
public enum Status: String, Sendable, Codable, CaseIterable {
1313
case placed = "placed"

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/OuterComposite.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct OuterComposite: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct OuterComposite: Sendable, Codable, Hashable {
1111

1212
public var myNumber: Double?
1313
public var myString: String?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Pet.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Pet: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Pet: Sendable, Codable, Hashable {
1111

1212
public enum Status: String, Sendable, Codable, CaseIterable {
1313
case available = "available"

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/ReadOnlyFirst.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct ReadOnlyFirst: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct ReadOnlyFirst: Sendable, Codable, Hashable {
1111

1212
public var bar: String?
1313
public var baz: String?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Return.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/** Model for testing reserved words */
11-
public struct Return: Sendable, Codable, QueryStringEncodable, Hashable {
11+
public struct Return: Sendable, Codable, Hashable {
1212

1313
public var _return: Int?
1414

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/SpecialModelName.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct SpecialModelName: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct SpecialModelName: Sendable, Codable, Hashable {
1111

1212
public var specialPropertyName: Int64?
1313

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/StringBooleanMap.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct StringBooleanMap: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct StringBooleanMap: Sendable, Codable, Hashable {
1111

1212

1313
public enum CodingKeys: CodingKey, CaseIterable {

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/Tag.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct Tag: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct Tag: Sendable, Codable, Hashable {
1111

1212
public var id: Int64?
1313
public var name: String?

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/TypeHolderDefault.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct TypeHolderDefault: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct TypeHolderDefault: Sendable, Codable, Hashable {
1111

1212
public var stringItem: String = "what"
1313
public var numberItem: Double

samples/client/petstore/swift6/alamofireLibrary/Sources/PetstoreClient/Models/TypeHolderExample.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct TypeHolderExample: Sendable, Codable, QueryStringEncodable, Hashable {
10+
public struct TypeHolderExample: Sendable, Codable, Hashable {
1111

1212
public var stringItem: String
1313
public var numberItem: Double

0 commit comments

Comments
 (0)