@@ -13,12 +13,12 @@ use std::net::IpAddr;
1313
1414use mas_data_model:: { Client , User } ;
1515use oauth2_types:: { registration:: VerifiedClientMetadata , scope:: Scope } ;
16+ use schemars:: JsonSchema ;
1617use serde:: { Deserialize , Serialize } ;
1718
1819/// A well-known policy code.
19- #[ derive( Deserialize , Debug , Clone , Copy ) ]
20+ #[ derive( Deserialize , Debug , Clone , Copy , JsonSchema ) ]
2021#[ serde( rename_all = "kebab-case" ) ]
21- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
2222pub enum Code {
2323 /// The username is too short.
2424 UsernameTooShort ,
@@ -71,8 +71,7 @@ impl Code {
7171}
7272
7373/// A single violation of a policy.
74- #[ derive( Deserialize , Debug ) ]
75- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
74+ #[ derive( Deserialize , Debug , JsonSchema ) ]
7675pub struct Violation {
7776 pub msg : String ,
7877 pub redirect_uri : Option < String > ,
@@ -111,9 +110,8 @@ impl EvaluationResult {
111110}
112111
113112/// Identity of the requester
114- #[ derive( Serialize , Debug , Default ) ]
113+ #[ derive( Serialize , Debug , Default , JsonSchema ) ]
115114#[ serde( rename_all = "snake_case" ) ]
116- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
117115pub struct Requester {
118116 /// IP address of the entity making the request
119117 pub ip_address : Option < IpAddr > ,
@@ -122,8 +120,7 @@ pub struct Requester {
122120 pub user_agent : Option < String > ,
123121}
124122
125- #[ derive( Serialize , Debug ) ]
126- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
123+ #[ derive( Serialize , Debug , JsonSchema ) ]
127124pub enum RegistrationMethod {
128125 #[ serde( rename = "password" ) ]
129126 Password ,
@@ -133,9 +130,8 @@ pub enum RegistrationMethod {
133130}
134131
135132/// Input for the user registration policy.
136- #[ derive( Serialize , Debug ) ]
133+ #[ derive( Serialize , Debug , JsonSchema ) ]
137134#[ serde( tag = "registration_method" ) ]
138- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
139135pub struct RegisterInput < ' a > {
140136 pub registration_method : RegistrationMethod ,
141137
@@ -148,21 +144,16 @@ pub struct RegisterInput<'a> {
148144}
149145
150146/// Input for the client registration policy.
151- #[ derive( Serialize , Debug ) ]
147+ #[ derive( Serialize , Debug , JsonSchema ) ]
152148#[ serde( rename_all = "snake_case" ) ]
153- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
154149pub 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>" ) ]
159151 pub client_metadata : & ' a VerifiedClientMetadata ,
160152 pub requester : Requester ,
161153}
162154
163- #[ derive( Serialize , Debug ) ]
155+ #[ derive( Serialize , Debug , JsonSchema ) ]
164156#[ serde( rename_all = "snake_case" ) ]
165- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
166157pub enum GrantType {
167158 AuthorizationCode ,
168159 ClientCredentials ,
@@ -171,23 +162,16 @@ pub enum GrantType {
171162}
172163
173164/// Input for the authorization grant policy.
174- #[ derive( Serialize , Debug ) ]
165+ #[ derive( Serialize , Debug , JsonSchema ) ]
175166#[ serde( rename_all = "snake_case" ) ]
176- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
177167pub 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>>" ) ]
182169 pub user : Option < & ' a User > ,
183170
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>" ) ]
188172 pub client : & ' a Client ,
189173
190- #[ cfg_attr ( feature = "jsonschema" , schemars( with = "String" ) ) ]
174+ #[ schemars( with = "String" ) ]
191175 pub scope : & ' a Scope ,
192176
193177 pub grant_type : GrantType ,
@@ -196,9 +180,8 @@ pub struct AuthorizationGrantInput<'a> {
196180}
197181
198182/// Input for the email add policy.
199- #[ derive( Serialize , Debug ) ]
183+ #[ derive( Serialize , Debug , JsonSchema ) ]
200184#[ serde( rename_all = "snake_case" ) ]
201- #[ cfg_attr( feature = "jsonschema" , derive( schemars:: JsonSchema ) ) ]
202185pub struct EmailInput < ' a > {
203186 pub email : & ' a str ,
204187
0 commit comments