1- use rustapi_core:: { post, Created , Json , RustApi , get } ;
1+ use rustapi_core:: { get , post, Created , Json , RustApi } ;
22use rustapi_openapi:: Schema ;
33use serde:: { Deserialize , Serialize } ;
44use serde_json:: json;
@@ -211,34 +211,34 @@ async fn test_openapi_snapshot() {
211211 assert_eq ! ( output, output2, "Nondeterministic output detected!" ) ;
212212}
213213
214- #[ derive( Debug , Deserialize , Schema ) ]
215- struct CreatePin {
214+ #[ derive( Debug , Deserialize , Schema ) ]
215+ struct CreatePin {
216216 title : String ,
217- }
217+ }
218218
219- #[ derive( Debug , Serialize , Schema ) ]
220- struct PinResponse {
219+ #[ derive( Debug , Serialize , Schema ) ]
220+ struct PinResponse {
221221 id : i64 ,
222222 title : String ,
223- }
223+ }
224224
225- async fn create_pin ( Json ( body) : Json < CreatePin > ) -> Created < PinResponse > {
225+ async fn create_pin ( Json ( body) : Json < CreatePin > ) -> Created < PinResponse > {
226226 Created ( PinResponse {
227- id : 1 ,
228- title : body. title ,
227+ id : 1 ,
228+ title : body. title ,
229229 } )
230- }
230+ }
231231
232- #[ test]
233- fn test_manual_route_registers_openapi_components_for_body_refs ( ) {
232+ #[ test]
233+ fn test_manual_route_registers_openapi_components_for_body_refs ( ) {
234234 use rustapi_openapi:: schema:: RustApiSchema ;
235235
236236 let app = RustApi :: new ( ) . route ( "/pins" , post ( create_pin) ) ;
237237 let spec = app. openapi_spec ( ) ;
238238
239239 assert ! (
240- spec. validate_integrity( ) . is_ok( ) ,
241- "manual route OpenAPI spec should not contain dangling $ref values"
240+ spec. validate_integrity( ) . is_ok( ) ,
241+ "manual route OpenAPI spec should not contain dangling $ref values"
242242 ) ;
243243
244244 let components = spec. components . as_ref ( ) . expect ( "components should exist" ) ;
@@ -251,15 +251,15 @@ async fn test_openapi_snapshot() {
251251 let path_item = spec. paths . get ( "/pins" ) . expect ( "/pins path should exist" ) ;
252252 let op = path_item. post . as_ref ( ) . expect ( "POST /pins should exist" ) ;
253253 let media_type = op
254- . request_body
255- . as_ref ( )
256- . and_then ( |body| body. content . get ( "application/json" ) )
257- . expect ( "request body media type should exist" ) ;
254+ . request_body
255+ . as_ref ( )
256+ . and_then ( |body| body. content . get ( "application/json" ) )
257+ . expect ( "request body media type should exist" ) ;
258258
259259 match media_type. schema . as_ref ( ) . expect ( "schema should exist" ) {
260- rustapi_openapi:: SchemaRef :: Ref { reference } => {
261- assert_eq ! ( reference, "#/components/schemas/CreatePin" ) ;
262- }
263- other => panic ! ( "expected request body schema ref, got {other:?}" ) ,
260+ rustapi_openapi:: SchemaRef :: Ref { reference } => {
261+ assert_eq ! ( reference, "#/components/schemas/CreatePin" ) ;
262+ }
263+ other => panic ! ( "expected request body schema ref, got {other:?}" ) ,
264264 }
265- }
265+ }
0 commit comments