Skip to content

Commit a9c9bca

Browse files
committed
fix/ x-enum-varnames in python
1 parent 701b6bd commit a9c9bca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,10 @@ private ModelsMap postProcessModelsMap(ModelsMap objs) {
958958
for (Map<String, Object> enumVars : (List<Map<String, Object>>) model.getAllowableValues().get("enumVars")) {
959959
if ((Boolean) enumVars.get("isString")) {
960960
model.vendorExtensions.putIfAbsent("x-py-enum-type", "str");
961-
// update `name`, e.g.
962-
enumVars.put("name", toEnumVariableName((String) enumVars.get("value"), "str"));
961+
// Do not overwrite the variable name if already set through x-enum-varnames
962+
if (model.vendorExtensions.get("x-enum-varnames") == null) {
963+
enumVars.put("name", toEnumVariableName((String) enumVars.get("value"), "str"));
964+
}
963965
} else {
964966
model.vendorExtensions.putIfAbsent("x-py-enum-type", "int");
965967
// Do not overwrite the variable name if already set through x-enum-varnames

0 commit comments

Comments
 (0)