From 24aad07717e52c27245fa57f5e31476d876ba95b Mon Sep 17 00:00:00 2001 From: Justin Black Date: Sun, 2 Aug 2020 22:13:29 -0700 Subject: [PATCH 1/7] Adds example setting code in python-experimental with one fn setting example values Fixes sample indentations Handles composed schema models, object model and arraymodels Adds brackets in arraymodel input Sets modelName with map schemas Removes included_schemas arguments, dicriminator examples do not include property examples Refactors modelName into toExampleValueRecursive argument Fixes bug where example models contained themselves Stops using model ExampleGenerator examples because they are inconsistent with the ones in python-experimental Uses example values if they exist Removes single quotes from enum examples Fixes password example Adds commented our regex handling, commented out because it breaks Handles AnyType schema examples Adds x_example values for simple string properties, uses toExampleValue for all example generation Adds examples for simple string parameters Updates comments in toExampleValueBase Fixes the double nested bug for AdditionalPropertiesWithArrayOfEnums Fixes bug where NumberWithValidations had double nesting Updates simple string examples in arrays Fixes array string examples Fixes example for string endpoint body example Adds exampleFromStringOrArraySchema Adds regex examples, pegs slf4j-version to v1.7.29 for rgxgen Adds comment about regex seed Updates pattern matcher to not handle ^ and $ Updates used sample values Adds ensureQuotes Adds ensureQuotes Fixes double quote bug Updates mustache file Adds ensureQuotes to key handling Adds modelNameToSchema map, reduces run time by using it Fixes java tests Regenerates python-experimental samples Fixes python test --- modules/openapi-generator-core/pom.xml | 2 +- modules/openapi-generator/pom.xml | 6 + .../openapitools/codegen/DefaultCodegen.java | 2 +- .../PythonClientExperimentalCodegen.java | 615 ++++++++++++++++-- .../api_doc_example.mustache | 65 +- .../python/PythonClientExperimentalTest.java | 2 +- .../src/test/resources/2_0/v1beta3.json | 9 +- ...odels-for-testing-with-http-signature.yaml | 28 + pom.xml | 2 +- .../petstore/python-experimental/README.md | 4 +- .../python-experimental/docs/Animal.md | 2 +- .../docs/AnotherFakeApi.md | 6 +- .../petstore/python-experimental/docs/Cat.md | 2 +- .../python-experimental/docs/Category.md | 2 +- .../petstore/python-experimental/docs/Dog.md | 2 +- .../python-experimental/docs/EnumClass.md | 2 +- .../python-experimental/docs/FakeApi.md | 184 ++++-- .../docs/FakeClassnameTags123Api.md | 6 +- .../python-experimental/docs/PetApi.md | 84 ++- .../python-experimental/docs/StoreApi.md | 21 +- .../docs/TypeHolderDefault.md | 2 +- .../docs/TypeHolderExample.md | 2 +- .../python-experimental/docs/UserApi.md | 74 ++- .../petstore_api/api/fake_api.py | 18 +- .../petstore_api/model/animal.py | 2 +- .../petstore_api/model/cat.py | 2 +- .../petstore_api/model/category.py | 4 +- .../petstore_api/model/dog.py | 2 +- .../petstore_api/model/enum_class.py | 2 +- .../petstore_api/model/type_holder_default.py | 4 +- .../petstore_api/model/type_holder_example.py | 4 +- .../python-experimental/docs/UsageApi.md | 8 +- .../python-experimental/docs/UsageApi.md | 4 +- .../petstore/python-experimental/README.md | 5 +- .../python-experimental/docs/Animal.md | 2 +- .../docs/AnotherFakeApi.md | 6 +- .../petstore/python-experimental/docs/Cat.md | 2 +- .../python-experimental/docs/Category.md | 2 +- .../ComposedOneOfNumberWithValidations.md | 2 +- .../python-experimental/docs/DefaultApi.md | 2 +- .../petstore/python-experimental/docs/Dog.md | 2 +- .../python-experimental/docs/EnumClass.md | 2 +- .../python-experimental/docs/FakeApi.md | 231 +++++-- .../docs/FakeClassnameTags123Api.md | 6 +- .../petstore/python-experimental/docs/Foo.md | 2 +- .../python-experimental/docs/FormatTest.md | 1 + .../python-experimental/docs/InlineObject2.md | 2 +- .../python-experimental/docs/PetApi.md | 80 ++- .../python-experimental/docs/StoreApi.md | 21 +- .../python-experimental/docs/StringEnum.md | 4 +- .../docs/StringEnumWithDefaultValue.md | 2 +- .../python-experimental/docs/UserApi.md | 90 ++- .../petstore_api/api/fake_api.py | 127 +++- .../petstore_api/model/animal.py | 2 +- .../petstore_api/model/cat.py | 2 +- .../petstore_api/model/category.py | 4 +- ...composed_one_of_number_with_validations.py | 2 +- .../petstore_api/model/dog.py | 2 +- .../petstore_api/model/enum_class.py | 2 +- .../petstore_api/model/foo.py | 2 +- .../petstore_api/model/format_test.py | 3 + .../petstore_api/model/inline_object2.py | 2 +- .../petstore_api/model/string_enum.py | 9 +- .../model/string_enum_with_default_value.py | 2 +- .../tests_manual/test_string_enum.py | 5 +- 65 files changed, 1446 insertions(+), 356 deletions(-) diff --git a/modules/openapi-generator-core/pom.xml b/modules/openapi-generator-core/pom.xml index dc45dda9eea3..986e9859b474 100644 --- a/modules/openapi-generator-core/pom.xml +++ b/modules/openapi-generator-core/pom.xml @@ -72,7 +72,7 @@ - 1.7.12 + 1.7.29 26.0-jre diff --git a/modules/openapi-generator/pom.xml b/modules/openapi-generator/pom.xml index 0262582d8845..ecb1f58bb663 100644 --- a/modules/openapi-generator/pom.xml +++ b/modules/openapi-generator/pom.xml @@ -258,6 +258,7 @@ 1.3.0 26.0-jre 1.0.2 + 1.1 2.10.1 2.10.0 1.3.60 @@ -373,6 +374,11 @@ generex ${generex-version} + + com.github.curious-odd-man + rgxgen + ${rxgen-version} + com.fasterxml.jackson.datatype jackson-datatype-jsr310 diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 92a3f76b7600..2d7c4f2a2e2e 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -6191,7 +6191,7 @@ public List fromServerVariables(Map allDefinitions = ModelUtils.getSchemas(openAPI); +// for (Map.Entry entry: allDefinitions.entrySet()) { +// Schema modelSchema = entry.getValue(); +// if (modelWillBeMade(modelSchema)) { +// String schemaName = entry.getKey(); +// String schemaModelName = toModelName(schemaName); +// modelNameToSchema.put(schemaModelName, modelSchema); +// } +// } +// } + /** * Configures a friendly name for the generator. This will be used by the * generator to select the library with the -g flag. @@ -305,11 +330,7 @@ public String toDefaultValue(Schema p) { } if (!ModelUtils.isByteArraySchema(p) && !ModelUtils.isBinarySchema(p) && !ModelUtils.isFileSchema(p) && !ModelUtils.isUUIDSchema(p) && !ModelUtils.isEmailSchema(p) && !ModelUtils.isDateTimeSchema(p) && !ModelUtils.isDateSchema(p)) { - if (Pattern.compile("\r\n|\r|\n").matcher((String) defaultValue).find()) { - defaultValue = "'''" + defaultValue + "'''"; - } else { - defaultValue = "'" + defaultValue + "'"; - } + defaultValue = ensureQuotes(defaultValue); } return defaultValue; } else if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) { @@ -489,13 +510,6 @@ public CodegenParameter fromRequestBody(RequestBody body, Set imports, S String simpleDataType = result.dataType; result.dataType = toModelName(modelName); result.baseType = result.dataType; - // set the example value - if (modelProp.isEnum) { - String value = modelProp._enum.get(0).toString(); - result.example = result.dataType + "(" + toEnumValue(value, simpleDataType) + ")"; - } else { - result.example = result.dataType + "(" + result.example + ")"; - } } return result; } @@ -656,7 +670,7 @@ public String toEnumValue(String value, String datatype) { if (datatype.equals("int") || datatype.equals("float")) { return value; } else { - return "\"" + escapeText(value) + "\""; + return ensureQuotes(value); } } @@ -962,6 +976,18 @@ public String getSchemaType(Schema schema) { return openAPIType; } + public String getModelName(Schema sc) { + Boolean thisModelWillBeMade = modelWillBeMade(sc); + Map schemas = ModelUtils.getSchemas(openAPI); + for (String thisSchemaName : schemas.keySet()) { + Schema thisSchema = schemas.get(thisSchemaName); + if (thisSchema == sc && thisModelWillBeMade) { + return toModelName(thisSchemaName); + } + } + return null; + } + /** * Output the type declaration of the property * @@ -978,11 +1004,27 @@ public String getSimpleTypeDeclaration(Schema schema) { public Boolean modelWillBeMade(Schema s) { // only invoke this on $refed schemas - if (ModelUtils.isComposedSchema(s) || ModelUtils.isArraySchema(s) || ModelUtils.isObjectSchema(s)) { + if (ModelUtils.isComposedSchema(s) || ModelUtils.isObjectSchema(s) || ModelUtils.isArraySchema(s) || ModelUtils.isMapSchema(s)) { return true; } - CodegenProperty cp = fromProperty("_model", s); - if (cp.isEnum || cp.hasValidation) { + List enums = s.getEnum(); + if (enums != null && !enums.isEmpty()) { + return true; + } + Boolean hasValidation = ( + s.getMaxItems() != null || + s.getMinLength() != null || + s.getMinItems() != null || + s.getMultipleOf() != null || + s.getPattern() != null || + s.getMaxLength() != null || + s.getMinimum() != null || + s.getMaximum() != null || + s.getExclusiveMaximum() != null || + s.getExclusiveMinimum() != null || + s.getUniqueItems() != null + ); + if (hasValidation) { return true; } return false; @@ -1106,71 +1148,528 @@ protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Sc // to false, i.e. no additional properties are allowed. } - @Override - public void setParameterExampleValue(CodegenParameter p) { - // we have a custom version of this function so we can set the file - // type example value - String example; + protected String toExampleValueBase(Schema sc) { + Schema schema = sc; + String ref = sc.get$ref(); + if (ref != null) { + schema = ModelUtils.getSchema(this.openAPI, ModelUtils.getSimpleRef(ref)); + } + // TODO handle examples in object models in the future + Boolean objectModel = (ModelUtils.isObjectSchema(schema) || ModelUtils.isMapSchema(schema) || ModelUtils.isComposedSchema(schema)); + if (objectModel) { + return null; + } + String example = null; + String defaultValue = toDefaultValue(schema); + if (schema.getExample() != null) { + example = schema.getExample().toString(); + } else if (defaultValue != null) { + example = defaultValue; + } else if (schema.getEnum() != null && !schema.getEnum().isEmpty()) { + example = schema.getEnum().get(0).toString(); + } + if (ModelUtils.isStringSchema(schema) && example != null && example.length() >= 2) { + // TODO check to see if example does not have quotes on it + // if it lacks them add double quotes + // TODO update the string handling code to just use the value without adding quotes + char firstChar = example.charAt(0); + char lastChar = example.charAt(example.length() - 1); + char quoteChar = "'".charAt(0); + if (firstChar == quoteChar && lastChar == quoteChar) { + example = example.substring(1, example.length()-1); + } + } + return example; + } - if (p.defaultValue == null) { - example = p.example; - } else { - p.example = p.defaultValue; - return; + /*** + * Ensures that the string has a leading and trailing quote + * + * @param in input string + * @return quoted string + */ + public String ensureQuotes(String in) { + Pattern pattern = Pattern.compile("\r\n|\r|\n"); + Matcher matcher = pattern.matcher(in); + if (matcher.find()) { + // if a string has a new line in it add triple quotes to make it a python multiline string + return "'''" + in + "'''"; + } + String strPattern = "^['\"].*?['\"]$"; + if (in.matches(strPattern)) { + return in; } + return "\"" + in + "\""; + } - String type = p.baseType; - if (type == null) { - type = p.dataType; + public String toExampleValue(Schema schema, Object objExample) { + String modelName = getModelName(schema); + return toExampleValueRecursive(modelName, schema, objExample, 1, "", 0); + } + + private Boolean simpleStringSchema(Schema schema) { + Schema sc = schema; + String ref = schema.get$ref(); + if (ref != null) { + sc = ModelUtils.getSchema(this.openAPI, ModelUtils.getSimpleRef(ref)); + } + if (ModelUtils.isStringSchema(sc) && !ModelUtils.isDateSchema(sc) && !ModelUtils.isDateTimeSchema(sc) && !"Number".equalsIgnoreCase(sc.getFormat()) && !ModelUtils.isByteArraySchema(sc) && !ModelUtils.isBinarySchema(sc) && schema.getPattern() == null) { + return true; } + return false; + } - if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) { + private MappedModel getDiscriminatorMappedModel(CodegenDiscriminator disc) { + for ( MappedModel mm : disc.getMappedModels() ) { + String modelName = mm.getModelName(); + Schema modelSchema = getModelNameToSchemaCache().get(modelName); + if (ModelUtils.isObjectSchema(modelSchema)) { + return mm; + } + } + return null; + } + + /*** + * Recursively generates string examples for schemas + * + * @param modelName the string name of the refed model that will be generated for the schema or null + * @param schema the schema that we need an example for + * @param objExample the example that applies to this schema, for now only string example are used + * @param indentationLevel integer indentation level that we are currently at + * we assume the indentaion amount is 4 spaces times this integer + * @param prefix the string prefix that we will use when assigning an example for this line + * this is used when setting key: value, pairs "key: " is the prefix + * and this is used when setting properties like some_property='some_property_example' + * @param exampleLine this is the current line that we are generatign an example for, starts at 0 + * we don't indentin the 0th line because using the example value looks like: + * prop = ModelName( line 0 + * some_property='some_property_example' line 1 + * ) line 2 + * and our example value is: + * ModelName( line 0 + * some_property='some_property_example' line 1 + * ) line 2 + * @return the string example + */ + private String toExampleValueRecursive(String modelName, Schema schema, Object objExample, int indentationLevel, String prefix, Integer exampleLine) { + final String indentionConst = " "; + String currentIndentation = ""; + String closingIndentation = ""; + for (int i=0 ; i < indentationLevel ; i++) currentIndentation += indentionConst; + String example = null; + if (objExample instanceof String) { + example = (String) objExample; + } else { + example = toExampleValueBase(schema); + } + if (exampleLine.equals(0)) { + closingIndentation = currentIndentation; + currentIndentation = ""; + } else { + closingIndentation = currentIndentation; + } + String openChars = ""; + String closeChars = ""; + if (modelName != null) { + openChars = modelName+"("; + closeChars = ")"; + } + + String fullPrefix = currentIndentation + prefix + openChars; + + if (null != schema.get$ref()) { + // $ref case: + Map allDefinitions = ModelUtils.getSchemas(this.openAPI); + String ref = ModelUtils.getSimpleRef(schema.get$ref()); + if (allDefinitions != null) { + Schema refSchema = allDefinitions.get(ref); + if (null == refSchema) { + return fullPrefix + "None" + closeChars; + } else { + String refModelName = getModelName(refSchema); + return toExampleValueRecursive(refModelName, refSchema, objExample, indentationLevel, prefix, exampleLine); + } + } else { + LOGGER.warn("allDefinitions not defined in toExampleValue!\n"); + } + } else if (ModelUtils.isNullType(schema) || isAnyTypeSchema(schema)) { + // The 'null' type is allowed in OAS 3.1 and above. It is not supported by OAS 3.0.x, + // though this tooling supports it. + return fullPrefix + "None" + closeChars; + } else if (ModelUtils.isBooleanSchema(schema)) { if (example == null) { - example = p.paramName + "_example"; + example = "True"; + } else { + if ("false".equalsIgnoreCase(example)) { + example = "False"; + } else { + example = "True"; + } } - example = "'" + escapeText(example) + "'"; - } else if ("Integer".equals(type) || "int".equals(type)) { + return fullPrefix + example + closeChars; + } else if (ModelUtils.isDateSchema(schema)) { if (example == null) { - example = "56"; + example = "1970-01-01"; } - } else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) { + example = "datetime.datetime.strptime('" + example + "', '%Y-%m-%d').date()"; + return fullPrefix + example + closeChars; + } else if (ModelUtils.isDateTimeSchema(schema)) { if (example == null) { - example = "3.4"; + example = "1970-01-01T00:00:00.00Z"; } - } else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) { + // TODO add time zone offset to sample + example = "datetime.datetime.strptime('" + example + "', '%Y-%m-%dT%H:%M:%S.%f')"; + return fullPrefix + example + closeChars; + } else if (ModelUtils.isBinarySchema(schema)) { if (example == null) { - example = "True"; + example = "/path/to/file.txt"; + } + example = "open('" + example + "', 'rb')"; + return fullPrefix + example + closeChars; + } else if (ModelUtils.isByteArraySchema(schema)) { + if (example == null) { + example = "'YQ=='"; } - } else if ("file".equalsIgnoreCase(type)) { + return fullPrefix + example + closeChars; + } else if (ModelUtils.isStringSchema(schema)) { if (example == null) { - example = "/path/to/file"; + // a BigDecimal: + if ("Number".equalsIgnoreCase(schema.getFormat())) { + example = "2"; + return fullPrefix + example + closeChars; + } else if (StringUtils.isNotBlank(schema.getPattern())) { + String pattern = schema.getPattern(); + RgxGen rgxGen = new RgxGen(pattern); + // this seed makes it so if we have [a-z] we pick a + Random random = new Random(18); + String sample = rgxGen.generate(random); + // omit leading / and trailing /, omit trailing /i + Pattern valueExtractor = Pattern.compile("^/?(.+?)/?.?$"); + Matcher m = valueExtractor.matcher(sample); + if (m.find()) { + example = m.group(m.groupCount()); + } else { + example = ""; + } + } else if (schema.getMinLength() != null) { + example = ""; + int len = schema.getMinLength().intValue(); + for (int i=0;i requiredAndOptionalProps = schema.getProperties(); + if (requiredAndOptionalProps == null || requiredAndOptionalProps.isEmpty()) { + return fullPrefix + closeChars; + } + + String example = fullPrefix + "\n"; + for (Map.Entry entry : requiredAndOptionalProps.entrySet()) { + String propName = entry.getKey(); + Schema propSchema = entry.getValue(); + propName = toVarName(propName); + String propModelName = null; + Object propExample = null; + if (discProp != null && propName.equals(discProp.name)) { + propModelName = null; + propExample = discProp.example; + } else { + propModelName = getModelName(propSchema); + propExample = toExampleValueBase(propSchema); + propExample = exampleFromStringOrArraySchema(propSchema, propExample, propName); + } + example += toExampleValueRecursive(propModelName, propSchema, propExample, indentationLevel + 1, propName + "=", exampleLine + 1) + ",\n"; + } + // TODO handle additionalProperties also + example += closingIndentation + closeChars; + return example; + } + + private Object exampleFromStringOrArraySchema(Schema sc, Object currentExample, String propName) { + if (currentExample != null) { + return currentExample; + } + String example = null; + if (simpleStringSchema(sc)) { + example = propName + "_example"; + } else if (ModelUtils.isArraySchema(sc)) { + ArraySchema arraySchema = (ArraySchema) sc; + Schema itemSchema = arraySchema.getItems(); + String itemExample = toExampleValueBase(itemSchema); + if (simpleStringSchema(itemSchema) && itemExample == null) { + example = propName + "_example"; + } + } + return example; + } + + + /*** + * + * Set the codegenParameter example value + * We have a custom version of this function so we can invoke toExampleValue + * + * @param codegenParameter the item we are setting the example on + * @param parameter the base parameter that came from the spec + */ + @Override + public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) { + Schema schema = parameter.getSchema(); + if (schema == null) { + LOGGER.warn("CodegenParameter.example defaulting to null because parameter lacks a schema"); + return; + } + + Object example = null; + if (codegenParameter.vendorExtensions != null && codegenParameter.vendorExtensions.containsKey("x-example")) { + example = codegenParameter.vendorExtensions.get("x-example"); + } else if (parameter.getExample() != null) { + example = parameter.getExample(); + } else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty() && parameter.getExamples().values().iterator().next().getValue() != null) { + example = parameter.getExamples().values().iterator().next().getValue(); + } else { + example = toExampleValueBase(schema); + } + example = exampleFromStringOrArraySchema(schema, example, parameter.getName()); + String finalExample = toExampleValue(schema, example); + codegenParameter.example = finalExample; + } + + /** + * Return the example value of the parameter. + * + * @param codegenParameter Codegen parameter + * @param requestBody Request body + */ + @Override + public void setParameterExampleValue(CodegenParameter codegenParameter, RequestBody requestBody) { + if (codegenParameter.vendorExtensions != null && codegenParameter.vendorExtensions.containsKey("x-example")) { + codegenParameter.example = Json.pretty(codegenParameter.vendorExtensions.get("x-example")); + } + + Content content = requestBody.getContent(); + + if (content.size() > 1) { + // @see ModelUtils.getSchemaFromContent() + once(LOGGER).warn("Multiple MediaTypes found, using only the first one"); + } + + MediaType mediaType = content.values().iterator().next(); + Schema schema = mediaType.getSchema(); + if (schema == null) { + LOGGER.warn("CodegenParameter.example defaulting to null because requestBody content lacks a schema"); + return; + } + + Object example = null; + if (mediaType.getExample() != null) { + example = mediaType.getExample(); + } else if (mediaType.getExamples() != null && !mediaType.getExamples().isEmpty() && mediaType.getExamples().values().iterator().next().getValue() != null) { + example = mediaType.getExamples().values().iterator().next().getValue(); + } else { + example = toExampleValueBase(schema); + } + example = exampleFromStringOrArraySchema(schema, example, codegenParameter.paramName); + codegenParameter.example = toExampleValue(schema, example); + } + + /** + * Create a CodegenParameter for a Form Property + * We have a custom version of this method so we can invoke + * setParameterExampleValue(codegenParameter, parameter) + * rather than setParameterExampleValue(codegenParameter) + * This ensures that all of our samples are generated in + * toExampleValueRecursive + * + * @param name the property name + * @param propertySchema the property schema + * @param imports our import set + * @return the resultant CodegenParameter + */ + @Override + public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set imports) { + CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER); + + LOGGER.debug("Debugging fromFormProperty {}: {}", name, propertySchema); + CodegenProperty codegenProperty = fromProperty(name, propertySchema); + + ModelUtils.syncValidationProperties(propertySchema, codegenProperty); + + codegenParameter.isFormParam = Boolean.TRUE; + codegenParameter.baseName = codegenProperty.baseName; + codegenParameter.paramName = toParamName((codegenParameter.baseName)); + codegenParameter.baseType = codegenProperty.baseType; + codegenParameter.dataType = codegenProperty.dataType; + codegenParameter.dataFormat = codegenProperty.dataFormat; + codegenParameter.description = escapeText(codegenProperty.description); + codegenParameter.unescapedDescription = codegenProperty.getDescription(); + codegenParameter.jsonSchema = Json.pretty(propertySchema); + codegenParameter.defaultValue = codegenProperty.getDefaultValue(); + + if (codegenProperty.getVendorExtensions() != null && !codegenProperty.getVendorExtensions().isEmpty()) { + codegenParameter.vendorExtensions = codegenProperty.getVendorExtensions(); + } + if (propertySchema.getRequired() != null && !propertySchema.getRequired().isEmpty() && propertySchema.getRequired().contains(codegenProperty.baseName)) { + codegenParameter.required = Boolean.TRUE; + } + + // non-array/map + updateCodegenPropertyEnum(codegenProperty); + codegenParameter.isEnum = codegenProperty.isEnum; + codegenParameter._enum = codegenProperty._enum; + codegenParameter.allowableValues = codegenProperty.allowableValues; + + if (codegenProperty.isEnum) { + codegenParameter.datatypeWithEnum = codegenProperty.datatypeWithEnum; + codegenParameter.enumName = codegenProperty.enumName; + } + + if (codegenProperty.items != null && codegenProperty.items.isEnum) { + codegenParameter.items = codegenProperty.items; + codegenParameter.mostInnerItems = codegenProperty.mostInnerItems; + } + + // import + if (codegenProperty.complexType != null) { + imports.add(codegenProperty.complexType); + } + + // validation + // handle maximum, minimum properly for int/long by removing the trailing ".0" + if (ModelUtils.isIntegerSchema(propertySchema)) { + codegenParameter.maximum = propertySchema.getMaximum() == null ? null : String.valueOf(propertySchema.getMaximum().longValue()); + codegenParameter.minimum = propertySchema.getMinimum() == null ? null : String.valueOf(propertySchema.getMinimum().longValue()); } else { - LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); + codegenParameter.maximum = propertySchema.getMaximum() == null ? null : String.valueOf(propertySchema.getMaximum()); + codegenParameter.minimum = propertySchema.getMinimum() == null ? null : String.valueOf(propertySchema.getMinimum()); } - if (example == null) { - example = "None"; - } else if (Boolean.TRUE.equals(p.isListContainer)) { - example = "[" + example + "]"; - } else if (Boolean.TRUE.equals(p.isMapContainer)) { - example = "{'key': " + example + "}"; + codegenParameter.exclusiveMaximum = propertySchema.getExclusiveMaximum() == null ? false : propertySchema.getExclusiveMaximum(); + codegenParameter.exclusiveMinimum = propertySchema.getExclusiveMinimum() == null ? false : propertySchema.getExclusiveMinimum(); + codegenParameter.maxLength = propertySchema.getMaxLength(); + codegenParameter.minLength = propertySchema.getMinLength(); + codegenParameter.pattern = toRegularExpression(propertySchema.getPattern()); + codegenParameter.maxItems = propertySchema.getMaxItems(); + codegenParameter.minItems = propertySchema.getMinItems(); + codegenParameter.uniqueItems = propertySchema.getUniqueItems() == null ? false : propertySchema.getUniqueItems(); + codegenParameter.multipleOf = propertySchema.getMultipleOf(); + + // exclusive* are noop without corresponding min/max + if (codegenParameter.maximum != null || codegenParameter.minimum != null || + codegenParameter.maxLength != null || codegenParameter.minLength != null || + codegenParameter.maxItems != null || codegenParameter.minItems != null || + codegenParameter.pattern != null || codegenParameter.multipleOf != null) { + codegenParameter.hasValidation = true; } - p.example = example; + setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty); + Parameter p = new Parameter(); + p.setSchema(propertySchema); + p.setName(codegenParameter.paramName); + setParameterExampleValue(codegenParameter, p); + // setParameterExampleValue(codegenParameter); + // set nullable + setParameterNullable(codegenParameter, codegenProperty); + + //TODO collectionFormat for form parameter not yet supported + //codegenParameter.collectionFormat = getCollectionFormat(propertySchema); + return codegenParameter; } } diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/api_doc_example.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/api_doc_example.mustache index b7bbc009f5c8..38d50dbd7cb2 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/api_doc_example.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/api_doc_example.mustache @@ -16,44 +16,61 @@ with {{{packageName}}}.ApiClient() as api_client: {{/hasAuthMethods}} # Create an instance of the API class api_instance = {{classVarName}}.{{{classname}}}(api_client) - {{#requiredParams}}{{^defaultValue}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} - {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} - {{/optionalParams}} - {{#requiredParams}} - {{^hasMore}} +{{#requiredParams}} +{{^defaultValue}} + {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}} +{{/defaultValue}} +{{/requiredParams}} +{{#optionalParams}} + {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} +{{/optionalParams}} +{{#requiredParams}} +{{^hasMore}} # example passing only required values which don't have defaults set try: - {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}){{#returnType}} - pprint(api_response){{/returnType}} +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/defaultValue}}{{/requiredParams}}) +{{#returnType}} + pprint(api_response) +{{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) - {{/hasMore}} - {{/requiredParams}} - {{#optionalParams}} - {{^hasMore}} +{{/hasMore}} +{{/requiredParams}} +{{#optionalParams}} +{{^hasMore}} # example passing only required values which don't have defaults set # and optional values try: - {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}){{#returnType}} - pprint(api_response){{/returnType}} +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#optionalParams}}{{paramName}}={{paramName}}{{#hasMore}}, {{/hasMore}}{{/optionalParams}}) +{{#returnType}} + pprint(api_response) +{{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) - {{/hasMore}} - {{/optionalParams}} - {{^requiredParams}} - {{^optionalParams}} +{{/hasMore}} +{{/optionalParams}} +{{^requiredParams}} +{{^optionalParams}} # example, this endpoint has no required or optional parameters try: - {{#summary}} # {{{.}}} - {{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}(){{#returnType}} - pprint(api_response){{/returnType}} +{{#summary}} + # {{{.}}} +{{/summary}} + {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}() +{{#returnType}} + pprint(api_response) +{{/returnType}} except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) - {{/optionalParams}} - {{/requiredParams}} +{{/optionalParams}} +{{/requiredParams}} ``` diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientExperimentalTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientExperimentalTest.java index 43bbb8821eb0..258320fbc4ca 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientExperimentalTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientExperimentalTest.java @@ -51,7 +51,7 @@ public void modelTest() { final String path = "/api/v1beta3/namespaces/{namespaces}/bindings"; final Operation operation = openAPI.getPaths().get(path).getPost(); - final CodegenOperation codegenOperation = codegen.fromOperation(path, "get", operation, null); + final CodegenOperation codegenOperation = codegen.fromOperation(path, "post", operation, null); Assert.assertEquals(codegenOperation.returnType, "V1beta3Binding"); Assert.assertEquals(codegenOperation.returnBaseType, "V1beta3Binding"); } diff --git a/modules/openapi-generator/src/test/resources/2_0/v1beta3.json b/modules/openapi-generator/src/test/resources/2_0/v1beta3.json index eb874ab3c783..b3e043c10d31 100644 --- a/modules/openapi-generator/src/test/resources/2_0/v1beta3.json +++ b/modules/openapi-generator/src/test/resources/2_0/v1beta3.json @@ -234,6 +234,11 @@ } } }, + "any": { + "description": "map model with key property names to any type", + "properties": {}, + "additionalProperties": {} + }, "v1beta3.ObjectReference": { "id": "v1beta3.ObjectReference", "properties": { @@ -271,7 +276,7 @@ "id": "v1beta3.ObjectMeta", "properties": { "annotations": { - "type": "any", + "$ref": "any", "description": "map of string keys and values that can be used by external tooling to store and retrieve arbitrary metadata about objects" }, "creationTimestamp": { @@ -287,7 +292,7 @@ "description": "an optional prefix to use to generate a unique name; has the same validation rules as name; optional, and is applied only name if is not specified" }, "labels": { - "type": "any", + "$ref": "any", "description": "map of string keys and values that can be used to organize and categorize objects; may match selectors of replication controllers and services" }, "name": { diff --git a/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 32de15d04b83..5e224d07adbe 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -842,6 +842,26 @@ paths: application/json: schema: $ref: '#/components/schemas/NumberWithValidations' + /fake/refs/mammal: + post: + tags: + - fake + description: Test serialization of mammals + operationId: Mammal + requestBody: + description: Input mammal + content: + application/json: + schema: + $ref: '#/components/schemas/mammal' + required: true + responses: + '200': + description: Output mammal + content: + application/json: + schema: + $ref: '#/components/schemas/mammal' /fake/refs/string: post: tags: @@ -1588,6 +1608,9 @@ components: type: string format: uuid example: 72f98069-206d-4f12-9f12-3d1e525a8e84 + uuidNoExample: + type: string + format: uuid password: type: string format: password @@ -1820,6 +1843,11 @@ components: - "placed" - "approved" - "delivered" + - 'single quoted' + - |- + multiple + lines + - "double quote \n with newline" IntegerEnum: type: integer enum: diff --git a/pom.xml b/pom.xml index d26e2db1ac1d..27a3f39306c9 100644 --- a/pom.xml +++ b/pom.xml @@ -1515,7 +1515,7 @@ 2.10.2 1.0.0 3.4 - 1.7.12 + 1.7.29 4.3.1 1.14 4.1.2 diff --git a/samples/client/petstore/python-experimental/README.md b/samples/client/petstore/python-experimental/README.md index 6c6a64d9899e..f2d9ac0fdad5 100644 --- a/samples/client/petstore/python-experimental/README.md +++ b/samples/client/petstore/python-experimental/README.md @@ -63,7 +63,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = another_fake_api.AnotherFakeApi(api_client) - body = Client() # Client | client model + body = Client( + client="client_example", + ) # Client | client model try: # To test special tags diff --git a/samples/client/petstore/python-experimental/docs/Animal.md b/samples/client/petstore/python-experimental/docs/Animal.md index e59166a62e83..698dc711aeb9 100644 --- a/samples/client/petstore/python-experimental/docs/Animal.md +++ b/samples/client/petstore/python-experimental/docs/Animal.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | -**color** | **str** | | [optional] if omitted the server will use the default value of 'red' +**color** | **str** | | [optional] if omitted the server will use the default value of "red" [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/AnotherFakeApi.md b/samples/client/petstore/python-experimental/docs/AnotherFakeApi.md index b476f17c965f..7bc6fba30a60 100644 --- a/samples/client/petstore/python-experimental/docs/AnotherFakeApi.md +++ b/samples/client/petstore/python-experimental/docs/AnotherFakeApi.md @@ -33,8 +33,10 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = another_fake_api.AnotherFakeApi(api_client) - body = Client() # Client | client model - + body = Client( + client="client_example", + ) # Client | client model + # example passing only required values which don't have defaults set try: # To test special tags diff --git a/samples/client/petstore/python-experimental/docs/Cat.md b/samples/client/petstore/python-experimental/docs/Cat.md index 8bdbf9b3bcca..b2662bc06c1d 100644 --- a/samples/client/petstore/python-experimental/docs/Cat.md +++ b/samples/client/petstore/python-experimental/docs/Cat.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | **declawed** | **bool** | | [optional] -**color** | **str** | | [optional] if omitted the server will use the default value of 'red' +**color** | **str** | | [optional] if omitted the server will use the default value of "red" [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/Category.md b/samples/client/petstore/python-experimental/docs/Category.md index 33b2242d703f..287225d66fd7 100644 --- a/samples/client/petstore/python-experimental/docs/Category.md +++ b/samples/client/petstore/python-experimental/docs/Category.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**name** | **str** | | defaults to 'default-name' +**name** | **str** | | defaults to "default-name" **id** | **int** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/Dog.md b/samples/client/petstore/python-experimental/docs/Dog.md index 81de56780725..ca679f81b41c 100644 --- a/samples/client/petstore/python-experimental/docs/Dog.md +++ b/samples/client/petstore/python-experimental/docs/Dog.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | **breed** | **str** | | [optional] -**color** | **str** | | [optional] if omitted the server will use the default value of 'red' +**color** | **str** | | [optional] if omitted the server will use the default value of "red" [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/EnumClass.md b/samples/client/petstore/python-experimental/docs/EnumClass.md index 6e7ecf355ffc..6c5c0619a1b0 100644 --- a/samples/client/petstore/python-experimental/docs/EnumClass.md +++ b/samples/client/petstore/python-experimental/docs/EnumClass.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **str** | | if omitted the server will use the default value of '-efg', must be one of ["_abc", "-efg", "(xyz)", ] +**value** | **str** | | if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/FakeApi.md b/samples/client/petstore/python-experimental/docs/FakeApi.md index 804344787fc6..d5980415b3d5 100644 --- a/samples/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/client/petstore/python-experimental/docs/FakeApi.md @@ -48,7 +48,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = AnimalFarm() # AnimalFarm | Input model (optional) + body = AnimalFarm([ + Animal(), + ]) # AnimalFarm | Input model (optional) # example passing only required values which don't have defaults set # and optional values @@ -173,8 +175,56 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - xml_item = XmlItem() # XmlItem | XmlItem Body - + xml_item = XmlItem( + attribute_string="string", + attribute_number=1.234, + attribute_integer=-2, + attribute_boolean=True, + wrapped_array=[ + 1, + ], + name_string="string", + name_number=1.234, + name_integer=-2, + name_boolean=True, + name_array=[ + 1, + ], + name_wrapped_array=[ + 1, + ], + prefix_string="string", + prefix_number=1.234, + prefix_integer=-2, + prefix_boolean=True, + prefix_array=[ + 1, + ], + prefix_wrapped_array=[ + 1, + ], + namespace_string="string", + namespace_number=1.234, + namespace_integer=-2, + namespace_boolean=True, + namespace_array=[ + 1, + ], + namespace_wrapped_array=[ + 1, + ], + prefix_ns_string="string", + prefix_ns_number=1.234, + prefix_ns_integer=-2, + prefix_ns_boolean=True, + prefix_ns_array=[ + 1, + ], + prefix_ns_wrapped_array=[ + 1, + ], + ) # XmlItem | XmlItem Body + # example passing only required values which don't have defaults set try: # creates an XmlItem @@ -235,7 +285,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = NumberWithValidations(3.4) # NumberWithValidations | Input number as post body (optional) + body = NumberWithValidations(1E+1) # NumberWithValidations | Input number as post body (optional) # example passing only required values which don't have defaults set # and optional values @@ -298,7 +348,11 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = ObjectModelWithRefProps() # ObjectModelWithRefProps | Input model (optional) + body = ObjectModelWithRefProps( + my_number=NumberWithValidations(1E+1), + my_string="my_string_example", + my_boolean=True, + ) # ObjectModelWithRefProps | Input model (optional) # example passing only required values which don't have defaults set # and optional values @@ -360,7 +414,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = 'body_example' # str | Input string as post body (optional) + body = "body_example" # str | Input string as post body (optional) # example passing only required values which don't have defaults set # and optional values @@ -486,8 +540,17 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = FileSchemaTestClass() # FileSchemaTestClass | - + body = FileSchemaTestClass( + file=File( + source_uri="source_uri_example", + ), + files=[ + File( + source_uri="source_uri_example", + ), + ], + ) # FileSchemaTestClass | + # example passing only required values which don't have defaults set try: api_instance.test_body_with_file_schema(body) @@ -545,9 +608,18 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - query = 'query_example' # str | - body = User() # User | - + query = "query_example" # str | + body = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ) # User | + # example passing only required values which don't have defaults set try: api_instance.test_body_with_query_params(query, body) @@ -608,8 +680,10 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = Client() # Client | client model - + body = Client( + client="client_example", + ) # Client | client model + # example passing only required values which don't have defaults set try: # To test \"client\" model @@ -670,7 +744,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - + # example passing only required values which don't have defaults set try: api_instance.test_endpoint_enums_length_one() @@ -683,8 +757,8 @@ with petstore_api.ApiClient() as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **query_integer** | **int**| | defaults to 3 - **query_string** | **str**| | defaults to 'brillig' - **path_string** | **str**| | defaults to 'hello' + **query_string** | **str**| | defaults to "brillig" + **path_string** | **str**| | defaults to "hello" **path_integer** | **int**| | defaults to 34 **header_number** | **float**| | defaults to 1.234 @@ -744,20 +818,20 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - number = 3.4 # float | None - double = 3.4 # float | None - pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None - byte = 'byte_example' # str | None - integer = 56 # int | None (optional) -int32 = 56 # int | None (optional) -int64 = 56 # int | None (optional) -float = 3.4 # float | None (optional) -string = 'string_example' # str | None (optional) -binary = open('/path/to/file', 'rb') # file_type | None (optional) -date = '2013-10-20' # date | None (optional) -date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional) -password = 'password_example' # str | None (optional) -param_callback = 'param_callback_example' # str | None (optional) + number = 32.1 # float | None + double = 67.8 # float | None + pattern_without_delimiter = "AUR,rZ#UM/?R,Fp^l6$ARjbhJk C" # str | None + byte = 'YQ==' # str | None + integer = 10 # int | None (optional) + int32 = 20 # int | None (optional) + int64 = 1 # int | None (optional) + float = 3.14 # float | None (optional) + string = "a" # str | None (optional) + binary = open('/path/to/file.txt', 'rb') # file_type | None (optional) + date = datetime.datetime.strptime('1970-01-01', '%Y-%m-%d').date() # date | None (optional) + date_time = datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f') # datetime | None (optional) + password = "password_example" # str | None (optional) + param_callback = "param_callback_example" # str | None (optional) # example passing only required values which don't have defaults set try: @@ -840,14 +914,18 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional) -enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg' -enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional) -enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of '-efg' -enum_query_integer = 56 # int | Query parameter enum test (double) (optional) -enum_query_double = 3.4 # float | Query parameter enum test (double) (optional) -enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of '$' -enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of '-efg' + enum_header_string_array = [ + "$", + ] # [str] | Header parameter enum test (string array) (optional) + enum_header_string = "-efg" # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" + enum_query_string_array = [ + "$", + ] # [str] | Query parameter enum test (string array) (optional) + enum_query_string = "-efg" # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" + enum_query_integer = 1 # int | Query parameter enum test (double) (optional) + enum_query_double = 1.1 # float | Query parameter enum test (double) (optional) + enum_form_string_array = "$" # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of "$" + enum_form_string = "-efg" # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" # example passing only required values which don't have defaults set # and optional values @@ -863,13 +941,13 @@ enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) i Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **enum_header_string_array** | **[str]**| Header parameter enum test (string array) | [optional] - **enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg' + **enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" **enum_query_string_array** | **[str]**| Query parameter enum test (string array) | [optional] - **enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg' + **enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" **enum_query_integer** | **int**| Query parameter enum test (double) | [optional] **enum_query_double** | **float**| Query parameter enum test (double) | [optional] - **enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$' - **enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg' + **enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of "$" + **enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" ### Return type @@ -917,12 +995,12 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - required_string_group = 56 # int | Required String in group parameters + required_string_group = 1 # int | Required String in group parameters required_boolean_group = True # bool | Required Boolean in group parameters - required_int64_group = 56 # int | Required Integer in group parameters - string_group = 56 # int | String in group parameters (optional) -boolean_group = True # bool | Boolean in group parameters (optional) -int64_group = 56 # int | Integer in group parameters (optional) + required_int64_group = 1 # int | Required Integer in group parameters + string_group = 1 # int | String in group parameters (optional) + boolean_group = True # bool | Boolean in group parameters (optional) + int64_group = 1 # int | Integer in group parameters (optional) # example passing only required values which don't have defaults set try: @@ -994,8 +1072,10 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - param = {'key': 'param_example'} # {str: (str,)} | request body - + param = { + "key": "key_example", + } # {str: (str,)} | request body + # example passing only required values which don't have defaults set try: # test inline additionalProperties @@ -1053,9 +1133,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - param = 'param_example' # str | field1 - param2 = 'param2_example' # str | field2 - + param = "param_example" # str | field1 + param2 = "param2_example" # str | field2 + # example passing only required values which don't have defaults set try: # test json serialization of form data diff --git a/samples/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md b/samples/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md index 134d05a959f2..2aa0a68d0c91 100644 --- a/samples/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md @@ -48,8 +48,10 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = fake_classname_tags_123_api.FakeClassnameTags123Api(api_client) - body = Client() # Client | client model - + body = Client( + client="client_example", + ) # Client | client model + # example passing only required values which don't have defaults set try: # To test class name in snake case diff --git a/samples/client/petstore/python-experimental/docs/PetApi.md b/samples/client/petstore/python-experimental/docs/PetApi.md index 642615e5ab29..6189bcf25c03 100644 --- a/samples/client/petstore/python-experimental/docs/PetApi.md +++ b/samples/client/petstore/python-experimental/docs/PetApi.md @@ -50,8 +50,26 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - body = Pet() # Pet | Pet object that needs to be added to the store - + body = Pet( + id=1, + category=Category( + id=1, + name="default-name", + ), + name="doggie", + photo_urls=[ + "photo_urls_example", + ], + tags=[ + Tag( + id=1, + name="name_example", + full_name="full_name_example", + ), + ], + status="available", + ) # Pet | Pet object that needs to be added to the store + # example passing only required values which don't have defaults set try: # Add a new pet to the store @@ -121,8 +139,8 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | Pet id to delete - api_key = 'api_key_example' # str | (optional) + pet_id = 1 # int | Pet id to delete + api_key = "api_key_example" # str | (optional) # example passing only required values which don't have defaults set try: @@ -205,8 +223,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - status = ['status_example'] # [str] | Status values that need to be considered for filter - + status = [ + "available", + ] # [str] | Status values that need to be considered for filter + # example passing only required values which don't have defaults set try: # Finds Pets by status @@ -280,8 +300,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - tags = ['tags_example'] # [str] | Tags to filter by - + tags = [ + "tags_example", + ] # [str] | Tags to filter by + # example passing only required values which don't have defaults set try: # Finds Pets by tags @@ -359,8 +381,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | ID of pet to return - + pet_id = 1 # int | ID of pet to return + # example passing only required values which don't have defaults set try: # Find pet by ID @@ -433,8 +455,26 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - body = Pet() # Pet | Pet object that needs to be added to the store - + body = Pet( + id=1, + category=Category( + id=1, + name="default-name", + ), + name="doggie", + photo_urls=[ + "photo_urls_example", + ], + tags=[ + Tag( + id=1, + name="name_example", + full_name="full_name_example", + ), + ], + status="available", + ) # Pet | Pet object that needs to be added to the store + # example passing only required values which don't have defaults set try: # Update an existing pet @@ -506,9 +546,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | ID of pet that needs to be updated - name = 'name_example' # str | Updated name of the pet (optional) -status = 'status_example' # str | Updated status of the pet (optional) + pet_id = 1 # int | ID of pet that needs to be updated + name = "name_example" # str | Updated name of the pet (optional) + status = "status_example" # str | Updated status of the pet (optional) # example passing only required values which don't have defaults set try: @@ -589,10 +629,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | ID of pet to update - additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional) -file = open('/path/to/file', 'rb') # file_type | file to upload (optional) -files = open('/path/to/file', 'rb') # [file_type] | files to upload (optional) + pet_id = 1 # int | ID of pet to update + additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) + file = open('/path/to/file.txt', 'rb') # file_type | file to upload (optional) + files = # [file_type] | files to upload (optional) # example passing only required values which don't have defaults set try: @@ -676,9 +716,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | ID of pet to update - required_file = open('/path/to/file', 'rb') # file_type | file to upload - additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional) + pet_id = 1 # int | ID of pet to update + required_file = open('/path/to/file.txt', 'rb') # file_type | file to upload + additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) # example passing only required values which don't have defaults set try: diff --git a/samples/client/petstore/python-experimental/docs/StoreApi.md b/samples/client/petstore/python-experimental/docs/StoreApi.md index c2780733ed5f..3406644d4fc0 100644 --- a/samples/client/petstore/python-experimental/docs/StoreApi.md +++ b/samples/client/petstore/python-experimental/docs/StoreApi.md @@ -35,8 +35,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = store_api.StoreApi(api_client) - order_id = 'order_id_example' # str | ID of the order that needs to be deleted - + order_id = "order_id_example" # str | ID of the order that needs to be deleted + # example passing only required values which don't have defaults set try: # Delete purchase order by ID @@ -112,7 +112,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = store_api.StoreApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Returns pet inventories by status @@ -171,8 +171,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = store_api.StoreApi(api_client) - order_id = 56 # int | ID of pet that needs to be fetched - + order_id = 1 # int | ID of pet that needs to be fetched + # example passing only required values which don't have defaults set try: # Find purchase order by ID @@ -234,8 +234,15 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = store_api.StoreApi(api_client) - body = Order() # Order | order placed for purchasing the pet - + body = Order( + id=1, + pet_id=1, + quantity=1, + ship_date=datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f'), + status="placed", + complete=False, + ) # Order | order placed for purchasing the pet + # example passing only required values which don't have defaults set try: # Place an order for a pet diff --git a/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md b/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md index 21d125a8e5f4..42322d2f4c37 100644 --- a/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md +++ b/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md @@ -5,7 +5,7 @@ a model to test optional properties with server defaults Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_item** | **[int]** | | -**string_item** | **str** | | defaults to 'what' +**string_item** | **str** | | defaults to "what" **number_item** | **float** | | defaults to 1.234 **integer_item** | **int** | | defaults to -2 **bool_item** | **bool** | | defaults to True diff --git a/samples/client/petstore/python-experimental/docs/TypeHolderExample.md b/samples/client/petstore/python-experimental/docs/TypeHolderExample.md index b74c520d447a..246ac18b2b59 100644 --- a/samples/client/petstore/python-experimental/docs/TypeHolderExample.md +++ b/samples/client/petstore/python-experimental/docs/TypeHolderExample.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **bool_item** | **bool** | | **array_item** | **[int]** | | -**string_item** | **str** | | defaults to 'what' +**string_item** | **str** | | defaults to "what" **number_item** | **float** | | defaults to 1.234 **integer_item** | **int** | | defaults to -2 diff --git a/samples/client/petstore/python-experimental/docs/UserApi.md b/samples/client/petstore/python-experimental/docs/UserApi.md index 912611a0cd35..429d7918521d 100644 --- a/samples/client/petstore/python-experimental/docs/UserApi.md +++ b/samples/client/petstore/python-experimental/docs/UserApi.md @@ -40,8 +40,17 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - body = User() # User | Created user object - + body = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ) # User | Created user object + # example passing only required values which don't have defaults set try: # Create user @@ -100,8 +109,19 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - body = [User()] # [User] | List of user object - + body = [ + User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ), + ] # [User] | List of user object + # example passing only required values which don't have defaults set try: # Creates list of users with given input array @@ -160,8 +180,19 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - body = [User()] # [User] | List of user object - + body = [ + User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ), + ] # [User] | List of user object + # example passing only required values which don't have defaults set try: # Creates list of users with given input array @@ -221,8 +252,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - username = 'username_example' # str | The name that needs to be deleted - + username = "username_example" # str | The name that needs to be deleted + # example passing only required values which don't have defaults set try: # Delete user @@ -282,8 +313,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing. - + username = "username_example" # str | The name that needs to be fetched. Use user1 for testing. + # example passing only required values which don't have defaults set try: # Get user by user name @@ -344,9 +375,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - username = 'username_example' # str | The user name for login - password = 'password_example' # str | The password for login in clear text - + username = "username_example" # str | The user name for login + password = "password_example" # str | The password for login in clear text + # example passing only required values which don't have defaults set try: # Logs user into the system @@ -407,7 +438,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Logs out current logged in user session @@ -465,9 +496,18 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - username = 'username_example' # str | name that need to be deleted - body = User() # User | Updated user object - + username = "username_example" # str | name that need to be deleted + body = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + ) # User | Updated user object + # example passing only required values which don't have defaults set try: # Updated user diff --git a/samples/client/petstore/python-experimental/petstore_api/api/fake_api.py b/samples/client/petstore/python-experimental/petstore_api/api/fake_api.py index 597af85596c2..316c8136ce2a 100644 --- a/samples/client/petstore/python-experimental/petstore_api/api/fake_api.py +++ b/samples/client/petstore/python-experimental/petstore_api/api/fake_api.py @@ -1188,8 +1188,8 @@ def __test_client_model( def __test_endpoint_enums_length_one( self, query_integer=3, - query_string='brillig', - path_string='hello', + query_string="brillig", + path_string="hello", path_integer=34, header_number=1.234, **kwargs @@ -1200,13 +1200,13 @@ def __test_endpoint_enums_length_one( This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_endpoint_enums_length_one(query_integer=3, query_string='brillig', path_string='hello', path_integer=34, header_number=1.234, async_req=True) + >>> thread = api.test_endpoint_enums_length_one(query_integer=3, query_string="brillig", path_string="hello", path_integer=34, header_number=1.234, async_req=True) >>> result = thread.get() Args: query_integer (int): defaults to 3, must be one of [3] - query_string (str): defaults to 'brillig', must be one of ['brillig'] - path_string (str): defaults to 'hello', must be one of ['hello'] + query_string (str): defaults to "brillig", must be one of ["brillig"] + path_string (str): defaults to "hello", must be one of ["hello"] path_integer (int): defaults to 34, must be one of [34] header_number (float): defaults to 1.234, must be one of [1.234] @@ -1639,13 +1639,13 @@ def __test_enum_parameters( Keyword Args: enum_header_string_array ([str]): Header parameter enum test (string array). [optional] - enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' + enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" enum_query_string_array ([str]): Query parameter enum test (string array). [optional] - enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' + enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" enum_query_integer (int): Query parameter enum test (double). [optional] enum_query_double (float): Query parameter enum test (double). [optional] - enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of '$' - enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' + enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of "$" + enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object diff --git a/samples/client/petstore/python-experimental/petstore_api/model/animal.py b/samples/client/petstore/python-experimental/petstore_api/model/animal.py index 39aaa93227c7..a155d8c4266e 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/animal.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/animal.py @@ -152,7 +152,7 @@ def __init__(self, class_name, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/client/petstore/python-experimental/petstore_api/model/cat.py b/samples/client/petstore/python-experimental/petstore_api/model/cat.py index 7b34989c8c11..7f4e8ee322e3 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/cat.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/cat.py @@ -153,7 +153,7 @@ def __init__(self, class_name, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) declawed (bool): [optional] # noqa: E501 - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/client/petstore/python-experimental/petstore_api/model/category.py b/samples/client/petstore/python-experimental/petstore_api/model/category.py index a5af94f90ce2..95d502adf4e9 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/category.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/category.py @@ -108,7 +108,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 Args: Keyword Args: - name (str): defaults to 'default-name' # noqa: E501 + name (str): defaults to "default-name" # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -142,7 +142,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 id (int): [optional] # noqa: E501 """ - name = kwargs.get('name', 'default-name') + name = kwargs.get('name', "default-name") _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) diff --git a/samples/client/petstore/python-experimental/petstore_api/model/dog.py b/samples/client/petstore/python-experimental/petstore_api/model/dog.py index 24f8a468895b..00b67ef2ca9c 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/dog.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/dog.py @@ -153,7 +153,7 @@ def __init__(self, class_name, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) breed (str): [optional] # noqa: E501 - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py index 5c9799cce105..2052f27748f0 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -103,7 +103,7 @@ def __init__(self, value, *args, **kwargs): """EnumClass - a model defined in OpenAPI Args: - value (str): if omitted the server will use the default value of '-efg', must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + value (str): if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 Keyword Args: _check_type (bool): if True, values for parameters in openapi_types diff --git a/samples/client/petstore/python-experimental/petstore_api/model/type_holder_default.py b/samples/client/petstore/python-experimental/petstore_api/model/type_holder_default.py index 812384aa9940..a684f532a940 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/type_holder_default.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/type_holder_default.py @@ -119,7 +119,7 @@ def __init__(self, array_item, *args, **kwargs): # noqa: E501 array_item ([int]): Keyword Args: - string_item (str): defaults to 'what' # noqa: E501 + string_item (str): defaults to "what" # noqa: E501 number_item (float): defaults to 1.234 # noqa: E501 integer_item (int): defaults to -2 # noqa: E501 bool_item (bool): defaults to True # noqa: E501 @@ -157,7 +157,7 @@ def __init__(self, array_item, *args, **kwargs): # noqa: E501 datetime_item (datetime): [optional] # noqa: E501 """ - string_item = kwargs.get('string_item', 'what') + string_item = kwargs.get('string_item', "what") number_item = kwargs.get('number_item', 1.234) integer_item = kwargs.get('integer_item', -2) bool_item = kwargs.get('bool_item', True) diff --git a/samples/client/petstore/python-experimental/petstore_api/model/type_holder_example.py b/samples/client/petstore/python-experimental/petstore_api/model/type_holder_example.py index 1f796982cde0..d5ac727feb96 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model/type_holder_example.py +++ b/samples/client/petstore/python-experimental/petstore_api/model/type_holder_example.py @@ -125,7 +125,7 @@ def __init__(self, bool_item, array_item, *args, **kwargs): # noqa: E501 array_item ([int]): Keyword Args: - string_item (str): defaults to 'what', must be one of ["what", ] # noqa: E501 + string_item (str): defaults to "what", must be one of ["what", ] # noqa: E501 number_item (float): defaults to 1.234, must be one of [1.234, ] # noqa: E501 integer_item (int): defaults to -2, must be one of [-2, ] # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types @@ -160,7 +160,7 @@ def __init__(self, bool_item, array_item, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) """ - string_item = kwargs.get('string_item', 'what') + string_item = kwargs.get('string_item', "what") number_item = kwargs.get('number_item', 1.234) integer_item = kwargs.get('integer_item', -2) _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/docs/UsageApi.md b/samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/docs/UsageApi.md index e68aff3cb673..1d6ecb07326b 100644 --- a/samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/docs/UsageApi.md +++ b/samples/openapi3/client/extensions/x-auth-id-alias/python-experimental/docs/UsageApi.md @@ -61,7 +61,7 @@ configuration = x_auth_id_alias.Configuration( with x_auth_id_alias.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = usage_api.UsageApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Use any API key @@ -145,7 +145,7 @@ configuration = x_auth_id_alias.Configuration( with x_auth_id_alias.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = usage_api.UsageApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Use both API keys @@ -218,7 +218,7 @@ configuration = x_auth_id_alias.Configuration( with x_auth_id_alias.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = usage_api.UsageApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Use API key in header @@ -291,7 +291,7 @@ configuration = x_auth_id_alias.Configuration( with x_auth_id_alias.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = usage_api.UsageApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Use API key in query diff --git a/samples/openapi3/client/features/dynamic-servers/python-experimental/docs/UsageApi.md b/samples/openapi3/client/features/dynamic-servers/python-experimental/docs/UsageApi.md index ab21766abafd..37f849e1b456 100644 --- a/samples/openapi3/client/features/dynamic-servers/python-experimental/docs/UsageApi.md +++ b/samples/openapi3/client/features/dynamic-servers/python-experimental/docs/UsageApi.md @@ -33,7 +33,7 @@ configuration = dynamic_servers.Configuration( with dynamic_servers.ApiClient() as api_client: # Create an instance of the API class api_instance = usage_api.UsageApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Use custom server @@ -91,7 +91,7 @@ configuration = dynamic_servers.Configuration( with dynamic_servers.ApiClient() as api_client: # Create an instance of the API class api_instance = usage_api.UsageApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Use default server diff --git a/samples/openapi3/client/petstore/python-experimental/README.md b/samples/openapi3/client/petstore/python-experimental/README.md index 3a6d461eaa73..ec221684f4ed 100644 --- a/samples/openapi3/client/petstore/python-experimental/README.md +++ b/samples/openapi3/client/petstore/python-experimental/README.md @@ -63,7 +63,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = another_fake_api.AnotherFakeApi(api_client) - client = Client() # Client | client model + client = Client( + client="client_example", + ) # Client | client model try: # To test special tags @@ -87,6 +89,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**boolean**](docs/FakeApi.md#boolean) | **POST** /fake/refs/boolean | *FakeApi* | [**composed_one_of_number_with_validations**](docs/FakeApi.md#composed_one_of_number_with_validations) | **POST** /fake/refs/composed_one_of_number_with_validations | *FakeApi* | [**fake_health_get**](docs/FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint +*FakeApi* | [**mammal**](docs/FakeApi.md#mammal) | **POST** /fake/refs/mammal | *FakeApi* | [**number_with_validations**](docs/FakeApi.md#number_with_validations) | **POST** /fake/refs/number | *FakeApi* | [**object_model_with_ref_props**](docs/FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props | *FakeApi* | [**string**](docs/FakeApi.md#string) | **POST** /fake/refs/string | diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Animal.md b/samples/openapi3/client/petstore/python-experimental/docs/Animal.md index e59166a62e83..698dc711aeb9 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/Animal.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/Animal.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | -**color** | **str** | | [optional] if omitted the server will use the default value of 'red' +**color** | **str** | | [optional] if omitted the server will use the default value of "red" [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/AnotherFakeApi.md b/samples/openapi3/client/petstore/python-experimental/docs/AnotherFakeApi.md index c0b203732c31..402031d6beef 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/AnotherFakeApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/AnotherFakeApi.md @@ -33,8 +33,10 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = another_fake_api.AnotherFakeApi(api_client) - client = Client() # Client | client model - + client = Client( + client="client_example", + ) # Client | client model + # example passing only required values which don't have defaults set try: # To test special tags diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Cat.md b/samples/openapi3/client/petstore/python-experimental/docs/Cat.md index d01b2effd044..86f6c0e11dcf 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/Cat.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/Cat.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | **declawed** | **bool** | | [optional] -**color** | **str** | | [optional] if omitted the server will use the default value of 'red' +**color** | **str** | | [optional] if omitted the server will use the default value of "red" **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Category.md b/samples/openapi3/client/petstore/python-experimental/docs/Category.md index 33b2242d703f..287225d66fd7 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/Category.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/Category.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**name** | **str** | | defaults to 'default-name' +**name** | **str** | | defaults to "default-name" **id** | **int** | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/ComposedOneOfNumberWithValidations.md b/samples/openapi3/client/petstore/python-experimental/docs/ComposedOneOfNumberWithValidations.md index 453d1a4d5b1c..c17117fe2c74 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/ComposedOneOfNumberWithValidations.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/ComposedOneOfNumberWithValidations.md @@ -5,7 +5,7 @@ this is a model that allows payloads of type object or number Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | defaults to nulltype.Null -**color** | **str** | | [optional] if omitted the server will use the default value of 'red' +**color** | **str** | | [optional] if omitted the server will use the default value of "red" **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/DefaultApi.md b/samples/openapi3/client/petstore/python-experimental/docs/DefaultApi.md index 3331aea8a25a..3fffa95ff343 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/DefaultApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/DefaultApi.md @@ -31,7 +31,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = default_api.DefaultApi(api_client) - + # example, this endpoint has no required or optional parameters try: api_response = api_instance.foo_get() diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Dog.md b/samples/openapi3/client/petstore/python-experimental/docs/Dog.md index f2044b25341b..fa9568060923 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/Dog.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/Dog.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | **breed** | **str** | | [optional] -**color** | **str** | | [optional] if omitted the server will use the default value of 'red' +**color** | **str** | | [optional] if omitted the server will use the default value of "red" **any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/EnumClass.md b/samples/openapi3/client/petstore/python-experimental/docs/EnumClass.md index 6e7ecf355ffc..6c5c0619a1b0 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/EnumClass.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/EnumClass.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **str** | | if omitted the server will use the default value of '-efg', must be one of ["_abc", "-efg", "(xyz)", ] +**value** | **str** | | if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md index 47c7f50f3ecb..1efb8231ad6b 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md @@ -10,6 +10,7 @@ Method | HTTP request | Description [**boolean**](FakeApi.md#boolean) | **POST** /fake/refs/boolean | [**composed_one_of_number_with_validations**](FakeApi.md#composed_one_of_number_with_validations) | **POST** /fake/refs/composed_one_of_number_with_validations | [**fake_health_get**](FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint +[**mammal**](FakeApi.md#mammal) | **POST** /fake/refs/mammal | [**number_with_validations**](FakeApi.md#number_with_validations) | **POST** /fake/refs/number | [**object_model_with_ref_props**](FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props | [**string**](FakeApi.md#string) | **POST** /fake/refs/string | @@ -49,7 +50,11 @@ configuration = petstore_api.Configuration( 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() # AdditionalPropertiesWithArrayOfEnums | Input enum (optional) + additional_properties_with_array_of_enums = AdditionalPropertiesWithArrayOfEnums( + "key": [ + EnumClass("-efg"), + ], + ) # AdditionalPropertiesWithArrayOfEnums | Input enum (optional) # example passing only required values which don't have defaults set # and optional values @@ -113,7 +118,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = AnimalFarm() # AnimalFarm | Input model (optional) + body = AnimalFarm([ + Animal(), + ]) # AnimalFarm | Input model (optional) # example passing only required values which don't have defaults set # and optional values @@ -174,7 +181,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - array_of_enums = ArrayOfEnums() # ArrayOfEnums | Input enum (optional) + array_of_enums = ArrayOfEnums([ + StringEnum("placed"), + ]) # ArrayOfEnums | Input enum (optional) # example passing only required values which don't have defaults set # and optional values @@ -361,7 +370,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Health check endpoint @@ -394,6 +403,72 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **mammal** +> Mammal mammal(mammal) + + + +Test serialization of mammals + +### Example + +```python +import time +import petstore_api +from petstore_api.api import fake_api +from petstore_api.model.mammal import Mammal +from pprint import pprint +# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2 +# See configuration.py for a list of all supported configuration parameters. +configuration = petstore_api.Configuration( + host = "http://petstore.swagger.io:80/v2" +) + + +# Enter a context with an instance of the API client +with petstore_api.ApiClient() as api_client: + # Create an instance of the API class + api_instance = fake_api.FakeApi(api_client) + mammal = Mammal( + has_baleen=True, + has_teeth=True, + class_name="whale", + ) # Mammal | Input mammal + + # example passing only required values which don't have defaults set + try: + api_response = api_instance.mammal(mammal) + pprint(api_response) + except petstore_api.ApiException as e: + print("Exception when calling FakeApi->mammal: %s\n" % e) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **mammal** | [**Mammal**](Mammal.md)| Input mammal | + +### Return type + +[**Mammal**](Mammal.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output mammal | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **number_with_validations** > NumberWithValidations number_with_validations() @@ -420,7 +495,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = NumberWithValidations(3.4) # NumberWithValidations | Input number as post body (optional) + body = NumberWithValidations(10) # NumberWithValidations | Input number as post body (optional) # example passing only required values which don't have defaults set # and optional values @@ -483,7 +558,11 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = ObjectModelWithRefProps() # ObjectModelWithRefProps | Input model (optional) + body = ObjectModelWithRefProps( + my_number=NumberWithValidations(10), + my_string="my_string_example", + my_boolean=True, + ) # ObjectModelWithRefProps | Input model (optional) # example passing only required values which don't have defaults set # and optional values @@ -545,7 +624,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - body = 'body_example' # str | Input string as post body (optional) + body = "body_example" # str | Input string as post body (optional) # example passing only required values which don't have defaults set # and optional values @@ -671,8 +750,17 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - file_schema_test_class = FileSchemaTestClass() # FileSchemaTestClass | - + file_schema_test_class = FileSchemaTestClass( + file=File( + source_uri="source_uri_example", + ), + files=[ + File( + source_uri="source_uri_example", + ), + ], + ) # FileSchemaTestClass | + # example passing only required values which don't have defaults set try: api_instance.test_body_with_file_schema(file_schema_test_class) @@ -730,9 +818,22 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - query = 'query_example' # str | - user = User() # User | - + query = "query_example" # str | + user = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + object_with_no_declared_props={}, + object_with_no_declared_props_nullable={}, + any_type_prop=None, + any_type_prop_nullable=None, + ) # User | + # example passing only required values which don't have defaults set try: api_instance.test_body_with_query_params(query, user) @@ -793,8 +894,10 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - client = Client() # Client | client model - + client = Client( + client="client_example", + ) # Client | client model + # example passing only required values which don't have defaults set try: # To test \"client\" model @@ -866,20 +969,20 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - number = 3.4 # float | None - double = 3.4 # float | None - pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None - byte = 'byte_example' # str | None - integer = 56 # int | None (optional) -int32 = 56 # int | None (optional) -int64 = 56 # int | None (optional) -float = 3.4 # float | None (optional) -string = 'string_example' # str | None (optional) -binary = open('/path/to/file', 'rb') # file_type | None (optional) -date = '2013-10-20' # date | None (optional) -date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional) -password = 'password_example' # str | None (optional) -param_callback = 'param_callback_example' # str | None (optional) + number = 32.1 # float | None + double = 67.8 # float | None + pattern_without_delimiter = "AUR,rZ#UM/?R,Fp^l6$ARjbhJk C" # str | None + byte = 'YQ==' # str | None + integer = 10 # int | None (optional) + int32 = 20 # int | None (optional) + int64 = 1 # int | None (optional) + float = 3.14 # float | None (optional) + string = "a" # str | None (optional) + binary = open('/path/to/file.txt', 'rb') # file_type | None (optional) + date = datetime.datetime.strptime('1970-01-01', '%Y-%m-%d').date() # date | None (optional) + date_time = datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f') # datetime | None (optional) + password = "password_example" # str | None (optional) + param_callback = "param_callback_example" # str | None (optional) # example passing only required values which don't have defaults set try: @@ -962,14 +1065,18 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional) -enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of '-efg' -enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional) -enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of '-efg' -enum_query_integer = 56 # int | Query parameter enum test (double) (optional) -enum_query_double = 3.4 # float | Query parameter enum test (double) (optional) -enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of '$' -enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of '-efg' + enum_header_string_array = [ + "$", + ] # [str] | Header parameter enum test (string array) (optional) + enum_header_string = "-efg" # str | Header parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" + enum_query_string_array = [ + "$", + ] # [str] | Query parameter enum test (string array) (optional) + enum_query_string = "-efg" # str | Query parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" + enum_query_integer = 1 # int | Query parameter enum test (double) (optional) + enum_query_double = 1.1 # float | Query parameter enum test (double) (optional) + enum_form_string_array = "$" # [str] | Form parameter enum test (string array) (optional) if omitted the server will use the default value of "$" + enum_form_string = "-efg" # str | Form parameter enum test (string) (optional) if omitted the server will use the default value of "-efg" # example passing only required values which don't have defaults set # and optional values @@ -985,13 +1092,13 @@ enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) i Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **enum_header_string_array** | **[str]**| Header parameter enum test (string array) | [optional] - **enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg' + **enum_header_string** | **str**| Header parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" **enum_query_string_array** | **[str]**| Query parameter enum test (string array) | [optional] - **enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg' + **enum_query_string** | **str**| Query parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" **enum_query_integer** | **int**| Query parameter enum test (double) | [optional] **enum_query_double** | **float**| Query parameter enum test (double) | [optional] - **enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$' - **enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg' + **enum_form_string_array** | **[str]**| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of "$" + **enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" ### Return type @@ -1049,12 +1156,12 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - required_string_group = 56 # int | Required String in group parameters + required_string_group = 1 # int | Required String in group parameters required_boolean_group = True # bool | Required Boolean in group parameters - required_int64_group = 56 # int | Required Integer in group parameters - string_group = 56 # int | String in group parameters (optional) -boolean_group = True # bool | Boolean in group parameters (optional) -int64_group = 56 # int | Integer in group parameters (optional) + required_int64_group = 1 # int | Required Integer in group parameters + string_group = 1 # int | String in group parameters (optional) + boolean_group = True # bool | Boolean in group parameters (optional) + int64_group = 1 # int | Integer in group parameters (optional) # example passing only required values which don't have defaults set try: @@ -1126,8 +1233,10 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - request_body = {'key': 'request_body_example'} # {str: (str,)} | request body - + request_body = { + "key": "key_example", + } # {str: (str,)} | request body + # example passing only required values which don't have defaults set try: # test inline additionalProperties @@ -1185,9 +1294,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - param = 'param_example' # str | field1 - param2 = 'param2_example' # str | field2 - + param = "param_example" # str | field1 + param2 = "param2_example" # str | field2 + # example passing only required values which don't have defaults set try: # test json serialization of form data @@ -1248,12 +1357,22 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = fake_api.FakeApi(api_client) - pipe = ['pipe_example'] # [str] | - ioutil = ['ioutil_example'] # [str] | - http = ['http_example'] # [str] | - url = ['url_example'] # [str] | - context = ['context_example'] # [str] | - + pipe = [ + "pipe_example", + ] # [str] | + ioutil = [ + "ioutil_example", + ] # [str] | + http = [ + "http_example", + ] # [str] | + url = [ + "url_example", + ] # [str] | + context = [ + "context_example", + ] # [str] | + # example passing only required values which don't have defaults set try: api_instance.test_query_parameter_collection_format(pipe, ioutil, http, url, context) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md b/samples/openapi3/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md index fa046d30ddb1..2f6730320c7d 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md @@ -48,8 +48,10 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = fake_classname_tags_123_api.FakeClassnameTags123Api(api_client) - client = Client() # Client | client model - + client = Client( + client="client_example", + ) # Client | client model + # example passing only required values which don't have defaults set try: # To test class name in snake case diff --git a/samples/openapi3/client/petstore/python-experimental/docs/Foo.md b/samples/openapi3/client/petstore/python-experimental/docs/Foo.md index 5b281fa08de7..3e9080e7f48a 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/Foo.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/Foo.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**bar** | **str** | | [optional] if omitted the server will use the default value of 'bar' +**bar** | **str** | | [optional] if omitted the server will use the default value of "bar" [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FormatTest.md b/samples/openapi3/client/petstore/python-experimental/docs/FormatTest.md index 2ac0ffb36d33..18e7d495e0f5 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/FormatTest.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/FormatTest.md @@ -16,6 +16,7 @@ Name | Type | Description | Notes **binary** | **file_type** | | [optional] **date_time** | **datetime** | | [optional] **uuid** | **str** | | [optional] +**uuid_no_example** | **str** | | [optional] **pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional] **pattern_with_digits_and_delimiter** | **str** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional] diff --git a/samples/openapi3/client/petstore/python-experimental/docs/InlineObject2.md b/samples/openapi3/client/petstore/python-experimental/docs/InlineObject2.md index 106488e8598e..9312bc7e3a19 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/InlineObject2.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/InlineObject2.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **enum_form_string_array** | **[str]** | Form parameter enum test (string array) | [optional] -**enum_form_string** | **str** | Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg' +**enum_form_string** | **str** | Form parameter enum test (string) | [optional] if omitted the server will use the default value of "-efg" [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/PetApi.md b/samples/openapi3/client/petstore/python-experimental/docs/PetApi.md index 94c9629a8c23..f141a5377700 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/PetApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/PetApi.md @@ -110,8 +110,25 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet = Pet() # Pet | Pet object that needs to be added to the store - + pet = Pet( + id=1, + category=Category( + id=1, + name="default-name", + ), + name="doggie", + photo_urls=[ + "photo_urls_example", + ], + tags=[ + Tag( + id=1, + name="name_example", + ), + ], + status="available", + ) # Pet | Pet object that needs to be added to the store + # example passing only required values which don't have defaults set try: # Add a new pet to the store @@ -180,8 +197,8 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | Pet id to delete - api_key = 'api_key_example' # str | (optional) + pet_id = 1 # int | Pet id to delete + api_key = "api_key_example" # str | (optional) # example passing only required values which don't have defaults set try: @@ -323,8 +340,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - status = ['status_example'] # [str] | Status values that need to be considered for filter - + status = [ + "available", + ] # [str] | Status values that need to be considered for filter + # example passing only required values which don't have defaults set try: # Finds Pets by status @@ -458,8 +477,10 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - tags = ['tags_example'] # [str] | Tags to filter by - + tags = [ + "tags_example", + ] # [str] | Tags to filter by + # example passing only required values which don't have defaults set try: # Finds Pets by tags @@ -537,8 +558,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | ID of pet to return - + pet_id = 1 # int | ID of pet to return + # example passing only required values which don't have defaults set try: # Find pet by ID @@ -671,8 +692,25 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet = Pet() # Pet | Pet object that needs to be added to the store - + pet = Pet( + id=1, + category=Category( + id=1, + name="default-name", + ), + name="doggie", + photo_urls=[ + "photo_urls_example", + ], + tags=[ + Tag( + id=1, + name="name_example", + ), + ], + status="available", + ) # Pet | Pet object that needs to be added to the store + # example passing only required values which don't have defaults set try: # Update an existing pet @@ -743,9 +781,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | ID of pet that needs to be updated - name = 'name_example' # str | Updated name of the pet (optional) -status = 'status_example' # str | Updated status of the pet (optional) + pet_id = 1 # int | ID of pet that needs to be updated + name = "name_example" # str | Updated name of the pet (optional) + status = "status_example" # str | Updated status of the pet (optional) # example passing only required values which don't have defaults set try: @@ -826,9 +864,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | ID of pet to update - additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional) -file = open('/path/to/file', 'rb') # file_type | file to upload (optional) + pet_id = 1 # int | ID of pet to update + additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) + file = open('/path/to/file.txt', 'rb') # file_type | file to upload (optional) # example passing only required values which don't have defaults set try: @@ -911,9 +949,9 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) - pet_id = 56 # int | ID of pet to update - required_file = open('/path/to/file', 'rb') # file_type | file to upload - additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional) + pet_id = 1 # int | ID of pet to update + required_file = open('/path/to/file.txt', 'rb') # file_type | file to upload + additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) # example passing only required values which don't have defaults set try: diff --git a/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md b/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md index eb126eda51d9..5f031ddf3b79 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md @@ -35,8 +35,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = store_api.StoreApi(api_client) - order_id = 'order_id_example' # str | ID of the order that needs to be deleted - + order_id = "order_id_example" # str | ID of the order that needs to be deleted + # example passing only required values which don't have defaults set try: # Delete purchase order by ID @@ -112,7 +112,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = store_api.StoreApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Returns pet inventories by status @@ -171,8 +171,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = store_api.StoreApi(api_client) - order_id = 56 # int | ID of pet that needs to be fetched - + order_id = 1 # int | ID of pet that needs to be fetched + # example passing only required values which don't have defaults set try: # Find purchase order by ID @@ -234,8 +234,15 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = store_api.StoreApi(api_client) - order = Order() # Order | order placed for purchasing the pet - + order = Order( + id=1, + pet_id=1, + quantity=1, + ship_date=datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f'), + status="placed", + complete=False, + ) # Order | order placed for purchasing the pet + # example passing only required values which don't have defaults set try: # Place an order for a pet diff --git a/samples/openapi3/client/petstore/python-experimental/docs/StringEnum.md b/samples/openapi3/client/petstore/python-experimental/docs/StringEnum.md index fbedcd04bce9..4c00bc4ad9dd 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/StringEnum.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/StringEnum.md @@ -3,7 +3,9 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **str** | | must be one of ["placed", "approved", "delivered", ] +**value** | **str** | | must be one of ["placed", "approved", "delivered", "single quoted", '''multiple +lines''', '''double quote + with newline''', ] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/StringEnumWithDefaultValue.md b/samples/openapi3/client/petstore/python-experimental/docs/StringEnumWithDefaultValue.md index 62111d72dbed..74cc456c84f9 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/StringEnumWithDefaultValue.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/StringEnumWithDefaultValue.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**value** | **str** | | if omitted the server will use the default value of 'placed', must be one of ["placed", "approved", "delivered", ] +**value** | **str** | | if omitted the server will use the default value of "placed", must be one of ["placed", "approved", "delivered", ] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/UserApi.md b/samples/openapi3/client/petstore/python-experimental/docs/UserApi.md index d7f0c3f8fa94..59eeff9a3366 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/UserApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/UserApi.md @@ -40,8 +40,21 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - user = User() # User | Created user object - + user = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + object_with_no_declared_props={}, + object_with_no_declared_props_nullable={}, + any_type_prop=None, + any_type_prop_nullable=None, + ) # User | Created user object + # example passing only required values which don't have defaults set try: # Create user @@ -100,8 +113,23 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - user = [User()] # [User] | List of user object - + user = [ + User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + object_with_no_declared_props={}, + object_with_no_declared_props_nullable={}, + any_type_prop=None, + any_type_prop_nullable=None, + ), + ] # [User] | List of user object + # example passing only required values which don't have defaults set try: # Creates list of users with given input array @@ -160,8 +188,23 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - user = [User()] # [User] | List of user object - + user = [ + User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + object_with_no_declared_props={}, + object_with_no_declared_props_nullable={}, + any_type_prop=None, + any_type_prop_nullable=None, + ), + ] # [User] | List of user object + # example passing only required values which don't have defaults set try: # Creates list of users with given input array @@ -221,8 +264,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - username = 'username_example' # str | The name that needs to be deleted - + username = "username_example" # str | The name that needs to be deleted + # example passing only required values which don't have defaults set try: # Delete user @@ -282,8 +325,8 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing. - + username = "username_example" # str | The name that needs to be fetched. Use user1 for testing. + # example passing only required values which don't have defaults set try: # Get user by user name @@ -344,9 +387,9 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - username = 'username_example' # str | The user name for login - password = 'password_example' # str | The password for login in clear text - + username = "username_example" # str | The user name for login + password = "password_example" # str | The password for login in clear text + # example passing only required values which don't have defaults set try: # Logs user into the system @@ -407,7 +450,7 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - + # example, this endpoint has no required or optional parameters try: # Logs out current logged in user session @@ -465,9 +508,22 @@ configuration = petstore_api.Configuration( with petstore_api.ApiClient() as api_client: # Create an instance of the API class api_instance = user_api.UserApi(api_client) - username = 'username_example' # str | name that need to be deleted - user = User() # User | Updated user object - + username = "username_example" # str | name that need to be deleted + user = User( + id=1, + username="username_example", + first_name="first_name_example", + last_name="last_name_example", + email="email_example", + password="password_example", + phone="phone_example", + user_status=1, + object_with_no_declared_props={}, + object_with_no_declared_props_nullable={}, + any_type_prop=None, + any_type_prop_nullable=None, + ) # User | Updated user object + # example passing only required values which don't have defaults set try: # Updated user diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api.py index 40f7ef9a8267..a741eabc7e99 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api.py @@ -30,6 +30,7 @@ from petstore_api.model.composed_one_of_number_with_validations import ComposedOneOfNumberWithValidations from petstore_api.model.file_schema_test_class import FileSchemaTestClass from petstore_api.model.health_check_result import HealthCheckResult +from petstore_api.model.mammal import Mammal from petstore_api.model.number_with_validations import NumberWithValidations from petstore_api.model.object_model_with_ref_props import ObjectModelWithRefProps from petstore_api.model.string_enum import StringEnum @@ -710,6 +711,124 @@ def __fake_health_get( callable=__fake_health_get ) + def __mammal( + self, + mammal, + **kwargs + ): + """mammal # noqa: E501 + + Test serialization of mammals # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.mammal(mammal, async_req=True) + >>> result = thread.get() + + Args: + mammal (Mammal): Input mammal + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (float/tuple): timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + Mammal + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['mammal'] = \ + mammal + return self.call_with_http_info(**kwargs) + + self.mammal = Endpoint( + settings={ + 'response_type': (Mammal,), + 'auth': [], + 'endpoint_path': '/fake/refs/mammal', + 'operation_id': 'mammal', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'mammal', + ], + 'required': [ + 'mammal', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'mammal': + (Mammal,), + }, + 'attribute_map': { + }, + 'location_map': { + 'mammal': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__mammal + ) + def __number_with_validations( self, **kwargs @@ -1792,13 +1911,13 @@ def __test_enum_parameters( Keyword Args: enum_header_string_array ([str]): Header parameter enum test (string array). [optional] - enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' + enum_header_string (str): Header parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" enum_query_string_array ([str]): Query parameter enum test (string array). [optional] - enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' + enum_query_string (str): Query parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" enum_query_integer (int): Query parameter enum test (double). [optional] enum_query_double (float): Query parameter enum test (double). [optional] - enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of '$' - enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' + enum_form_string_array ([str]): Form parameter enum test (string array). [optional] if omitted the server will use the default value of "$" + enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal.py index 39aaa93227c7..a155d8c4266e 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/animal.py @@ -152,7 +152,7 @@ def __init__(self, class_name, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/cat.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/cat.py index 79cb4253383a..2ebbd9a6e012 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/cat.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/cat.py @@ -162,7 +162,7 @@ def __init__(self, class_name, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) declawed (bool): [optional] # noqa: E501 - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/category.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/category.py index a5af94f90ce2..95d502adf4e9 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/category.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/category.py @@ -108,7 +108,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 Args: Keyword Args: - name (str): defaults to 'default-name' # noqa: E501 + name (str): defaults to "default-name" # noqa: E501 _check_type (bool): if True, values for parameters in openapi_types will be type checked and a TypeError will be raised if the wrong type is input. @@ -142,7 +142,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 id (int): [optional] # noqa: E501 """ - name = kwargs.get('name', 'default-name') + name = kwargs.get('name', "default-name") _check_type = kwargs.pop('_check_type', True) _spec_property_naming = kwargs.pop('_spec_property_naming', False) _path_to_item = kwargs.pop('_path_to_item', ()) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/composed_one_of_number_with_validations.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/composed_one_of_number_with_validations.py index b94be08717f7..0923008ec199 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/composed_one_of_number_with_validations.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/composed_one_of_number_with_validations.py @@ -154,7 +154,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 """ class_name = kwargs.get('class_name', nulltype.Null) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/dog.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/dog.py index 9dcfb59d09ca..e68764d3bae3 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/dog.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/dog.py @@ -160,7 +160,7 @@ def __init__(self, class_name, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) breed (str): [optional] # noqa: E501 - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 + color (str): [optional] if omitted the server will use the default value of "red" # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py index 5c9799cce105..2052f27748f0 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/enum_class.py @@ -103,7 +103,7 @@ def __init__(self, value, *args, **kwargs): """EnumClass - a model defined in OpenAPI Args: - value (str): if omitted the server will use the default value of '-efg', must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 + value (str): if omitted the server will use the default value of "-efg", must be one of ["_abc", "-efg", "(xyz)", ] # noqa: E501 Keyword Args: _check_type (bool): if True, values for parameters in openapi_types diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/foo.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/foo.py index 2947adf7dcb8..97bf13554f88 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/foo.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/foo.py @@ -134,7 +134,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - bar (str): [optional] if omitted the server will use the default value of 'bar' # noqa: E501 + bar (str): [optional] if omitted the server will use the default value of "bar" # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py index 309609987992..509863d73c22 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/format_test.py @@ -132,6 +132,7 @@ def openapi_types(): 'binary': (file_type,), # noqa: E501 'date_time': (datetime,), # noqa: E501 'uuid': (str,), # noqa: E501 + 'uuid_no_example': (str,), # noqa: E501 'pattern_with_digits': (str,), # noqa: E501 'pattern_with_digits_and_delimiter': (str,), # noqa: E501 } @@ -155,6 +156,7 @@ def discriminator(): 'binary': 'binary', # noqa: E501 'date_time': 'dateTime', # noqa: E501 'uuid': 'uuid', # noqa: E501 + 'uuid_no_example': 'uuidNoExample', # noqa: E501 'pattern_with_digits': 'pattern_with_digits', # noqa: E501 'pattern_with_digits_and_delimiter': 'pattern_with_digits_and_delimiter', # noqa: E501 } @@ -220,6 +222,7 @@ def __init__(self, number, byte, date, password, *args, **kwargs): # noqa: E501 binary (file_type): [optional] # noqa: E501 date_time (datetime): [optional] # noqa: E501 uuid (str): [optional] # noqa: E501 + uuid_no_example (str): [optional] # noqa: E501 pattern_with_digits (str): A string that is a 10 digit number. Can have leading zeros.. [optional] # noqa: E501 pattern_with_digits_and_delimiter (str): A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01.. [optional] # noqa: E501 """ diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/inline_object2.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/inline_object2.py index cb8a3b1758db..03e534e5d513 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/inline_object2.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/inline_object2.py @@ -146,7 +146,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) enum_form_string_array ([str]): Form parameter enum test (string array). [optional] # noqa: E501 - enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of '-efg' # noqa: E501 + enum_form_string (str): Form parameter enum test (string). [optional] if omitted the server will use the default value of "-efg" # noqa: E501 """ _check_type = kwargs.pop('_check_type', True) diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py index d76bf700a8a8..9c7ffa0854c8 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum.py @@ -57,6 +57,11 @@ class StringEnum(ModelSimple): 'PLACED': "placed", 'APPROVED': "approved", 'DELIVERED': "delivered", + 'SINGLE_QUOTED': "single quoted", + 'MULTIPLE_LINES': '''multiple +lines''', + 'DOUBLE_QUOTE_WITH_NEWLINE': '''double quote + with newline''', }, } @@ -104,7 +109,9 @@ def __init__(self, value, *args, **kwargs): """StringEnum - a model defined in OpenAPI Args: - value (str):, must be one of ["placed", "approved", "delivered", ] # noqa: E501 + value (str):, must be one of ["placed", "approved", "delivered", "single quoted", '''multiple +lines''', '''double quote + with newline''', ] # noqa: E501 Keyword Args: _check_type (bool): if True, values for parameters in openapi_types diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py index fd425751def7..7431e0d1d920 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/model/string_enum_with_default_value.py @@ -103,7 +103,7 @@ def __init__(self, value, *args, **kwargs): """StringEnumWithDefaultValue - a model defined in OpenAPI Args: - value (str): if omitted the server will use the default value of 'placed', must be one of ["placed", "approved", "delivered", ] # noqa: E501 + value (str): if omitted the server will use the default value of "placed", must be one of ["placed", "approved", "delivered", ] # noqa: E501 Keyword Args: _check_type (bool): if True, values for parameters in openapi_types diff --git a/samples/openapi3/client/petstore/python-experimental/tests_manual/test_string_enum.py b/samples/openapi3/client/petstore/python-experimental/tests_manual/test_string_enum.py index a9f7431e24ee..87092d66d388 100644 --- a/samples/openapi3/client/petstore/python-experimental/tests_manual/test_string_enum.py +++ b/samples/openapi3/client/petstore/python-experimental/tests_manual/test_string_enum.py @@ -42,7 +42,10 @@ def testStringEnum(self): 'None': None, 'PLACED': "placed", 'APPROVED': "approved", - 'DELIVERED': "delivered" + 'DELIVERED': "delivered", + 'DOUBLE_QUOTE_WITH_NEWLINE': "double quote \n with newline", + 'MULTIPLE_LINES': "multiple\nlines", + 'SINGLE_QUOTED': "single quoted" } From dcf0f0973847a32e9a4981bb4641ed218462b476 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Tue, 18 Aug 2020 12:46:09 -0700 Subject: [PATCH 2/7] Rebased on master --- .../PythonClientExperimentalCodegen.java | 19 ------------------- .../python-experimental/docs/FakeApi.md | 4 ++-- .../petstore_api/api/fake_api.py | 2 +- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java index b0e2f9959372..3ee16cdc1ff3 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java @@ -215,25 +215,6 @@ public void processOpts() { LOGGER.info(CodegenConstants.GENERATE_ALIAS_AS_MODEL + " is hard coded to true in this generator. Alias models will only be generated if they contain validations or enums"); } -// /*** -// * We have a custom version of this method so we can store a map going from python ModelNames to schemas -// * -// * @param openAPI input spec -// */ -// @Override -// public void setOpenAPI(OpenAPI openAPI) { -// super.setOpenAPI(openAPI); -// Map allDefinitions = ModelUtils.getSchemas(openAPI); -// for (Map.Entry entry: allDefinitions.entrySet()) { -// Schema modelSchema = entry.getValue(); -// if (modelWillBeMade(modelSchema)) { -// String schemaName = entry.getKey(); -// String schemaModelName = toModelName(schemaName); -// modelNameToSchema.put(schemaModelName, modelSchema); -// } -// } -// } - /** * Configures a friendly name for the generator. This will be used by the * generator to select the library with the -g flag. diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md index 1efb8231ad6b..f86ae3a9838a 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md @@ -980,7 +980,7 @@ with petstore_api.ApiClient(configuration) as api_client: string = "a" # str | None (optional) binary = open('/path/to/file.txt', 'rb') # file_type | None (optional) date = datetime.datetime.strptime('1970-01-01', '%Y-%m-%d').date() # date | None (optional) - date_time = datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f') # datetime | None (optional) + date_time = datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f') # datetime | None (optional) if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') password = "password_example" # str | None (optional) param_callback = "param_callback_example" # str | None (optional) @@ -1015,7 +1015,7 @@ Name | Type | Description | Notes **string** | **str**| None | [optional] **binary** | **file_type**| None | [optional] **date** | **date**| None | [optional] - **date_time** | **datetime**| None | [optional] + **date_time** | **datetime**| None | [optional] if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') **password** | **str**| None | [optional] **param_callback** | **str**| None | [optional] diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api.py index a741eabc7e99..7654e5916de7 100644 --- a/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api.py +++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/api/fake_api.py @@ -1668,7 +1668,7 @@ def __test_endpoint_parameters( string (str): None. [optional] binary (file_type): None. [optional] date (date): None. [optional] - date_time (datetime): None. [optional] + date_time (datetime): None. [optional] if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') password (str): None. [optional] param_callback (str): None. [optional] _return_http_data_only (bool): response data without head status From fa5ac8ba936a58924a3fa536c7bd192dbf2a2675 Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 19 Aug 2020 08:49:13 -0700 Subject: [PATCH 3/7] Adds getModelNameToSchemaCache --- .../PythonClientExperimentalCodegen.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java index 3ee16cdc1ff3..1e5424dc0cb2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java @@ -17,9 +17,7 @@ package org.openapitools.codegen.languages; import io.swagger.v3.core.util.Json; -import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.examples.Example; import io.swagger.v3.oas.models.media.*; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.MediaType; @@ -28,7 +26,6 @@ import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.security.SecurityScheme; -import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.CodegenDiscriminator.MappedModel; @@ -51,11 +48,11 @@ import java.util.regex.Matcher; import static org.openapitools.codegen.utils.OnceLogger.once; -import static org.openapitools.codegen.utils.StringUtils.camelize; -import static org.openapitools.codegen.utils.StringUtils.underscore; public class PythonClientExperimentalCodegen extends PythonClientCodegen { private static final Logger LOGGER = LoggerFactory.getLogger(PythonClientExperimentalCodegen.class); + // A cache to efficiently lookup a Schema instance based on the return value of `toModelName()`. + private Map modelNameToSchemaCache; public PythonClientExperimentalCodegen() { super(); @@ -1653,4 +1650,21 @@ public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set //codegenParameter.collectionFormat = getCollectionFormat(propertySchema); return codegenParameter; } + + /** + * Return a map from model name to Schema for efficient lookup. + * + * @return map from model name to Schema. + */ + protected Map getModelNameToSchemaCache() { + if (modelNameToSchemaCache == null) { + // Create a cache to efficiently lookup schema based on model name. + Map m = new HashMap(); + ModelUtils.getSchemas(openAPI).forEach((key, schema) -> { + m.put(toModelName(key), schema); + }); + modelNameToSchemaCache = Collections.unmodifiableMap(m); + } + return modelNameToSchemaCache; + } } From 5a4469b32d503b2461694f53fc3e0dac756f709d Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 19 Aug 2020 18:47:45 -0700 Subject: [PATCH 4/7] Updates toDefaultValue to not mutate schemas --- .../PythonClientExperimentalCodegen.java | 115 +++++------------- .../.openapi-generator/VERSION | 2 +- .../python-experimental/docs/FakeApi.md | 2 +- .../python-experimental/docs/StoreApi.md | 2 +- 4 files changed, 36 insertions(+), 85 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java index 1e5424dc0cb2..87e1704c3f0b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java @@ -53,6 +53,8 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen { private static final Logger LOGGER = LoggerFactory.getLogger(PythonClientExperimentalCodegen.class); // A cache to efficiently lookup a Schema instance based on the return value of `toModelName()`. private Map modelNameToSchemaCache; + private DateTimeFormatter iso8601Date = DateTimeFormatter.ISO_DATE; + private DateTimeFormatter iso8601DateTime = DateTimeFormatter.ISO_DATE_TIME; public PythonClientExperimentalCodegen() { super(); @@ -223,15 +225,26 @@ public String getName() { return "python-experimental"; } - public String dateToString(Schema p, OffsetDateTime date, DateTimeFormatter dateFormatter, DateTimeFormatter dateTimeFormatter) { - // converts a date into a date or date-time python string - if (!(ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p))) { - throw new RuntimeException("passed schema must be of type Date or DateTime"); + public String pythonDate(Object dateValue) { + OffsetDateTime date = null; + try { + date = (OffsetDateTime) dateValue; + } catch (ClassCastException e) { + LOGGER.warn("Invalid `date` format for value {}", dateValue.toString()); + date = ((Date) dateValue).toInstant().atOffset(ZoneOffset.UTC); } - if (ModelUtils.isDateSchema(p)) { - return "dateutil_parser('" + date.format(dateFormatter) + "').date()"; + return "dateutil_parser('" + date.format(iso8601Date) + "').date()"; + } + + public String pythonDateTime(Object dateTimeValue) { + OffsetDateTime dateTime = null; + try { + dateTime = (OffsetDateTime) dateTimeValue; + } catch (ClassCastException e) { + LOGGER.warn("Invalid `date-time` format for value {}", dateTimeValue.toString()); + dateTime = ((Date) dateTimeValue).toInstant().atOffset(ZoneOffset.UTC); } - return "dateutil_parser('" + date.format(dateTimeFormatter) + "')"; + return "dateutil_parser('" + dateTime.format(iso8601DateTime) + "')"; } /** @@ -254,76 +267,25 @@ public String toDefaultValue(Schema p) { defaultObject = p.getEnum().get(0); } - // convert datetime and date enums if they exist - DateTimeFormatter iso8601Date = DateTimeFormatter.ISO_DATE; - DateTimeFormatter iso8601DateTime = DateTimeFormatter.ISO_DATE_TIME; - - if (ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)) { - List currentEnum = p.getEnum(); - List fixedEnum = new ArrayList(); - String fixedValue = null; - OffsetDateTime date = null; - if (currentEnum != null && !currentEnum.isEmpty()) { - for (Object enumItem : currentEnum) { - date = (OffsetDateTime) enumItem; - fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime); - fixedEnum.add(fixedValue); - } - p.setEnum(fixedEnum); - } - - // convert the example if it exists - Object currentExample = p.getExample(); - if (currentExample != null) { - try { - date = (OffsetDateTime) currentExample; - } catch (ClassCastException e) { - date = ((Date) currentExample).toInstant().atOffset(ZoneOffset.UTC); - LOGGER.warn("Invalid `date-time` format for value {}", currentExample); - } - fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime); - fixedEnum.add(fixedValue); - p.setExample(fixedValue); - LOGGER.warn(fixedValue); - } - - // fix defaultObject - if (defaultObject != null) { - date = (OffsetDateTime) defaultObject; - fixedValue = dateToString(p, date, iso8601Date, iso8601DateTime); - p.setDefault(fixedValue); - defaultObject = fixedValue; - } - } - if (defaultObject == null) { return null; } - String defaultValue = null; - if (ModelUtils.isStringSchema(p)) { - defaultValue = defaultObject.toString(); - if (ModelUtils.isDateSchema(p) || ModelUtils.isDateTimeSchema(p)) { - return defaultValue; - } - - if (!ModelUtils.isByteArraySchema(p) && !ModelUtils.isBinarySchema(p) && !ModelUtils.isFileSchema(p) && !ModelUtils.isUUIDSchema(p) && !ModelUtils.isEmailSchema(p) && !ModelUtils.isDateTimeSchema(p) && !ModelUtils.isDateSchema(p)) { - defaultValue = ensureQuotes(defaultValue); - } - return defaultValue; - } else if (ModelUtils.isIntegerSchema(p) || ModelUtils.isNumberSchema(p) || ModelUtils.isBooleanSchema(p)) { - defaultValue = String.valueOf(defaultObject); - if (ModelUtils.isBooleanSchema(p)) { - if (Boolean.valueOf(defaultValue) == false) { - return "False"; - } else { - return "True"; - } + String defaultValue = defaultObject.toString(); + if (ModelUtils.isDateSchema(p)) { + defaultValue = pythonDate(defaultObject); + } else if (ModelUtils.isDateTimeSchema(p)) { + defaultValue = pythonDateTime(defaultObject); + } else if (ModelUtils.isStringSchema(p) && !ModelUtils.isByteArraySchema(p) && !ModelUtils.isBinarySchema(p) && !ModelUtils.isFileSchema(p) && !ModelUtils.isUUIDSchema(p) && !ModelUtils.isEmailSchema(p)) { + defaultValue = ensureQuotes(defaultValue); + } else if (ModelUtils.isBooleanSchema(p)) { + if (Boolean.valueOf(defaultValue) == false) { + defaultValue = "False"; + } else { + defaultValue = "True"; } - return defaultValue; - } else { - return defaultObject.toString(); } + return defaultValue; } @Override @@ -1146,17 +1108,6 @@ protected String toExampleValueBase(Schema sc) { } else if (schema.getEnum() != null && !schema.getEnum().isEmpty()) { example = schema.getEnum().get(0).toString(); } - if (ModelUtils.isStringSchema(schema) && example != null && example.length() >= 2) { - // TODO check to see if example does not have quotes on it - // if it lacks them add double quotes - // TODO update the string handling code to just use the value without adding quotes - char firstChar = example.charAt(0); - char lastChar = example.charAt(example.length() - 1); - char quoteChar = "'".charAt(0); - if (firstChar == quoteChar && lastChar == quoteChar) { - example = example.substring(1, example.length()-1); - } - } return example; } diff --git a/samples/openapi3/client/petstore/python-experimental/.openapi-generator/VERSION b/samples/openapi3/client/petstore/python-experimental/.openapi-generator/VERSION index d99e7162d01f..717311e32e3c 100644 --- a/samples/openapi3/client/petstore/python-experimental/.openapi-generator/VERSION +++ b/samples/openapi3/client/petstore/python-experimental/.openapi-generator/VERSION @@ -1 +1 @@ -5.0.0-SNAPSHOT \ No newline at end of file +unset \ No newline at end of file diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md index f86ae3a9838a..c294a190a5cc 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md @@ -980,7 +980,7 @@ with petstore_api.ApiClient(configuration) as api_client: string = "a" # str | None (optional) binary = open('/path/to/file.txt', 'rb') # file_type | None (optional) date = datetime.datetime.strptime('1970-01-01', '%Y-%m-%d').date() # date | None (optional) - date_time = datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f') # datetime | None (optional) if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') + date_time = datetime.datetime.strptime('2020-02-02T20:20:20.222220Z', '%Y-%m-%dT%H:%M:%S.%f') # datetime | None (optional) if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') password = "password_example" # str | None (optional) param_callback = "param_callback_example" # str | None (optional) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md b/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md index 5f031ddf3b79..13c72666d925 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md @@ -238,7 +238,7 @@ with petstore_api.ApiClient() as api_client: id=1, pet_id=1, quantity=1, - ship_date=datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f'), + ship_date=datetime.datetime.strptime('2020-02-02T20:20:20.000222Z', '%Y-%m-%dT%H:%M:%S.%f'), status="placed", complete=False, ) # Order | order placed for purchasing the pet From 412db5dac5499b106900c2f80be71f3fdb06941d Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 19 Aug 2020 20:31:46 -0700 Subject: [PATCH 5/7] Has all dates and datetimes default and example setting use the same helper function --- .../PythonClientExperimentalCodegen.java | 142 +++++++++++------- .../python-experimental/docs/FakeApi.md | 4 +- .../python-experimental/docs/StoreApi.md | 2 +- 3 files changed, 87 insertions(+), 61 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java index 87e1704c3f0b..57a9dca2fdf8 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java @@ -226,25 +226,37 @@ public String getName() { } public String pythonDate(Object dateValue) { - OffsetDateTime date = null; - try { - date = (OffsetDateTime) dateValue; - } catch (ClassCastException e) { - LOGGER.warn("Invalid `date` format for value {}", dateValue.toString()); - date = ((Date) dateValue).toInstant().atOffset(ZoneOffset.UTC); - } - return "dateutil_parser('" + date.format(iso8601Date) + "').date()"; + String strValue = null; + if (dateValue instanceof OffsetDateTime) { + OffsetDateTime date = null; + try { + date = (OffsetDateTime) dateValue; + } catch (ClassCastException e) { + LOGGER.warn("Invalid `date` format for value {}", dateValue.toString()); + date = ((Date) dateValue).toInstant().atOffset(ZoneOffset.UTC); + } + strValue = date.format(iso8601Date); + } else { + strValue = dateValue.toString(); + } + return "dateutil_parser('" + strValue + "').date()"; } public String pythonDateTime(Object dateTimeValue) { - OffsetDateTime dateTime = null; - try { - dateTime = (OffsetDateTime) dateTimeValue; - } catch (ClassCastException e) { - LOGGER.warn("Invalid `date-time` format for value {}", dateTimeValue.toString()); - dateTime = ((Date) dateTimeValue).toInstant().atOffset(ZoneOffset.UTC); - } - return "dateutil_parser('" + dateTime.format(iso8601DateTime) + "')"; + String strValue = null; + if (dateTimeValue instanceof OffsetDateTime) { + OffsetDateTime dateTime = null; + try { + dateTime = (OffsetDateTime) dateTimeValue; + } catch (ClassCastException e) { + LOGGER.warn("Invalid `date-time` format for value {}", dateTimeValue.toString()); + dateTime = ((Date) dateTimeValue).toInstant().atOffset(ZoneOffset.UTC); + } + strValue = dateTime.format(iso8601DateTime); + } else { + strValue = dateTimeValue.toString(); + } + return "dateutil_parser('" + strValue + "')"; } /** @@ -1088,7 +1100,13 @@ protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Sc // to false, i.e. no additional properties are allowed. } - protected String toExampleValueBase(Schema sc) { + /** + * Gets an example if it exists + * + * @param sc input schema + * @return the example value + */ + protected Object getObjectExample(Schema sc) { Schema schema = sc; String ref = sc.get$ref(); if (ref != null) { @@ -1099,16 +1117,14 @@ protected String toExampleValueBase(Schema sc) { if (objectModel) { return null; } - String example = null; - String defaultValue = toDefaultValue(schema); if (schema.getExample() != null) { - example = schema.getExample().toString(); - } else if (defaultValue != null) { - example = defaultValue; + return schema.getExample(); + } if (schema.getDefault() != null) { + return schema.getDefault(); } else if (schema.getEnum() != null && !schema.getEnum().isEmpty()) { - example = schema.getEnum().get(0).toString(); + return schema.getEnum().get(0); } - return example; + return null; } /*** @@ -1186,12 +1202,6 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o String currentIndentation = ""; String closingIndentation = ""; for (int i=0 ; i < indentationLevel ; i++) currentIndentation += indentionConst; - String example = null; - if (objExample instanceof String) { - example = (String) objExample; - } else { - example = toExampleValueBase(schema); - } if (exampleLine.equals(0)) { closingIndentation = currentIndentation; currentIndentation = ""; @@ -1207,6 +1217,10 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o String fullPrefix = currentIndentation + prefix + openChars; + String example = null; + if (objExample != null) { + example = objExample.toString(); + } if (null != schema.get$ref()) { // $ref case: Map allDefinitions = ModelUtils.getSchemas(this.openAPI); @@ -1227,10 +1241,10 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o // though this tooling supports it. return fullPrefix + "None" + closeChars; } else if (ModelUtils.isBooleanSchema(schema)) { - if (example == null) { + if (objExample == null) { example = "True"; } else { - if ("false".equalsIgnoreCase(example)) { + if ("false".equalsIgnoreCase(objExample.toString())) { example = "False"; } else { example = "True"; @@ -1238,31 +1252,32 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o } return fullPrefix + example + closeChars; } else if (ModelUtils.isDateSchema(schema)) { - if (example == null) { - example = "1970-01-01"; + if (objExample == null) { + example = pythonDate("1970-01-01"); + } else { + example = pythonDate(objExample); } - example = "datetime.datetime.strptime('" + example + "', '%Y-%m-%d').date()"; return fullPrefix + example + closeChars; } else if (ModelUtils.isDateTimeSchema(schema)) { - if (example == null) { - example = "1970-01-01T00:00:00.00Z"; + if (objExample == null) { + example = pythonDateTime("1970-01-01T00:00:00.00Z"); + } else { + example = pythonDateTime(objExample); } - // TODO add time zone offset to sample - example = "datetime.datetime.strptime('" + example + "', '%Y-%m-%dT%H:%M:%S.%f')"; return fullPrefix + example + closeChars; } else if (ModelUtils.isBinarySchema(schema)) { - if (example == null) { + if (objExample == null) { example = "/path/to/file.txt"; } example = "open('" + example + "', 'rb')"; return fullPrefix + example + closeChars; } else if (ModelUtils.isByteArraySchema(schema)) { - if (example == null) { + if (objExample == null) { example = "'YQ=='"; } return fullPrefix + example + closeChars; } else if (ModelUtils.isStringSchema(schema)) { - if (example == null) { + if (objExample == null) { // a BigDecimal: if ("Number".equalsIgnoreCase(schema.getFormat())) { example = "2"; @@ -1293,7 +1308,7 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o } return fullPrefix + ensureQuotes(example) + closeChars; } else if (ModelUtils.isIntegerSchema(schema)) { - if (example == null) { + if (objExample == null) { if (schema.getMinimum() != null) { example = schema.getMinimum().toString(); } else { @@ -1302,7 +1317,7 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o } return fullPrefix + example + closeChars; } else if (ModelUtils.isNumberSchema(schema)) { - if (example == null) { + if (objExample == null) { if (schema.getMinimum() != null) { example = schema.getMinimum().toString(); } else { @@ -1326,7 +1341,7 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o if (addPropsObj instanceof Schema) { Schema addPropsSchema = (Schema) addPropsObj; String key = "key"; - Object addPropsExample = toExampleValueBase(addPropsSchema); + Object addPropsExample = getObjectExample(addPropsSchema); if (addPropsSchema.getEnum() != null && !addPropsSchema.getEnum().isEmpty()) { key = addPropsSchema.getEnum().get(0).toString(); } @@ -1401,8 +1416,7 @@ private String exampleForObjectModel(Schema schema, String fullPrefix, String cl propExample = discProp.example; } else { propModelName = getModelName(propSchema); - propExample = toExampleValueBase(propSchema); - propExample = exampleFromStringOrArraySchema(propSchema, propExample, propName); + propExample = exampleFromStringOrArraySchema(propSchema, null, propName); } example += toExampleValueRecursive(propModelName, propSchema, propExample, indentationLevel + 1, propName + "=", exampleLine + 1) + ",\n"; } @@ -1415,18 +1429,27 @@ private Object exampleFromStringOrArraySchema(Schema sc, Object currentExample, if (currentExample != null) { return currentExample; } - String example = null; - if (simpleStringSchema(sc)) { - example = propName + "_example"; - } else if (ModelUtils.isArraySchema(sc)) { - ArraySchema arraySchema = (ArraySchema) sc; + Schema schema = sc; + String ref = sc.get$ref(); + if (ref != null) { + schema = ModelUtils.getSchema(this.openAPI, ModelUtils.getSimpleRef(ref)); + } + Object example = getObjectExample(schema); + if (example != null) { + return example; + } else if (simpleStringSchema(schema)) { + return propName + "_example"; + } else if (ModelUtils.isArraySchema(schema)) { + ArraySchema arraySchema = (ArraySchema) schema; Schema itemSchema = arraySchema.getItems(); - String itemExample = toExampleValueBase(itemSchema); - if (simpleStringSchema(itemSchema) && itemExample == null) { - example = propName + "_example"; + example = getObjectExample(itemSchema); + if (example != null ) { + return example; + } else if (simpleStringSchema(itemSchema)) { + return propName + "_example"; } } - return example; + return null; } @@ -1454,7 +1477,7 @@ public void setParameterExampleValue(CodegenParameter codegenParameter, Paramete } else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty() && parameter.getExamples().values().iterator().next().getValue() != null) { example = parameter.getExamples().values().iterator().next().getValue(); } else { - example = toExampleValueBase(schema); + example = getObjectExample(schema); } example = exampleFromStringOrArraySchema(schema, example, parameter.getName()); String finalExample = toExampleValue(schema, example); @@ -1487,13 +1510,16 @@ public void setParameterExampleValue(CodegenParameter codegenParameter, RequestB return; } + if ("array_of_enums".equals(codegenParameter.paramName)) { + String a = "a"; + } Object example = null; if (mediaType.getExample() != null) { example = mediaType.getExample(); } else if (mediaType.getExamples() != null && !mediaType.getExamples().isEmpty() && mediaType.getExamples().values().iterator().next().getValue() != null) { example = mediaType.getExamples().values().iterator().next().getValue(); } else { - example = toExampleValueBase(schema); + example = getObjectExample(schema); } example = exampleFromStringOrArraySchema(schema, example, codegenParameter.paramName); codegenParameter.example = toExampleValue(schema, example); diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md index c294a190a5cc..b96e9c86c2a7 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md @@ -979,8 +979,8 @@ with petstore_api.ApiClient(configuration) as api_client: float = 3.14 # float | None (optional) string = "a" # str | None (optional) binary = open('/path/to/file.txt', 'rb') # file_type | None (optional) - date = datetime.datetime.strptime('1970-01-01', '%Y-%m-%d').date() # date | None (optional) - date_time = datetime.datetime.strptime('2020-02-02T20:20:20.222220Z', '%Y-%m-%dT%H:%M:%S.%f') # datetime | None (optional) if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') + date = dateutil_parser('1970-01-01').date() # date | None (optional) + date_time = dateutil_parser('2020-02-02T20:20:20.22222Z') # datetime | None (optional) if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') password = "password_example" # str | None (optional) param_callback = "param_callback_example" # str | None (optional) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md b/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md index 13c72666d925..5b5c30f2761f 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/StoreApi.md @@ -238,7 +238,7 @@ with petstore_api.ApiClient() as api_client: id=1, pet_id=1, quantity=1, - ship_date=datetime.datetime.strptime('2020-02-02T20:20:20.000222Z', '%Y-%m-%dT%H:%M:%S.%f'), + ship_date=dateutil_parser('2020-02-02T20:20:20.000222Z'), status="placed", complete=False, ) # Order | order placed for purchasing the pet From 69e7cc558c019b5f6471ac205d4d8895af75c24a Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 19 Aug 2020 20:41:38 -0700 Subject: [PATCH 6/7] Samples regenerated --- .../codegen/languages/PythonClientExperimentalCodegen.java | 3 --- samples/client/petstore/python-experimental/docs/FakeApi.md | 4 ++-- samples/client/petstore/python-experimental/docs/StoreApi.md | 2 +- .../petstore/python-experimental/.openapi-generator/VERSION | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java index 57a9dca2fdf8..d76b2db2bf0a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java @@ -1510,9 +1510,6 @@ public void setParameterExampleValue(CodegenParameter codegenParameter, RequestB return; } - if ("array_of_enums".equals(codegenParameter.paramName)) { - String a = "a"; - } Object example = null; if (mediaType.getExample() != null) { example = mediaType.getExample(); diff --git a/samples/client/petstore/python-experimental/docs/FakeApi.md b/samples/client/petstore/python-experimental/docs/FakeApi.md index d5980415b3d5..f3d455cdfa91 100644 --- a/samples/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/client/petstore/python-experimental/docs/FakeApi.md @@ -828,8 +828,8 @@ with petstore_api.ApiClient(configuration) as api_client: float = 3.14 # float | None (optional) string = "a" # str | None (optional) binary = open('/path/to/file.txt', 'rb') # file_type | None (optional) - date = datetime.datetime.strptime('1970-01-01', '%Y-%m-%d').date() # date | None (optional) - date_time = datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f') # datetime | None (optional) + date = dateutil_parser('1970-01-01').date() # date | None (optional) + date_time = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | None (optional) password = "password_example" # str | None (optional) param_callback = "param_callback_example" # str | None (optional) diff --git a/samples/client/petstore/python-experimental/docs/StoreApi.md b/samples/client/petstore/python-experimental/docs/StoreApi.md index 3406644d4fc0..b8065abf64ff 100644 --- a/samples/client/petstore/python-experimental/docs/StoreApi.md +++ b/samples/client/petstore/python-experimental/docs/StoreApi.md @@ -238,7 +238,7 @@ with petstore_api.ApiClient() as api_client: id=1, pet_id=1, quantity=1, - ship_date=datetime.datetime.strptime('1970-01-01T00:00:00.00Z', '%Y-%m-%dT%H:%M:%S.%f'), + ship_date=dateutil_parser('1970-01-01T00:00:00.00Z'), status="placed", complete=False, ) # Order | order placed for purchasing the pet diff --git a/samples/openapi3/client/petstore/python-experimental/.openapi-generator/VERSION b/samples/openapi3/client/petstore/python-experimental/.openapi-generator/VERSION index 717311e32e3c..d99e7162d01f 100644 --- a/samples/openapi3/client/petstore/python-experimental/.openapi-generator/VERSION +++ b/samples/openapi3/client/petstore/python-experimental/.openapi-generator/VERSION @@ -1 +1 @@ -unset \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file From 35126636cb31e3fde74f159ed46df39ef2730abf Mon Sep 17 00:00:00 2001 From: Justin Black Date: Wed, 19 Aug 2020 20:49:59 -0700 Subject: [PATCH 7/7] indentation tweak, removes txt from sample file --- .../codegen/languages/PythonClientExperimentalCodegen.java | 2 +- samples/client/petstore/python-experimental/docs/FakeApi.md | 2 +- samples/client/petstore/python-experimental/docs/PetApi.md | 4 ++-- .../client/petstore/python-experimental/docs/FakeApi.md | 2 +- .../client/petstore/python-experimental/docs/PetApi.md | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java index d76b2db2bf0a..941c5d11d87b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java @@ -1267,7 +1267,7 @@ private String toExampleValueRecursive(String modelName, Schema schema, Object o return fullPrefix + example + closeChars; } else if (ModelUtils.isBinarySchema(schema)) { if (objExample == null) { - example = "/path/to/file.txt"; + example = "/path/to/file"; } example = "open('" + example + "', 'rb')"; return fullPrefix + example + closeChars; diff --git a/samples/client/petstore/python-experimental/docs/FakeApi.md b/samples/client/petstore/python-experimental/docs/FakeApi.md index f3d455cdfa91..b098d80fdd33 100644 --- a/samples/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/client/petstore/python-experimental/docs/FakeApi.md @@ -827,7 +827,7 @@ with petstore_api.ApiClient(configuration) as api_client: int64 = 1 # int | None (optional) float = 3.14 # float | None (optional) string = "a" # str | None (optional) - binary = open('/path/to/file.txt', 'rb') # file_type | None (optional) + binary = open('/path/to/file', 'rb') # file_type | None (optional) date = dateutil_parser('1970-01-01').date() # date | None (optional) date_time = dateutil_parser('1970-01-01T00:00:00.00Z') # datetime | None (optional) password = "password_example" # str | None (optional) diff --git a/samples/client/petstore/python-experimental/docs/PetApi.md b/samples/client/petstore/python-experimental/docs/PetApi.md index 6189bcf25c03..f00dd3a66486 100644 --- a/samples/client/petstore/python-experimental/docs/PetApi.md +++ b/samples/client/petstore/python-experimental/docs/PetApi.md @@ -631,7 +631,7 @@ with petstore_api.ApiClient(configuration) as api_client: api_instance = pet_api.PetApi(api_client) pet_id = 1 # int | ID of pet to update additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) - file = open('/path/to/file.txt', 'rb') # file_type | file to upload (optional) + file = open('/path/to/file', 'rb') # file_type | file to upload (optional) files = # [file_type] | files to upload (optional) # example passing only required values which don't have defaults set @@ -717,7 +717,7 @@ with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) pet_id = 1 # int | ID of pet to update - required_file = open('/path/to/file.txt', 'rb') # file_type | file to upload + required_file = open('/path/to/file', 'rb') # file_type | file to upload additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) # example passing only required values which don't have defaults set diff --git a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md index b96e9c86c2a7..a5cbcb9e0f7e 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/FakeApi.md @@ -978,7 +978,7 @@ with petstore_api.ApiClient(configuration) as api_client: int64 = 1 # int | None (optional) float = 3.14 # float | None (optional) string = "a" # str | None (optional) - binary = open('/path/to/file.txt', 'rb') # file_type | None (optional) + binary = open('/path/to/file', 'rb') # file_type | None (optional) date = dateutil_parser('1970-01-01').date() # date | None (optional) date_time = dateutil_parser('2020-02-02T20:20:20.22222Z') # datetime | None (optional) if omitted the server will use the default value of dateutil_parser('2010-02-01T10:20:10.11111+01:00') password = "password_example" # str | None (optional) diff --git a/samples/openapi3/client/petstore/python-experimental/docs/PetApi.md b/samples/openapi3/client/petstore/python-experimental/docs/PetApi.md index f141a5377700..5ba8114a4a39 100644 --- a/samples/openapi3/client/petstore/python-experimental/docs/PetApi.md +++ b/samples/openapi3/client/petstore/python-experimental/docs/PetApi.md @@ -866,7 +866,7 @@ with petstore_api.ApiClient(configuration) as api_client: api_instance = pet_api.PetApi(api_client) pet_id = 1 # int | ID of pet to update additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) - file = open('/path/to/file.txt', 'rb') # file_type | file to upload (optional) + file = open('/path/to/file', 'rb') # file_type | file to upload (optional) # example passing only required values which don't have defaults set try: @@ -950,7 +950,7 @@ with petstore_api.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = pet_api.PetApi(api_client) pet_id = 1 # int | ID of pet to update - required_file = open('/path/to/file.txt', 'rb') # file_type | file to upload + required_file = open('/path/to/file', 'rb') # file_type | file to upload additional_metadata = "additional_metadata_example" # str | Additional data to pass to server (optional) # example passing only required values which don't have defaults set