@@ -2488,6 +2488,9 @@ public CodegenModel fromModel(String name, Schema schema) {
24882488
24892489 // interfaces (schemas defined in allOf, anyOf, oneOf)
24902490 List <Schema > interfaces = ModelUtils .getInterfaces (composed );
2491+ List <CodegenProperty > anyOfProps = new ArrayList <>();
2492+ List <CodegenProperty > allOfProps = new ArrayList <>();
2493+ List <CodegenProperty > oneOfProps = new ArrayList <>();
24912494 if (!interfaces .isEmpty ()) {
24922495 // m.interfaces is for backward compatibility
24932496 if (m .interfaces == null )
@@ -2499,11 +2502,11 @@ public CodegenModel fromModel(String name, Schema schema) {
24992502 if (StringUtils .isBlank (interfaceSchema .get$ref ())) {
25002503 // primitive type
25012504 String languageType = getTypeDeclaration (interfaceSchema );
2505+ CodegenProperty interfaceProperty = fromProperty (languageType , interfaceSchema );
25022506 if (ModelUtils .isArraySchema (interfaceSchema ) || ModelUtils .isMapSchema (interfaceSchema )) {
2503- CodegenProperty cp = fromProperty ("composedSchemaImports" , interfaceSchema );
2504- while (cp != null ) {
2505- addImport (m , cp .complexType );
2506- cp = cp .items ;
2507+ while (interfaceProperty != null ) {
2508+ addImport (m , interfaceProperty .complexType );
2509+ interfaceProperty = interfaceProperty .items ;
25072510 }
25082511 }
25092512
@@ -2512,12 +2515,15 @@ public CodegenModel fromModel(String name, Schema schema) {
25122515 LOGGER .warn ("{} (anyOf schema) already has `{}` defined and therefore it's skipped." , m .name , languageType );
25132516 } else {
25142517 m .anyOf .add (languageType );
2518+ anyOfProps .add (interfaceProperty );
2519+
25152520 }
25162521 } else if (composed .getOneOf () != null ) {
25172522 if (m .oneOf .contains (languageType )) {
25182523 LOGGER .warn ("{} (oneOf schema) already has `{}` defined and therefore it's skipped." , m .name , languageType );
25192524 } else {
25202525 m .oneOf .add (languageType );
2526+ oneOfProps .add (interfaceProperty );
25212527 }
25222528 } else if (composed .getAllOf () != null ) {
25232529 // no need to add primitive type to allOf, which should comprise of schemas (models) only
@@ -2534,6 +2540,7 @@ public CodegenModel fromModel(String name, Schema schema) {
25342540 refSchema = allDefinitions .get (ref );
25352541 }
25362542 final String modelName = toModelName (ref );
2543+ CodegenProperty interfaceProperty = fromProperty (modelName , interfaceSchema );
25372544 m .interfaces .add (modelName );
25382545 addImport (m , modelName );
25392546 if (allDefinitions != null && refSchema != null ) {
@@ -2552,16 +2559,23 @@ public CodegenModel fromModel(String name, Schema schema) {
25522559
25532560 if (composed .getAnyOf () != null ) {
25542561 m .anyOf .add (modelName );
2562+ anyOfProps .add (interfaceProperty );
25552563 } else if (composed .getOneOf () != null ) {
25562564 m .oneOf .add (modelName );
2565+ oneOfProps .add (interfaceProperty );
25572566 } else if (composed .getAllOf () != null ) {
25582567 m .allOf .add (modelName );
2568+ allOfProps .add (interfaceProperty );
25592569 } else {
25602570 LOGGER .error ("Composed schema has incorrect anyOf, allOf, oneOf defined: {}" , composed );
25612571 }
25622572 }
25632573 }
25642574
2575+ m .vendorExtensions .put ("x-oneOf-as-properties" , oneOfProps );
2576+ m .vendorExtensions .put ("x-allOf-as-properties" , allOfProps );
2577+ m .vendorExtensions .put ("x-anyOf-as-properties" , anyOfProps );
2578+
25652579 if (parent != null && composed .getAllOf () != null ) { // set parent for allOf only
25662580 m .parentSchema = parentName ;
25672581 m .parent = toModelName (parentName );
0 commit comments