@@ -3,23 +3,37 @@ use std::collections::BTreeMap;
3
3
use serde:: { Deserialize , Serialize } ;
4
4
use url:: Url ;
5
5
6
+ use super :: spec_extensions;
7
+
6
8
/// Allows configuration of the supported OAuth Flows.
7
9
///
8
10
/// See <https://github.com/OAI/OpenAPI-Specification/blob/HEAD/versions/3.1.0.md#oauth-flows-object>.
9
11
#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
10
12
#[ serde( rename_all = "camelCase" ) ]
11
13
pub struct Flows {
14
+ /// Configuration for the OAuth Implicit flow.
12
15
#[ serde( skip_serializing_if = "Option::is_none" ) ]
13
16
pub implicit : Option < ImplicitFlow > ,
14
17
18
+ /// Configuration for the OAuth Resource Owner Password flow.
15
19
#[ serde( skip_serializing_if = "Option::is_none" ) ]
16
20
pub password : Option < PasswordFlow > ,
17
21
22
+ /// Configuration for the OAuth Client Credentials flow.
18
23
#[ serde( skip_serializing_if = "Option::is_none" ) ]
19
24
pub client_credentials : Option < ClientCredentialsFlow > ,
20
25
26
+ /// Configuration for the OAuth Authorization Code flow.
21
27
#[ serde( skip_serializing_if = "Option::is_none" ) ]
22
28
pub authorization_code : Option < AuthorizationCodeFlow > ,
29
+
30
+ /// Specification extensions.
31
+ ///
32
+ /// Only "x-" prefixed keys are collected, and the prefix is stripped.
33
+ ///
34
+ /// See <https://github.com/OAI/OpenAPI-Specification/blob/HEAD/versions/3.1.0.md#specification-extensions>.
35
+ #[ serde( flatten, with = "spec_extensions" ) ]
36
+ pub extensions : BTreeMap < String , serde_json:: Value > ,
23
37
}
24
38
25
39
/// Configuration details for a implicit OAuth Flow.
@@ -28,12 +42,30 @@ pub struct Flows {
28
42
#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
29
43
#[ serde( rename_all = "camelCase" ) ]
30
44
pub struct ImplicitFlow {
45
+ /// The authorization URL to be used for this flow.
46
+ ///
47
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
31
48
pub authorization_url : Url ,
32
49
50
+ /// The URL to be used for obtaining refresh tokens.
51
+ ///
52
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
33
53
#[ serde( skip_serializing_if = "Option::is_none" ) ]
34
54
pub refresh_url : Option < Url > ,
35
55
56
+ /// The available scopes for the OAuth2 security scheme.
57
+ ///
58
+ /// A map between the scope name and a short description for it. The map MAY be empty.
59
+ #[ serde( default ) ]
36
60
pub scopes : BTreeMap < String , String > ,
61
+
62
+ /// Specification extensions.
63
+ ///
64
+ /// Only "x-" prefixed keys are collected, and the prefix is stripped.
65
+ ///
66
+ /// See <https://github.com/OAI/OpenAPI-Specification/blob/HEAD/versions/3.1.0.md#specification-extensions>.
67
+ #[ serde( flatten, with = "spec_extensions" ) ]
68
+ pub extensions : BTreeMap < String , serde_json:: Value > ,
37
69
}
38
70
39
71
/// Configuration details for a password OAuth Flow.
@@ -42,11 +74,21 @@ pub struct ImplicitFlow {
42
74
#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
43
75
#[ serde( rename_all = "camelCase" ) ]
44
76
pub struct PasswordFlow {
45
- token_url : Url ,
77
+ /// The token URL to be used for this flow.
78
+ ///
79
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
80
+ pub token_url : Url ,
46
81
82
+ /// The URL to be used for obtaining refresh tokens.
83
+ ///
84
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
47
85
#[ serde( skip_serializing_if = "Option::is_none" ) ]
48
86
pub refresh_url : Option < Url > ,
49
87
88
+ /// The available scopes for the OAuth2 security scheme.
89
+ ///
90
+ /// A map between the scope name and a short description for it. The map MAY be empty.
91
+ #[ serde( default ) ]
50
92
pub scopes : BTreeMap < String , String > ,
51
93
}
52
94
@@ -56,11 +98,21 @@ pub struct PasswordFlow {
56
98
#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
57
99
#[ serde( rename_all = "camelCase" ) ]
58
100
pub struct ClientCredentialsFlow {
59
- token_url : Url ,
101
+ /// The token URL to be used for this flow.
102
+ ///
103
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
104
+ pub token_url : Url ,
60
105
106
+ /// The URL to be used for obtaining refresh tokens.
107
+ ///
108
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
61
109
#[ serde( skip_serializing_if = "Option::is_none" ) ]
62
110
pub refresh_url : Option < Url > ,
63
111
112
+ /// The available scopes for the OAuth2 security scheme.
113
+ ///
114
+ /// A map between the scope name and a short description for it. The map MAY be empty.
115
+ #[ serde( default ) ]
64
116
pub scopes : BTreeMap < String , String > ,
65
117
}
66
118
@@ -70,12 +122,26 @@ pub struct ClientCredentialsFlow {
70
122
#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
71
123
#[ serde( rename_all = "camelCase" ) ]
72
124
pub struct AuthorizationCodeFlow {
125
+ /// The authorization URL to be used for this flow.
126
+ ///
127
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
73
128
pub authorization_url : Url ,
129
+
130
+ /// The token URL to be used for this flow.
131
+ ///
132
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
74
133
pub token_url : Url ,
75
134
135
+ /// The URL to be used for obtaining refresh tokens.
136
+ ///
137
+ /// This MUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
76
138
#[ serde( skip_serializing_if = "Option::is_none" ) ]
77
139
pub refresh_url : Option < Url > ,
78
140
141
+ /// The available scopes for the OAuth2 security scheme.
142
+ ///
143
+ /// A map between the scope name and a short description for it. The map MAY be empty.
144
+ #[ serde( default ) ]
79
145
pub scopes : BTreeMap < String , String > ,
80
146
}
81
147
0 commit comments