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();
|
List<MappedModel> uniqueDescendants = new ArrayList();
|
||||||
if (sourceDiscriminator.getMapping() != null && !sourceDiscriminator.getMapping().isEmpty()) {
|
if (sourceDiscriminator.getMapping() != null && !sourceDiscriminator.getMapping().isEmpty()) {
|
||||||
for (Entry<String, String> e : sourceDiscriminator.getMapping().entrySet()) {
|
for (Entry<String, String> e : sourceDiscriminator.getMapping().entrySet()) {
|
||||||
String nameOrRef = e.getValue();
|
String name;
|
||||||
String name = nameOrRef.indexOf('/') >= 0 ? ModelUtils.getSimpleRef(nameOrRef) : nameOrRef;
|
if (e.getValue().indexOf('/') >= 0) {
|
||||||
String modelName = toModelName(name);
|
name = ModelUtils.getSimpleRef(e.getValue());
|
||||||
uniqueDescendants.add(new MappedModel(e.getKey(), modelName));
|
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