@@ -114,7 +114,7 @@ impl TryFrom<SchemaObject> for Object {
114114 attributes,
115115 docstring : schema_obj. description . unwrap_or_default ( ) ,
116116 term : None ,
117- parent : None ,
117+ mixins : Vec :: new ( ) ,
118118 position : None ,
119119 } )
120120 }
@@ -174,6 +174,21 @@ impl TryFrom<Property> for Attribute {
174174 }
175175 }
176176
177+ if let Some ( all_of) = property. all_of {
178+ if all_of. len ( ) == 1 {
179+ dtypes. extend (
180+ all_of[ 0 ]
181+ . get_types ( )
182+ . into_iter ( )
183+ . map ( extract_reference)
184+ . collect :: < Result < Vec < String > , String > > ( ) ?,
185+ ) ;
186+ } else {
187+ // TODO: Implement allOf with multiple items
188+ unimplemented ! ( "allOf with multiple items is not supported yet" ) ;
189+ }
190+ }
191+
177192 Ok ( Attribute {
178193 name : property. title . unwrap_or ( "MISSING_TITLE" . to_string ( ) ) ,
179194 is_array,
@@ -186,7 +201,6 @@ impl TryFrom<Property> for Attribute {
186201 options : parse_options ( & property. options ) ?,
187202 term : property. term ,
188203 required : false ,
189- // TODO: Implement default
190204 default : None ,
191205 xml : None ,
192206 is_enum : false ,
@@ -590,6 +604,68 @@ mod tests {
590604 assert_eq ! ( attribute. import_prefix, None ) ;
591605 }
592606
607+ /// Tests the parsing of a property with oneOf (multiple types)
608+ ///
609+ /// This test verifies that a property with multiple possible types
610+ /// is correctly converted to an Attribute with all types included.
611+ #[ test]
612+ fn test_parse_property_with_one_of_mixed ( ) {
613+ let property = json ! ( {
614+ "title" : "number" ,
615+ "oneOf" : [
616+ {
617+ "$ref" : "#/$defs/Test"
618+ } ,
619+ {
620+ "type" : "string"
621+ }
622+ ]
623+ } ) ;
624+
625+ let property: Property = serde_json:: from_value ( property) . unwrap ( ) ;
626+ let attribute = Attribute :: try_from ( property) . unwrap ( ) ;
627+
628+ assert_eq ! ( attribute. name, "number" ) ;
629+ assert_eq ! (
630+ attribute. dtypes. into_iter( ) . collect:: <HashSet <_>>( ) ,
631+ vec![ "Test" . to_string( ) , "string" . to_string( ) ]
632+ . into_iter( )
633+ . collect:: <HashSet <_>>( )
634+ ) ;
635+ assert_eq ! ( attribute. docstring, "" ) ;
636+ assert_eq ! ( attribute. term, None ) ;
637+ assert ! ( !attribute. required) ;
638+ assert_eq ! ( attribute. default , None ) ;
639+ assert_eq ! ( attribute. xml, None ) ;
640+ assert ! ( !attribute. is_array) ;
641+ assert ! ( !attribute. is_enum) ;
642+ assert_eq ! ( attribute. position, None ) ;
643+ assert_eq ! ( attribute. import_prefix, None ) ;
644+ }
645+
646+ /// Tests the parsing of a property with allOf (multiple types)
647+ ///
648+ /// This test verifies that a property with multiple possible types
649+ /// is correctly converted to an Attribute with all types included.
650+ #[ test]
651+ #[ should_panic]
652+ fn test_parse_property_with_all_of ( ) {
653+ let property = json ! ( {
654+ "title" : "number" ,
655+ "allOf" : [
656+ {
657+ "type" : "number"
658+ } ,
659+ {
660+ "type" : "string"
661+ }
662+ ]
663+ } ) ;
664+
665+ let property: Property = serde_json:: from_value ( property) . unwrap ( ) ;
666+ Attribute :: try_from ( property) . unwrap ( ) ;
667+ }
668+
593669 /// Tests the parsing of a property with a reference
594670 ///
595671 /// This test verifies that a property with a reference to another type
0 commit comments