@@ -98,6 +98,10 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
9898
9999 // MARK: Decodable
100100
101+ /// Initializes an `OpenAPIValueContainer` by decoding it from a decoder.
102+ ///
103+ /// - Parameter decoder: The decoder to read data from.
104+ /// - Throws: An error if the decoding process encounters issues or if the data is corrupted.
101105 public init ( from decoder: any Decoder ) throws {
102106 let container = try decoder. singleValueContainer ( )
103107 if container. decodeNil ( ) {
@@ -124,6 +128,10 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
124128
125129 // MARK: Encodable
126130
131+ /// Encodes the `OpenAPIValueContainer` and writes it to an encoder.
132+ ///
133+ /// - Parameter encoder: The encoder to which the value should be encoded.
134+ /// - Throws: An error if the encoding process encounters issues or if the value is invalid.
127135 public func encode( to encoder: any Encoder ) throws {
128136 var container = encoder. singleValueContainer ( )
129137 guard let value = value else {
@@ -153,6 +161,12 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
153161
154162 // MARK: Equatable
155163
164+ /// Compares two `OpenAPIValueContainer` instances for equality.
165+ ///
166+ /// - Parameters:
167+ /// - lhs: The left-hand side `OpenAPIValueContainer` to compare.
168+ /// - rhs: The right-hand side `OpenAPIValueContainer` to compare.
169+ /// - Returns: `true` if the two instances are equal, `false` otherwise.
156170 public static func == ( lhs: OpenAPIValueContainer , rhs: OpenAPIValueContainer ) -> Bool {
157171 switch ( lhs. value, rhs. value) {
158172 case ( nil , nil ) , is ( Void , Void ) :
@@ -201,6 +215,9 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
201215
202216 // MARK: Hashable
203217
218+ /// Hashes the `OpenAPIValueContainer` instance into a hasher.
219+ ///
220+ /// - Parameter hasher: The hasher used to compute the hash value.
204221 public func hash( into hasher: inout Hasher ) {
205222 switch value {
206223 case let value as Bool :
@@ -227,30 +244,45 @@ public struct OpenAPIValueContainer: Codable, Hashable, Sendable {
227244}
228245
229246extension OpenAPIValueContainer : ExpressibleByBooleanLiteral {
247+ /// Creates an `OpenAPIValueContainer` with the provided boolean value.
248+ ///
249+ /// - Parameter value: The boolean value to store in the container.
230250 public init ( booleanLiteral value: BooleanLiteralType ) {
231251 self . init ( validatedValue: value)
232252 }
233253}
234254
235255extension OpenAPIValueContainer : ExpressibleByStringLiteral {
256+ /// Creates an `OpenAPIValueContainer` with the provided string value.
257+ ///
258+ /// - Parameter value: The string value to store in the container.
236259 public init ( stringLiteral value: String ) {
237260 self . init ( validatedValue: value)
238261 }
239262}
240263
241264extension OpenAPIValueContainer : ExpressibleByNilLiteral {
265+ /// Creates an `OpenAPIValueContainer` with a `nil` value.
266+ ///
267+ /// - Parameter nilLiteral: The `nil` literal.
242268 public init ( nilLiteral: ( ) ) {
243269 self . init ( validatedValue: nil )
244270 }
245271}
246272
247273extension OpenAPIValueContainer : ExpressibleByIntegerLiteral {
274+ /// Creates an `OpenAPIValueContainer` with the provided integer value.
275+ ///
276+ /// - Parameter value: The integer value to store in the container.
248277 public init ( integerLiteral value: Int ) {
249278 self . init ( validatedValue: value)
250279 }
251280}
252281
253282extension OpenAPIValueContainer : ExpressibleByFloatLiteral {
283+ /// Creates an `OpenAPIValueContainer` with the provided floating-point value.
284+ ///
285+ /// - Parameter value: The floating-point value to store in the container.
254286 public init ( floatLiteral value: Double ) {
255287 self . init ( validatedValue: value)
256288 }
@@ -317,6 +349,10 @@ public struct OpenAPIObjectContainer: Codable, Hashable, Sendable {
317349
318350 // MARK: Decodable
319351
352+ /// Creates an `OpenAPIValueContainer` by decoding it from a single-value container in a given decoder.
353+ ///
354+ /// - Parameter decoder: The decoder used to decode the container.
355+ /// - Throws: An error if the decoding process encounters an issue or if the data does not match the expected format.
320356 public init ( from decoder: any Decoder ) throws {
321357 let container = try decoder. singleValueContainer ( )
322358 let item = try container. decode ( [ String : OpenAPIValueContainer ] . self)
@@ -325,13 +361,24 @@ public struct OpenAPIObjectContainer: Codable, Hashable, Sendable {
325361
326362 // MARK: Encodable
327363
364+ /// Encodes the `OpenAPIValueContainer` into a format that can be stored or transmitted via the given encoder.
365+ ///
366+ /// - Parameter encoder: The encoder used to perform the encoding.
367+ /// - Throws: An error if the encoding process encounters an issue or if the data does not match the expected format.
328368 public func encode( to encoder: any Encoder ) throws {
329369 var container = encoder. singleValueContainer ( )
330370 try container. encode ( value. mapValues ( OpenAPIValueContainer . init ( validatedValue: ) ) )
331371 }
332372
333373 // MARK: Equatable
334374
375+ /// Compares two `OpenAPIObjectContainer` instances for equality by comparing their inner key-value dictionaries.
376+ ///
377+ /// - Parameters:
378+ /// - lhs: The left-hand side `OpenAPIObjectContainer` to compare.
379+ /// - rhs: The right-hand side `OpenAPIObjectContainer` to compare.
380+ ///
381+ /// - Returns: `true` if the `OpenAPIObjectContainer` instances are equal, `false` otherwise.
335382 public static func == ( lhs: OpenAPIObjectContainer , rhs: OpenAPIObjectContainer ) -> Bool {
336383 let lv = lhs. value
337384 let rv = rhs. value
@@ -352,6 +399,9 @@ public struct OpenAPIObjectContainer: Codable, Hashable, Sendable {
352399
353400 // MARK: Hashable
354401
402+ /// Hashes the `OpenAPIObjectContainer` instance into the provided `Hasher`.
403+ ///
404+ /// - Parameter hasher: The `Hasher` into which the hash value is combined.
355405 public func hash( into hasher: inout Hasher ) {
356406 for (key, itemValue) in value {
357407 hasher. combine ( key)
@@ -414,12 +464,17 @@ public struct OpenAPIArrayContainer: Codable, Hashable, Sendable {
414464 /// Returns the specified value cast to an array of supported values.
415465 /// - Parameter value: An array with untyped values.
416466 /// - Returns: A cast value if values are supported, nil otherwise.
467+ /// - Throws: An error if casting to supported values fails for any element.
417468 static func tryCast( _ value: [ ( any Sendable ) ? ] ) throws -> [ ( any Sendable ) ? ] {
418469 return try value. map ( OpenAPIValueContainer . tryCast ( _: ) )
419470 }
420471
421472 // MARK: Decodable
422473
474+ /// Initializes a new instance by decoding a validated array of values from a decoder.
475+ ///
476+ /// - Parameter decoder: The decoder to use for decoding the array of values.
477+ /// - Throws: An error if the decoding process fails or if the decoded values cannot be validated.
423478 public init ( from decoder: any Decoder ) throws {
424479 let container = try decoder. singleValueContainer ( )
425480 let item = try container. decode ( [ OpenAPIValueContainer ] . self)
@@ -428,13 +483,23 @@ public struct OpenAPIArrayContainer: Codable, Hashable, Sendable {
428483
429484 // MARK: Encodable
430485
486+ /// Encodes the array of validated values and stores the result in the given encoder.
487+ ///
488+ /// - Parameter encoder: The encoder to use for encoding the array of values.
489+ /// - Throws: An error if the encoding process fails.
431490 public func encode( to encoder: any Encoder ) throws {
432491 var container = encoder. singleValueContainer ( )
433492 try container. encode ( value. map ( OpenAPIValueContainer . init ( validatedValue: ) ) )
434493 }
435494
436495 // MARK: Equatable
437496
497+ /// Compares two `OpenAPIArrayContainer` instances for equality.
498+ ///
499+ /// - Parameters:
500+ /// - lhs: The left-hand side `OpenAPIArrayContainer` to compare.
501+ /// - rhs: The right-hand side `OpenAPIArrayContainer` to compare.
502+ /// - Returns: `true` if the two `OpenAPIArrayContainer` instances are equal, `false` otherwise.
438503 public static func == ( lhs: OpenAPIArrayContainer , rhs: OpenAPIArrayContainer ) -> Bool {
439504 let lv = lhs. value
440505 let rv = rhs. value
@@ -449,6 +514,9 @@ public struct OpenAPIArrayContainer: Codable, Hashable, Sendable {
449514
450515 // MARK: Hashable
451516
517+ /// Hashes the `OpenAPIArrayContainer` instance into a hasher.
518+ ///
519+ /// - Parameter hasher: The hasher used to compute the hash value.
452520 public func hash( into hasher: inout Hasher ) {
453521 for item in value {
454522 hasher. combine ( OpenAPIValueContainer ( validatedValue: item) )
0 commit comments