forked from loafle/openapi-generator-original
Fix generation of map model examples (#8063)
When generation examples of objects with additional properties, we use the map syntax inside a model instantiation, which is incorrect. This fixes it by checking for model at the right place.
This commit is contained in:
@@ -1072,7 +1072,10 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
|
||||
key = addPropsSchema.getEnum().get(0).toString();
|
||||
}
|
||||
addPropsExample = exampleFromStringOrArraySchema(addPropsSchema, addPropsExample, key);
|
||||
String addPropPrefix = ensureQuotes(key) + ": ";
|
||||
String addPropPrefix = key + "=";
|
||||
if (modelName == null) {
|
||||
addPropPrefix = ensureQuotes(key) + ": ";
|
||||
}
|
||||
String addPropsModelName = getModelName(addPropsSchema);
|
||||
example = fullPrefix + "\n" + toExampleValueRecursive(addPropsModelName, addPropsSchema, addPropsExample, indentationLevel + 1, addPropPrefix, exampleLine + 1) + ",\n" + closingIndentation + closeChars;
|
||||
} else {
|
||||
|
||||
@@ -51,7 +51,7 @@ with petstore_api.ApiClient() as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = fake_api.FakeApi(api_client)
|
||||
additional_properties_with_array_of_enums = AdditionalPropertiesWithArrayOfEnums(
|
||||
"key": [
|
||||
key=[
|
||||
EnumClass("-efg"),
|
||||
],
|
||||
) # AdditionalPropertiesWithArrayOfEnums | Input enum (optional)
|
||||
|
||||
Reference in New Issue
Block a user