From 157ad1ce738200de673abc2f2cbba8b5aee4b768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Herv=C3=A9?= Date: Thu, 26 Nov 2020 11:01:34 +0100 Subject: [PATCH] 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 --- .../openapitools/codegen/languages/PythonClientCodegen.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index 5b91b6bb5cd..23016b2bba6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -1048,6 +1048,10 @@ public class PythonClientCodegen extends PythonLegacyClientCodegen { } return fullPrefix + example + closeChars; } 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; Schema itemSchema = arrayschema.getItems(); String itemModelName = getModelName(itemSchema);