@@ -21,8 +21,8 @@ use vespera_core::schema::{Discriminator, Schema, SchemaRef, SchemaType};
2121
2222use super :: {
2323 serde_attrs:: {
24- SerdeEnumRepr , extract_doc_comment, extract_enum_repr, extract_field_rename,
25- extract_rename_all , rename_field, strip_raw_prefix,
24+ extract_doc_comment, extract_enum_repr, extract_field_rename, extract_rename_all ,
25+ rename_field, strip_raw_prefix, SerdeEnumRepr ,
2626 } ,
2727 type_schema:: parse_type_to_schema_ref,
2828} ;
@@ -775,13 +775,11 @@ mod tests {
775775 let inner_props = inner_obj. properties . as_ref ( ) . unwrap ( ) ;
776776 assert ! ( inner_props. contains_key( "id" ) ) ;
777777 assert ! ( inner_props. contains_key( "note" ) ) ;
778- assert ! (
779- inner_obj
780- . required
781- . as_ref( )
782- . unwrap( )
783- . contains( & "id" . to_string( ) )
784- ) ;
778+ assert ! ( inner_obj
779+ . required
780+ . as_ref( )
781+ . unwrap( )
782+ . contains( & "id" . to_string( ) ) ) ;
785783 } else {
786784 panic ! ( "Expected inline object schema" ) ;
787785 }
@@ -822,9 +820,8 @@ mod tests {
822820 let one_of = schema. one_of . expect ( "one_of missing for mixed enum" ) ;
823821 assert_eq ! ( one_of. len( ) , expected_one_of_len) ;
824822
825- let unit_schema = match & one_of[ 0 ] {
826- SchemaRef :: Inline ( s) => s,
827- _ => panic ! ( "Expected inline schema for unit variant" ) ,
823+ let SchemaRef :: Inline ( unit_schema) = & one_of[ 0 ] else {
824+ panic ! ( "Expected inline schema for unit variant" )
828825 } ;
829826 assert_eq ! ( unit_schema. schema_type, Some ( expected_unit_type) ) ;
830827 let unit_enum = unit_schema. r#enum . as_ref ( ) . expect ( "enum values missing" ) ;
@@ -845,9 +842,8 @@ mod tests {
845842
846843 let schema = parse_enum_to_schema ( & enum_item, & HashSet :: new ( ) , & HashMap :: new ( ) ) ;
847844 let one_of = schema. one_of . expect ( "one_of missing" ) ;
848- let variant_obj = match & one_of[ 0 ] {
849- SchemaRef :: Inline ( s) => s,
850- _ => panic ! ( "Expected inline schema" ) ,
845+ let SchemaRef :: Inline ( variant_obj) = & one_of[ 0 ] else {
846+ panic ! ( "Expected inline schema" )
851847 } ;
852848 let props = variant_obj
853849 . properties
@@ -870,17 +866,15 @@ mod tests {
870866
871867 let schema = parse_enum_to_schema ( & enum_item, & HashSet :: new ( ) , & HashMap :: new ( ) ) ;
872868 let one_of = schema. one_of . expect ( "one_of missing" ) ;
873- let variant_obj = match & one_of[ 0 ] {
874- SchemaRef :: Inline ( s) => s,
875- _ => panic ! ( "Expected inline schema" ) ,
869+ let SchemaRef :: Inline ( variant_obj) = & one_of[ 0 ] else {
870+ panic ! ( "Expected inline schema" )
876871 } ;
877872 let props = variant_obj
878873 . properties
879874 . as_ref ( )
880875 . expect ( "variant props missing" ) ;
881- let inner = match props. get ( "detail" ) . expect ( "variant key missing" ) {
882- SchemaRef :: Inline ( s) => s,
883- _ => panic ! ( "Expected inline inner schema" ) ,
876+ let SchemaRef :: Inline ( inner) = props. get ( "detail" ) . expect ( "variant key missing" ) else {
877+ panic ! ( "Expected inline inner schema" )
884878 } ;
885879 let inner_props = inner. properties . as_ref ( ) . expect ( "inner props missing" ) ;
886880 assert ! ( inner_props. contains_key( "user_id" ) ) ;
@@ -902,9 +896,8 @@ mod tests {
902896
903897 let schema = parse_enum_to_schema ( & enum_item, & HashSet :: new ( ) , & HashMap :: new ( ) ) ;
904898 let one_of = schema. one_of . expect ( "one_of missing" ) ;
905- let variant_obj = match & one_of[ 0 ] {
906- SchemaRef :: Inline ( s) => s,
907- _ => panic ! ( "Expected inline schema" ) ,
899+ let SchemaRef :: Inline ( variant_obj) = & one_of[ 0 ] else {
900+ panic ! ( "Expected inline schema" )
908901 } ;
909902 let props = variant_obj
910903 . properties
@@ -929,21 +922,19 @@ mod tests {
929922
930923 let schema = parse_enum_to_schema ( & enum_item, & HashSet :: new ( ) , & HashMap :: new ( ) ) ;
931924 let one_of = schema. one_of . expect ( "one_of missing" ) ;
932- let variant_obj = match & one_of[ 0 ] {
933- SchemaRef :: Inline ( s) => s,
934- _ => panic ! ( "Expected inline schema" ) ,
925+ let SchemaRef :: Inline ( variant_obj) = & one_of[ 0 ] else {
926+ panic ! ( "Expected inline schema" )
935927 } ;
936928 let props = variant_obj
937929 . properties
938930 . as_ref ( )
939931 . expect ( "variant props missing" ) ;
940- let inner = match props
932+ let SchemaRef :: Inline ( inner) = props
941933 . get ( "detail" )
942934 . or_else ( || props. get ( "Detail" ) )
943935 . expect ( "variant key missing" )
944- {
945- SchemaRef :: Inline ( s) => s,
946- _ => panic ! ( "Expected inline inner schema" ) ,
936+ else {
937+ panic ! ( "Expected inline inner schema" )
947938 } ;
948939 let inner_props = inner. properties . as_ref ( ) . expect ( "inner props missing" ) ;
949940 assert ! ( inner_props. contains_key( "ID" ) ) ; // field-level rename wins
@@ -988,9 +979,8 @@ mod tests {
988979 let one_of = schema. one_of . expect ( "one_of missing" ) ;
989980
990981 // Check UserCreated variant key is camelCase
991- let variant_obj = match & one_of[ 0 ] {
992- SchemaRef :: Inline ( s) => s,
993- _ => panic ! ( "Expected inline schema" ) ,
982+ let SchemaRef :: Inline ( variant_obj) = & one_of[ 0 ] else {
983+ panic ! ( "Expected inline schema" )
994984 } ;
995985 let props = variant_obj
996986 . properties
@@ -1001,9 +991,8 @@ mod tests {
1001991 assert ! ( !props. contains_key( "user_created" ) ) ;
1002992
1003993 // Check UserDeleted variant key is camelCase
1004- let variant_obj2 = match & one_of[ 1 ] {
1005- SchemaRef :: Inline ( s) => s,
1006- _ => panic ! ( "Expected inline schema" ) ,
994+ let SchemaRef :: Inline ( variant_obj2) = & one_of[ 1 ] else {
995+ panic ! ( "Expected inline schema" )
1007996 } ;
1008997 let props2 = variant_obj2
1009998 . properties
@@ -1153,17 +1142,15 @@ mod tests {
11531142 let one_of = schema. one_of . expect ( "one_of missing" ) ;
11541143
11551144 // Get the Data variant schema
1156- let variant_obj = match & one_of[ 0 ] {
1157- SchemaRef :: Inline ( s) => s,
1158- _ => panic ! ( "Expected inline schema" ) ,
1145+ let SchemaRef :: Inline ( variant_obj) = & one_of[ 0 ] else {
1146+ panic ! ( "Expected inline schema" )
11591147 } ;
11601148 let props = variant_obj
11611149 . properties
11621150 . as_ref ( )
11631151 . expect ( "variant props missing" ) ;
1164- let inner = match props. get ( "Data" ) . expect ( "variant key missing" ) {
1165- SchemaRef :: Inline ( s) => s,
1166- _ => panic ! ( "Expected inline inner schema" ) ,
1152+ let SchemaRef :: Inline ( inner) = props. get ( "Data" ) . expect ( "variant key missing" ) else {
1153+ panic ! ( "Expected inline inner schema" )
11671154 } ;
11681155 let inner_props = inner. properties . as_ref ( ) . expect ( "inner props missing" ) ;
11691156
@@ -1179,12 +1166,10 @@ mod tests {
11791166 // Should have allOf with the original $ref
11801167 let all_of = schema. all_of . as_ref ( ) . expect ( "allOf missing" ) ;
11811168 assert_eq ! ( all_of. len( ) , 1 ) ;
1182- match & all_of[ 0 ] {
1183- SchemaRef :: Ref ( reference) => {
1184- assert_eq ! ( reference. ref_path, "#/components/schemas/User" ) ;
1185- }
1186- _ => panic ! ( "Expected $ref in allOf" ) ,
1187- }
1169+ let SchemaRef :: Ref ( reference) = & all_of[ 0 ] else {
1170+ panic ! ( "Expected $ref in allOf" )
1171+ } ;
1172+ assert_eq ! ( reference. ref_path, "#/components/schemas/User" ) ;
11881173 }
11891174 SchemaRef :: Ref ( _) => panic ! ( "Expected inline schema with allOf, not direct $ref" ) ,
11901175 }
@@ -1589,9 +1574,9 @@ mod tests {
15891574 . properties
15901575 . as_ref ( )
15911576 . expect ( "variant props missing" ) ;
1592- let inner = match props. get ( "Empty" ) . expect ( "Empty key missing" ) {
1593- SchemaRef :: Inline ( s ) => s ,
1594- _ => panic ! ( "Expected inline schema" ) ,
1577+ let SchemaRef :: Inline ( inner) = props. get ( "Empty" ) . expect ( "Empty key missing" )
1578+ else {
1579+ panic ! ( "Expected inline schema" )
15951580 } ;
15961581 // Empty struct should have properties: None and required: None
15971582 assert ! ( inner. properties. is_none( ) ) ;
0 commit comments