[Bug] [Python] Fix #2092 python docs example quoting (#2669)

* replaced setParameterExampleValue method

* removed old method

* fixed bool, test fix for objects

* continued fix

* double override

* regenerated petstore client

* regenerated oas3 sample

* updated asyncio and tornado generated clients for CI
This commit is contained in:
Tim Bedard
2019-04-16 21:49:50 -05:00
committed by William Cheng
parent 4b84821506
commit 3d92ea0eda
5 changed files with 29 additions and 9 deletions

View File

@@ -17,8 +17,10 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
@@ -704,7 +706,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
}
if (example == null) {
example = "NULL";
example = "None";
} else if (Boolean.TRUE.equals(p.isListContainer)) {
example = "[" + example + "]";
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
@@ -714,6 +716,24 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
p.example = example;
}
@Override
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
Schema schema = parameter.getSchema();
if (parameter.getExample() != null) {
codegenParameter.example = parameter.getExample().toString();
} else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
Example example = parameter.getExamples().values().iterator().next();
if (example.getValue() != null) {
codegenParameter.example = example.getValue().toString();
}
} else if (schema != null && schema.getExample() != null) {
codegenParameter.example = schema.getExample().toString();
}
setParameterExampleValue(codegenParameter);
}
@Override
public String sanitizeTag(String tag) {
return sanitizeName(tag);