diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index a154c21f49f3..1c878f90708e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -258,13 +258,12 @@ public Map postProcessAllModels(Map objs) { } /** - * Loop through all models to update different flags (e.g. isSelfReference), children models, etc + * Index all CodegenModels by model name. * * @param objs Map of models - * @return maps of models with various updates + * @return map of all models indexed by names */ - public Map updateAllModels(Map objs) { - // Index all CodegenModels by model name. + public Map getAllModels(Map objs) { Map allModels = new HashMap(); for (Entry entry : objs.entrySet()) { String modelName = toModelName(entry.getKey()); @@ -275,6 +274,17 @@ public Map updateAllModels(Map objs) { allModels.put(modelName, cm); } } + return allModels; + } + + /** + * Loop through all models to update different flags (e.g. isSelfReference), children models, etc + * + * @param objs Map of models + * @return maps of models with various updates + */ + public Map updateAllModels(Map objs) { + Map allModels = getAllModels(objs); // Fix up all parent and interface CodegenModel references. for (CodegenModel cm : allModels.values()) { @@ -1859,7 +1869,7 @@ public CodegenModel fromModel(String name, Schema schema) { if (composed.getAllOf() != null) { int modelImplCnt = 0; // only one inline object allowed in a ComposedModel int modelDiscriminators = 0; // only one discriminator allowed in a ComposedModel - for (Schema innerSchema : composed.getAllOf()) { // TOOD need to work with anyOf, oneOf as well + for (Schema innerSchema : composed.getAllOf()) { // TODO need to work with anyOf, oneOf as well if (m.discriminator == null && innerSchema.getDiscriminator() != null) { LOGGER.debug("discriminator is set to null (not correctly set earlier): {}", name); m.discriminator = createDiscriminator(name, innerSchema);