Skip to content

Commit

Permalink
Different approach
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMattijs committed May 3, 2024
1 parent b8696d9 commit 3d94276
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,8 @@ public Map<String, ModelsMap> postProcessAllModels(Map<String, ModelsMap> objs)
}

private ModelsMap postProcessModelsMap(ModelsMap objs) {
// process enum in models
objs = postProcessModelsEnum(objs);

// TODO: migrate almost (all?) everything to the `PythonImports` class.
TreeSet<String> modelImports = new TreeSet<>();
Expand Down Expand Up @@ -990,7 +992,10 @@ private ModelsMap postProcessModelsMap(ModelsMap objs) {
enumVars.put("name", toEnumVariableName((String) enumVars.get("value"), "str"));
} else {
model.vendorExtensions.putIfAbsent("x-py-enum-type", "int");
enumVars.put("name", toEnumVariableName((String) enumVars.get("value"), "int"));
// Do not overwrite the variable name if already set through x-enum-varnames
if (model.vendorExtensions.get("x-enum-varnames") == null) {
enumVars.put("name", toEnumVariableName((String) enumVars.get("value"), "int"));
}
}
}
}
Expand Down Expand Up @@ -1038,8 +1043,7 @@ private ModelsMap postProcessModelsMap(ModelsMap objs) {
}
}

// process enum in models
return postProcessModelsEnum(objs);
return objs;
}


Expand Down

0 comments on commit 3d94276

Please sign in to comment.