@@ -12,13 +12,15 @@ extension OpenAPI {
1212 /// OpenAPI Spec "Oauth Flows Object"
1313 ///
1414 /// See [OpenAPI Oauth Flows Object](https://spec.openapis.org/oas/v3.0.4.html#oauth-flows-object).
15- public struct OAuthFlows : Equatable , Sendable {
15+ public struct OAuthFlows : HasConditionalWarnings , Sendable {
1616 public let implicit : Implicit ?
1717 public let password : Password ?
1818 public let clientCredentials : ClientCredentials ?
1919 public let authorizationCode : AuthorizationCode ?
2020 public let deviceAuthorization : DeviceAuthorization ?
2121
22+ public let conditionalWarnings : [ ( any Condition , OpenAPI . Warning ) ]
23+
2224 public init (
2325 implicit: Implicit ? = nil ,
2426 password: Password ? = nil ,
@@ -31,10 +33,33 @@ extension OpenAPI {
3133 self . clientCredentials = clientCredentials
3234 self . authorizationCode = authorizationCode
3335 self . deviceAuthorization = deviceAuthorization
36+
37+ self . conditionalWarnings = [
38+ nonNilVersionWarning ( fieldName: " deviceAuthorization " , value: deviceAuthorization, minimumVersion: . v3_2_0)
39+ ] . compactMap { $0 }
3440 }
3541 }
3642}
3743
44+ extension OpenAPI . OAuthFlows : Equatable {
45+ public static func == ( lhs: Self , rhs: Self ) -> Bool {
46+ lhs. implicit == rhs. implicit
47+ && lhs. password == rhs. password
48+ && lhs. clientCredentials == rhs. clientCredentials
49+ && lhs. authorizationCode == rhs. authorizationCode
50+ && lhs. deviceAuthorization == rhs. deviceAuthorization
51+ }
52+ }
53+
54+ fileprivate func nonNilVersionWarning< Subject> ( fieldName: String , value: Subject ? , minimumVersion: OpenAPI . Document . Version ) -> ( any Condition , OpenAPI . Warning ) ? {
55+ value. map { _ in
56+ OpenAPI . Document. ConditionalWarnings. version (
57+ lessThan: minimumVersion,
58+ doesNotSupport: " The OAuthFlows \( fieldName) field "
59+ )
60+ }
61+ }
62+
3863extension OpenAPI . OAuthFlows {
3964 @dynamicMemberLookup
4065 public struct DeviceAuthorization : Equatable , Sendable {
@@ -93,6 +118,10 @@ extension OpenAPI.OAuthFlows: Decodable {
93118 clientCredentials = try container. decodeIfPresent ( OpenAPI . OAuthFlows. ClientCredentials. self, forKey: . clientCredentials)
94119 authorizationCode = try container. decodeIfPresent ( OpenAPI . OAuthFlows. AuthorizationCode. self, forKey: . authorizationCode)
95120 deviceAuthorization = try container. decodeIfPresent ( OpenAPI . OAuthFlows. DeviceAuthorization. self, forKey: . deviceAuthorization)
121+
122+ self . conditionalWarnings = [
123+ nonNilVersionWarning ( fieldName: " deviceAuthorization " , value: deviceAuthorization, minimumVersion: . v3_2_0)
124+ ] . compactMap { $0 }
96125 }
97126}
98127
0 commit comments