36
36
public struct OpenAPIValueContainer : Codable , Equatable , Hashable , Sendable {
37
37
38
38
/// The underlying dynamic value.
39
- public var value : Sendable ?
39
+ public var value : ( any Sendable ) ?
40
40
41
41
/// Creates a new container with the given validated value.
42
42
/// - Parameter value: A value of a JSON-compatible type, such as `String`,
43
43
/// `[Any]`, and `[String: Any]`.
44
- init ( validatedValue value: Sendable ? ) {
44
+ init ( validatedValue value: ( any Sendable ) ? ) {
45
45
self . value = value
46
46
}
47
47
@@ -62,7 +62,7 @@ public struct OpenAPIValueContainer: Codable, Equatable, Hashable, Sendable {
62
62
/// - Parameter value: An untyped value.
63
63
/// - Returns: A cast value if supported.
64
64
/// - Throws: When the value is not supported.
65
- static func tryCast( _ value: ( any Sendable ) ? ) throws -> Sendable ? {
65
+ static func tryCast( _ value: ( any Sendable ) ? ) throws -> ( any Sendable ) ? {
66
66
guard let value = value else {
67
67
return nil
68
68
}
@@ -98,7 +98,7 @@ public struct OpenAPIValueContainer: Codable, Equatable, Hashable, Sendable {
98
98
99
99
// MARK: Decodable
100
100
101
- public init ( from decoder: Decoder ) throws {
101
+ public init ( from decoder: any Decoder ) throws {
102
102
let container = try decoder. singleValueContainer ( )
103
103
if container. decodeNil ( ) {
104
104
self . init ( validatedValue: nil )
@@ -124,7 +124,7 @@ public struct OpenAPIValueContainer: Codable, Equatable, Hashable, Sendable {
124
124
125
125
// MARK: Encodable
126
126
127
- public func encode( to encoder: Encoder ) throws {
127
+ public func encode( to encoder: any Encoder ) throws {
128
128
var container = encoder. singleValueContainer ( )
129
129
guard let value = value else {
130
130
try container. encodeNil ( )
@@ -171,15 +171,15 @@ public struct OpenAPIValueContainer: Codable, Equatable, Hashable, Sendable {
171
171
return lhs == rhs
172
172
case let ( lhs as String , rhs as String ) :
173
173
return lhs == rhs
174
- case let ( lhs as [ Sendable ? ] , rhs as [ Sendable ? ] ) :
174
+ case let ( lhs as [ ( any Sendable ) ? ] , rhs as [ ( any Sendable ) ? ] ) :
175
175
guard lhs. count == rhs. count else {
176
176
return false
177
177
}
178
178
return zip ( lhs, rhs)
179
179
. allSatisfy { lhs, rhs in
180
180
OpenAPIValueContainer ( validatedValue: lhs) == OpenAPIValueContainer ( validatedValue: rhs)
181
181
}
182
- case let ( lhs as [ String : Sendable ? ] , rhs as [ String : Sendable ? ] ) :
182
+ case let ( lhs as [ String : ( any Sendable ) ? ] , rhs as [ String : ( any Sendable ) ? ] ) :
183
183
guard lhs. count == rhs. count else {
184
184
return false
185
185
}
@@ -211,11 +211,11 @@ public struct OpenAPIValueContainer: Codable, Equatable, Hashable, Sendable {
211
211
hasher. combine ( value)
212
212
case let value as String :
213
213
hasher. combine ( value)
214
- case let value as [ Sendable ] :
214
+ case let value as [ any Sendable ] :
215
215
for item in value {
216
216
hasher. combine ( OpenAPIValueContainer ( validatedValue: item) )
217
217
}
218
- case let value as [ String : Sendable ] :
218
+ case let value as [ String : any Sendable ] :
219
219
for (key, itemValue) in value {
220
220
hasher. combine ( key)
221
221
hasher. combine ( OpenAPIValueContainer ( validatedValue: itemValue) )
@@ -281,11 +281,11 @@ extension OpenAPIValueContainer: ExpressibleByFloatLiteral {
281
281
public struct OpenAPIObjectContainer : Codable , Equatable , Hashable , Sendable {
282
282
283
283
/// The underlying dynamic dictionary value.
284
- public var value : [ String : Sendable ? ]
284
+ public var value : [ String : ( any Sendable ) ? ]
285
285
286
286
/// Creates a new container with the given validated dictionary.
287
287
/// - Parameter value: A dictionary value.
288
- init ( validatedValue value: [ String : Sendable ? ] ) {
288
+ init ( validatedValue value: [ String : ( any Sendable ) ? ] ) {
289
289
self . value = value
290
290
}
291
291
@@ -311,21 +311,21 @@ public struct OpenAPIObjectContainer: Codable, Equatable, Hashable, Sendable {
311
311
/// - Parameter value: A dictionary with untyped values.
312
312
/// - Returns: A cast dictionary if values are supported.
313
313
/// - Throws: If an unsupported value is found.
314
- static func tryCast( _ value: [ String : Any ? ] ) throws -> [ String : Sendable ? ] {
314
+ static func tryCast( _ value: [ String : Any ? ] ) throws -> [ String : ( any Sendable ) ? ] {
315
315
return try value. mapValues ( OpenAPIValueContainer . tryCast ( _: ) )
316
316
}
317
317
318
318
// MARK: Decodable
319
319
320
- public init ( from decoder: Decoder ) throws {
320
+ public init ( from decoder: any Decoder ) throws {
321
321
let container = try decoder. singleValueContainer ( )
322
322
let item = try container. decode ( [ String : OpenAPIValueContainer ] . self)
323
323
self . init ( validatedValue: item. mapValues ( \. value) )
324
324
}
325
325
326
326
// MARK: Encodable
327
327
328
- public func encode( to encoder: Encoder ) throws {
328
+ public func encode( to encoder: any Encoder ) throws {
329
329
var container = encoder. singleValueContainer ( )
330
330
try container. encode ( value. mapValues ( OpenAPIValueContainer . init ( validatedValue: ) ) )
331
331
}
@@ -385,11 +385,11 @@ public struct OpenAPIObjectContainer: Codable, Equatable, Hashable, Sendable {
385
385
public struct OpenAPIArrayContainer : Codable , Equatable , Hashable , Sendable {
386
386
387
387
/// The underlying dynamic array value.
388
- public var value : [ Sendable ? ]
388
+ public var value : [ ( any Sendable ) ? ]
389
389
390
390
/// Creates a new container with the given validated array.
391
391
/// - Parameter value: An array value.
392
- init ( validatedValue value: [ Sendable ? ] ) {
392
+ init ( validatedValue value: [ ( any Sendable ) ? ] ) {
393
393
self . value = value
394
394
}
395
395
@@ -414,21 +414,21 @@ public struct OpenAPIArrayContainer: Codable, Equatable, Hashable, Sendable {
414
414
/// Returns the specified value cast to an array of supported values.
415
415
/// - Parameter value: An array with untyped values.
416
416
/// - Returns: A cast value if values are supported, nil otherwise.
417
- static func tryCast( _ value: [ Any ? ] ) throws -> [ Sendable ? ] {
417
+ static func tryCast( _ value: [ Any ? ] ) throws -> [ ( any Sendable ) ? ] {
418
418
return try value. map ( OpenAPIValueContainer . tryCast ( _: ) )
419
419
}
420
420
421
421
// MARK: Decodable
422
422
423
- public init ( from decoder: Decoder ) throws {
423
+ public init ( from decoder: any Decoder ) throws {
424
424
let container = try decoder. singleValueContainer ( )
425
425
let item = try container. decode ( [ OpenAPIValueContainer ] . self)
426
426
self . init ( validatedValue: item. map ( \. value) )
427
427
}
428
428
429
429
// MARK: Encodable
430
430
431
- public func encode( to encoder: Encoder ) throws {
431
+ public func encode( to encoder: any Encoder ) throws {
432
432
var container = encoder. singleValueContainer ( )
433
433
try container. encode ( value. map ( OpenAPIValueContainer . init ( validatedValue: ) ) )
434
434
}
0 commit comments