@@ -13,12 +13,12 @@ use std::net::IpAddr;
13
13
14
14
use mas_data_model:: { Client , User } ;
15
15
use oauth2_types:: { registration:: VerifiedClientMetadata , scope:: Scope } ;
16
+ use schemars:: JsonSchema ;
16
17
use serde:: { Deserialize , Serialize } ;
17
18
18
19
/// A well-known policy code.
19
- #[ derive( Deserialize , Debug , Clone , Copy ) ]
20
+ #[ derive( Deserialize , Debug , Clone , Copy , JsonSchema ) ]
20
21
#[ serde( rename_all = "kebab-case" ) ]
21
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
22
22
pub enum Code {
23
23
/// The username is too short.
24
24
UsernameTooShort ,
@@ -71,8 +71,7 @@ impl Code {
71
71
}
72
72
73
73
/// A single violation of a policy.
74
- #[ derive( Deserialize , Debug ) ]
75
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
74
+ #[ derive( Deserialize , Debug , JsonSchema ) ]
76
75
pub struct Violation {
77
76
pub msg : String ,
78
77
pub redirect_uri : Option < String > ,
@@ -111,9 +110,8 @@ impl EvaluationResult {
111
110
}
112
111
113
112
/// Identity of the requester
114
- #[ derive( Serialize , Debug , Default ) ]
113
+ #[ derive( Serialize , Debug , Default , JsonSchema ) ]
115
114
#[ serde( rename_all = "snake_case" ) ]
116
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
117
115
pub struct Requester {
118
116
/// IP address of the entity making the request
119
117
pub ip_address : Option < IpAddr > ,
@@ -122,8 +120,7 @@ pub struct Requester {
122
120
pub user_agent : Option < String > ,
123
121
}
124
122
125
- #[ derive( Serialize , Debug ) ]
126
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
123
+ #[ derive( Serialize , Debug , JsonSchema ) ]
127
124
pub enum RegistrationMethod {
128
125
#[ serde( rename = "password" ) ]
129
126
Password ,
@@ -133,9 +130,8 @@ pub enum RegistrationMethod {
133
130
}
134
131
135
132
/// Input for the user registration policy.
136
- #[ derive( Serialize , Debug ) ]
133
+ #[ derive( Serialize , Debug , JsonSchema ) ]
137
134
#[ serde( tag = "registration_method" ) ]
138
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
139
135
pub struct RegisterInput < ' a > {
140
136
pub registration_method : RegistrationMethod ,
141
137
@@ -148,21 +144,16 @@ pub struct RegisterInput<'a> {
148
144
}
149
145
150
146
/// Input for the client registration policy.
151
- #[ derive( Serialize , Debug ) ]
147
+ #[ derive( Serialize , Debug , JsonSchema ) ]
152
148
#[ serde( rename_all = "snake_case" ) ]
153
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
154
149
pub struct ClientRegistrationInput < ' a > {
155
- #[ cfg_attr(
156
- feature = "jsonschema" ,
157
- schemars( with = "std::collections::HashMap<String, serde_json::Value>" )
158
- ) ]
150
+ #[ schemars( with = "std::collections::HashMap<String, serde_json::Value>" ) ]
159
151
pub client_metadata : & ' a VerifiedClientMetadata ,
160
152
pub requester : Requester ,
161
153
}
162
154
163
- #[ derive( Serialize , Debug ) ]
155
+ #[ derive( Serialize , Debug , JsonSchema ) ]
164
156
#[ serde( rename_all = "snake_case" ) ]
165
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
166
157
pub enum GrantType {
167
158
AuthorizationCode ,
168
159
ClientCredentials ,
@@ -171,23 +162,16 @@ pub enum GrantType {
171
162
}
172
163
173
164
/// Input for the authorization grant policy.
174
- #[ derive( Serialize , Debug ) ]
165
+ #[ derive( Serialize , Debug , JsonSchema ) ]
175
166
#[ serde( rename_all = "snake_case" ) ]
176
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
177
167
pub struct AuthorizationGrantInput < ' a > {
178
- #[ cfg_attr(
179
- feature = "jsonschema" ,
180
- schemars( with = "Option<std::collections::HashMap<String, serde_json::Value>>" )
181
- ) ]
168
+ #[ schemars( with = "Option<std::collections::HashMap<String, serde_json::Value>>" ) ]
182
169
pub user : Option < & ' a User > ,
183
170
184
- #[ cfg_attr(
185
- feature = "jsonschema" ,
186
- schemars( with = "std::collections::HashMap<String, serde_json::Value>" )
187
- ) ]
171
+ #[ schemars( with = "std::collections::HashMap<String, serde_json::Value>" ) ]
188
172
pub client : & ' a Client ,
189
173
190
- #[ cfg_attr ( feature = "jsonschema" , schemars( with = "String" ) ) ]
174
+ #[ schemars( with = "String" ) ]
191
175
pub scope : & ' a Scope ,
192
176
193
177
pub grant_type : GrantType ,
@@ -196,9 +180,8 @@ pub struct AuthorizationGrantInput<'a> {
196
180
}
197
181
198
182
/// Input for the email add policy.
199
- #[ derive( Serialize , Debug ) ]
183
+ #[ derive( Serialize , Debug , JsonSchema ) ]
200
184
#[ serde( rename_all = "snake_case" ) ]
201
- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
202
185
pub struct EmailInput < ' a > {
203
186
pub email : & ' a str ,
204
187
0 commit comments