forked from loafle/openapi-generator-original
show error when schema in discriminator mapping is undefined (#11127)
This commit is contained in:
parent
b2daa5a836
commit
c27ddc67fe
@ -3170,10 +3170,16 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
List<MappedModel> uniqueDescendants = new ArrayList();
|
||||
if (sourceDiscriminator.getMapping() != null && !sourceDiscriminator.getMapping().isEmpty()) {
|
||||
for (Entry<String, String> e : sourceDiscriminator.getMapping().entrySet()) {
|
||||
String nameOrRef = e.getValue();
|
||||
String name = nameOrRef.indexOf('/') >= 0 ? ModelUtils.getSimpleRef(nameOrRef) : nameOrRef;
|
||||
String modelName = toModelName(name);
|
||||
uniqueDescendants.add(new MappedModel(e.getKey(), modelName));
|
||||
String name;
|
||||
if (e.getValue().indexOf('/') >= 0) {
|
||||
name = ModelUtils.getSimpleRef(e.getValue());
|
||||
if (ModelUtils.getSchema(openAPI, name) == null) {
|
||||
LOGGER.error("Failed to lookup the schema '{}' when processing the discriminator mapping of oneOf/anyOf. Please check to ensure it's defined properly.", name);
|
||||
}
|
||||
} else {
|
||||
name = e.getValue();
|
||||
}
|
||||
uniqueDescendants.add(new MappedModel(e.getKey(), toModelName(name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user