Skip to content

Commit c06db15

Browse files
authored
[swift6] Add conditional Hashable conformance to NullEncodable (#20149)
1 parent 18b01ca commit c06db15

File tree

14 files changed

+42
-14
lines changed
  • modules/openapi-generator/src/main/resources/swift6
  • samples/client/petstore/swift6
    • alamofireLibrary/Sources/PetstoreClient/Infrastructure
    • apiNonStaticMethod/Sources/PetstoreClient/Infrastructure
    • asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure
    • combineDeferredLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • combineLibrary/Sources/CombineLibrary/Infrastructure
    • default/Sources/PetstoreClient/Infrastructure
    • objcCompatible/Sources/PetstoreClient/Infrastructure
    • oneOf/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • resultLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure
    • urlsessionLibrary/Sources/PetstoreClient/Infrastructure
    • validation/PetstoreClient/Classes/OpenAPIs/Infrastructure

14 files changed

+42
-14
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ extension CaseIterableDefaultsLast {
3838

3939
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
4040
/// or not encoded (`.encodeNothing`). Intended for request payloads.
41-
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum NullEncodable<Wrapped: Hashable>: Hashable {
41+
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} enum NullEncodable<Wrapped> {
4242
case encodeNothing
4343
case encodeNull
4444
case encodeValue(Wrapped)
4545
}
4646

47+
extension NullEncodable: Equatable where Wrapped: Equatable {}
48+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4749
extension NullEncodable: Sendable where Wrapped: Sendable {}
4850

4951
extension NullEncodable: Codable where Wrapped: Codable {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ extension CaseIterableDefaultsLast {
3838

3939
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
4040
/// or not encoded (`.encodeNothing`). Intended for request payloads.
41-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
41+
public enum NullEncodable<Wrapped> {
4242
case encodeNothing
4343
case encodeNull
4444
case encodeValue(Wrapped)
4545
}
4646

47+
extension NullEncodable: Equatable where Wrapped: Equatable {}
48+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4749
extension NullEncodable: Sendable where Wrapped: Sendable {}
4850

4951
extension NullEncodable: Codable where Wrapped: Codable {

samples/client/petstore/swift6/apiNonStaticMethod/Sources/PetstoreClient/Infrastructure/Models.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ extension CaseIterableDefaultsLast {
3838

3939
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
4040
/// or not encoded (`.encodeNothing`). Intended for request payloads.
41-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
41+
public enum NullEncodable<Wrapped> {
4242
case encodeNothing
4343
case encodeNull
4444
case encodeValue(Wrapped)
4545
}
4646

47+
extension NullEncodable: Equatable where Wrapped: Equatable {}
48+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4749
extension NullEncodable: Sendable where Wrapped: Sendable {}
4850

4951
extension NullEncodable: Codable where Wrapped: Codable {

samples/client/petstore/swift6/asyncAwaitLibrary/Sources/PetstoreClient/Infrastructure/Models.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ extension CaseIterableDefaultsLast {
3737

3838
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
3939
/// or not encoded (`.encodeNothing`). Intended for request payloads.
40-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
40+
public enum NullEncodable<Wrapped> {
4141
case encodeNothing
4242
case encodeNull
4343
case encodeValue(Wrapped)
4444
}
4545

46+
extension NullEncodable: Equatable where Wrapped: Equatable {}
47+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4648
extension NullEncodable: Sendable where Wrapped: Sendable {}
4749

4850
extension NullEncodable: Codable where Wrapped: Codable {

samples/client/petstore/swift6/combineDeferredLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ extension CaseIterableDefaultsLast {
3737

3838
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
3939
/// or not encoded (`.encodeNothing`). Intended for request payloads.
40-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
40+
public enum NullEncodable<Wrapped> {
4141
case encodeNothing
4242
case encodeNull
4343
case encodeValue(Wrapped)
4444
}
4545

46+
extension NullEncodable: Equatable where Wrapped: Equatable {}
47+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4648
extension NullEncodable: Sendable where Wrapped: Sendable {}
4749

4850
extension NullEncodable: Codable where Wrapped: Codable {

samples/client/petstore/swift6/combineLibrary/Sources/CombineLibrary/Infrastructure/Models.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ extension CaseIterableDefaultsLast {
3737

3838
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
3939
/// or not encoded (`.encodeNothing`). Intended for request payloads.
40-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
40+
public enum NullEncodable<Wrapped> {
4141
case encodeNothing
4242
case encodeNull
4343
case encodeValue(Wrapped)
4444
}
4545

46+
extension NullEncodable: Equatable where Wrapped: Equatable {}
47+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4648
extension NullEncodable: Sendable where Wrapped: Sendable {}
4749

4850
extension NullEncodable: Codable where Wrapped: Codable {

samples/client/petstore/swift6/default/Sources/PetstoreClient/Infrastructure/Models.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ extension CaseIterableDefaultsLast {
3737

3838
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
3939
/// or not encoded (`.encodeNothing`). Intended for request payloads.
40-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
40+
public enum NullEncodable<Wrapped> {
4141
case encodeNothing
4242
case encodeNull
4343
case encodeValue(Wrapped)
4444
}
4545

46+
extension NullEncodable: Equatable where Wrapped: Equatable {}
47+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4648
extension NullEncodable: Sendable where Wrapped: Sendable {}
4749

4850
extension NullEncodable: Codable where Wrapped: Codable {

samples/client/petstore/swift6/objcCompatible/Sources/PetstoreClient/Infrastructure/Models.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ extension CaseIterableDefaultsLast {
3737

3838
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
3939
/// or not encoded (`.encodeNothing`). Intended for request payloads.
40-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
40+
public enum NullEncodable<Wrapped> {
4141
case encodeNothing
4242
case encodeNull
4343
case encodeValue(Wrapped)
4444
}
4545

46+
extension NullEncodable: Equatable where Wrapped: Equatable {}
47+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4648
extension NullEncodable: Sendable where Wrapped: Sendable {}
4749

4850
extension NullEncodable: Codable where Wrapped: Codable {

samples/client/petstore/swift6/oneOf/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ extension CaseIterableDefaultsLast {
3737

3838
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
3939
/// or not encoded (`.encodeNothing`). Intended for request payloads.
40-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
40+
public enum NullEncodable<Wrapped> {
4141
case encodeNothing
4242
case encodeNull
4343
case encodeValue(Wrapped)
4444
}
4545

46+
extension NullEncodable: Equatable where Wrapped: Equatable {}
47+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4648
extension NullEncodable: Sendable where Wrapped: Sendable {}
4749

4850
extension NullEncodable: Codable where Wrapped: Codable {

samples/client/petstore/swift6/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/Infrastructure/Models.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ extension CaseIterableDefaultsLast {
3737

3838
/// A flexible type that can be encoded (`.encodeNull` or `.encodeValue`)
3939
/// or not encoded (`.encodeNothing`). Intended for request payloads.
40-
public enum NullEncodable<Wrapped: Hashable>: Hashable {
40+
public enum NullEncodable<Wrapped> {
4141
case encodeNothing
4242
case encodeNull
4343
case encodeValue(Wrapped)
4444
}
4545

46+
extension NullEncodable: Equatable where Wrapped: Equatable {}
47+
extension NullEncodable: Hashable where Wrapped: Hashable {}
4648
extension NullEncodable: Sendable where Wrapped: Sendable {}
4749

4850
extension NullEncodable: Codable where Wrapped: Codable {

0 commit comments

Comments
 (0)