Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Refactor: breaking allModels indexing apart from updateAllModels #4753

Merged
merged 2 commits into from
Dec 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,12 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> 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<String, Object> updateAllModels(Map<String, Object> objs) {
// Index all CodegenModels by model name.
public Map<String, CodegenModel> getAllModels(Map<String, Object> objs) {
Map<String, CodegenModel> allModels = new HashMap<String, CodegenModel>();
for (Entry<String, Object> entry : objs.entrySet()) {
String modelName = toModelName(entry.getKey());
Expand All @@ -275,6 +274,17 @@ public Map<String, Object> updateAllModels(Map<String, Object> 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<String, Object> updateAllModels(Map<String, Object> objs) {
Map<String, CodegenModel> allModels = getAllModels(objs);

// Fix up all parent and interface CodegenModel references.
for (CodegenModel cm : allModels.values()) {
Expand Down Expand Up @@ -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);
Expand Down