@@ -507,7 +507,8 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
507507 // add the model to the discriminator's mapping so templates have access to more than just the string to string mapping
508508 if (model .discriminator != null && model .discriminator .getMappedModels () != null ) {
509509 for (CodegenDiscriminator .MappedModel mappedModel : model .discriminator .getMappedModels ()) {
510- CodegenModel mappedCodegenModel = ModelUtils .getModelByName (mappedModel .getModelName (), objs );
510+ String lookupName = mappedModel .getSchemaName () != null ? mappedModel .getSchemaName () : mappedModel .getModelName ();
511+ CodegenModel mappedCodegenModel = ModelUtils .getModelByName (lookupName , objs );
511512 mappedModel .setModel (mappedCodegenModel );
512513 }
513514 }
@@ -3574,7 +3575,7 @@ protected List<MappedModel> getOneOfAnyOfDescendants(String composedSchemaName,
35743575 once (LOGGER ).warn ("'{}' defines discriminator '{}', but the referenced schema '{}' is incorrect. {}" ,
35753576 composedSchemaName , discPropName , modelName , msgSuffix );
35763577 }
3577- MappedModel mm = new MappedModel (modelName , toModelName (modelName ));
3578+ MappedModel mm = new MappedModel (modelName , toModelName (modelName ), modelName , false );
35783579 descendentSchemas .add (mm );
35793580 Schema cs = ModelUtils .getSchema (openAPI , modelName );
35803581 if (cs == null ) { // cannot lookup the model based on the name
@@ -3583,7 +3584,7 @@ protected List<MappedModel> getOneOfAnyOfDescendants(String composedSchemaName,
35833584 Map <String , Object > vendorExtensions = cs .getExtensions ();
35843585 if (vendorExtensions != null && !vendorExtensions .isEmpty () && vendorExtensions .containsKey (X_DISCRIMINATOR_VALUE )) {
35853586 String xDiscriminatorValue = (String ) vendorExtensions .get (X_DISCRIMINATOR_VALUE );
3586- mm = new MappedModel (xDiscriminatorValue , toModelName (modelName ), true );
3587+ mm = new MappedModel (xDiscriminatorValue , toModelName (modelName ), modelName , true );
35873588 descendentSchemas .add (mm );
35883589 }
35893590 }
@@ -3641,7 +3642,7 @@ protected List<MappedModel> getAllOfDescendants(String thisSchemaName) {
36413642 .map (ve -> ve .get (X_DISCRIMINATOR_VALUE ))
36423643 .map (discriminatorValue -> (String ) discriminatorValue )
36433644 .orElse (currentSchemaName );
3644- MappedModel mm = new MappedModel (mappingName , toModelName (currentSchemaName ), !mappingName .equals (currentSchemaName ));
3645+ MappedModel mm = new MappedModel (mappingName , toModelName (currentSchemaName ), currentSchemaName , !mappingName .equals (currentSchemaName ));
36453646 descendentSchemas .add (mm );
36463647 }
36473648 return descendentSchemas ;
@@ -3687,7 +3688,7 @@ protected CodegenDiscriminator createDiscriminator(String schemaName, Schema sch
36873688 } else {
36883689 name = e .getValue ();
36893690 }
3690- uniqueDescendants .add (new MappedModel (e .getKey (), toModelName (name ), true ));
3691+ uniqueDescendants .add (new MappedModel (e .getKey (), toModelName (name ), name , true ));
36913692 }
36923693 }
36933694
0 commit comments