Fix list examples in python (#7967)

* Fix list examples in python

When a model has an example in an array, it wrongly wraps it again in a
list instead of returning the list examples. This fixes it.

* Add comment
This commit is contained in:
Thomas Hervé 2020-11-26 11:01:34 +01:00 committed by GitHub
parent cf185d559b
commit 157ad1ce73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1048,6 +1048,10 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen {
} }
return fullPrefix + example + closeChars; return fullPrefix + example + closeChars;
} else if (ModelUtils.isArraySchema(schema)) { } else if (ModelUtils.isArraySchema(schema)) {
if (objExample instanceof Iterable) {
// If the example is already a list, return it directly instead of wrongly wrap it in another list
return objExample.toString();
}
ArraySchema arrayschema = (ArraySchema) schema; ArraySchema arrayschema = (ArraySchema) schema;
Schema itemSchema = arrayschema.getItems(); Schema itemSchema = arrayschema.getItems();
String itemModelName = getModelName(itemSchema); String itemModelName = getModelName(itemSchema);