diff --git a/README.md b/README.md index 5d5dbcfd42c6..dd1a0f98c711 100644 --- a/README.md +++ b/README.md @@ -482,7 +482,7 @@ SYNOPSIS [--model-name-prefix ] [--model-name-suffix ] [--model-package ] - [(-o | --output )] + [(-o | --output )] [(-p | --additional-properties )...] [--package-name ] [--release-note ] [--remove-operation-id-prefix] @@ -562,7 +562,7 @@ Here is a list of community-conitributed IDE plug-ins that integrate with OpenAP - Visual Studio: [REST API Client Code Generator](https://marketplace.visualstudio.com/items?itemName=ChristianResmaHelle.ApiClientCodeGenerator) by [Christian Resma Helle](https://christian-helle.blogspot.com/) - Visual Studio Code: [Codewind OpenAPI Tools](https://marketplace.visualstudio.com/items?itemName=IBM.codewind-openapi-tools) by [IBM](https://marketplace.visualstudio.com/publishers/IBM) - + ## [4 - Companies/Projects using OpenAPI Generator](#table-of-contents) Here are some companies/projects (alphabetical order) using OpenAPI Generator in production. To add your company/project to the list, please visit [README.md](README.md) and click on the icon to edit the page. @@ -727,7 +727,7 @@ OpenAPI Generator core team members are contributors who have been making signif * [@jmini](https://github.com/jmini) (2018/04) [:heart:](https://www.patreon.com/jmini) * [@etherealjoy](https://github.com/etherealjoy) (2019/06) -:heart: = Link to support the contributor directly +:heart: = Link to support the contributor directly #### Template Creator @@ -782,8 +782,9 @@ Here is a list of template creators: * Perl: @wing328 [:heart:](https://www.patreon.com/wing328) * PHP (Guzzle): @baartosz * PowerShell: @beatcracker + * Python-experimental: @spacether * R: @ramnov - * Ruby (Faraday): @meganemura @dkliban + * Ruby (Faraday): @meganemura @dkliban * Rust: @farcaller * Rust (rust-server): @metaswitch * Scala (scalaz & http4s): @tbrown1979 @@ -793,7 +794,7 @@ Here is a list of template creators: * Swift 4: @ehyche * TypeScript (Angular1): @mhardorf * TypeScript (Angular2): @roni-frantchi - * TypeScript (Angular6): @akehir + * TypeScript (Angular6): @akehir * TypeScript (Angular7): @topce * TypeScript (Axios): @nicokoenig * TypeScript (Fetch): @leonyu @@ -805,7 +806,7 @@ Here is a list of template creators: * Server Stubs * Ada: @stcarrez * C# ASP.NET 5: @jimschubert [:heart:](https://www.patreon.com/jimschubert) - * C# ASP.NET Core 3.0: @A-Joshi + * C# ASP.NET Core 3.0: @A-Joshi * C# NancyFX: @mstefaniuk * C++ (Qt5 QHttpEngine): @etherealjoy * C++ Pistache: @sebymiano @@ -848,7 +849,7 @@ Here is a list of template creators: * Configuration * Apache2: @stkrwork * Schema - * Avro: @sgadouar + * Avro: @sgadouar * GraphQL: @wing328 [:heart:](https://www.patreon.com/wing328) * MySQL: @ybelenko * Protocol Buffer: @wing328 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 7c2c4565b361..622bece963b9 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 @@ -1807,10 +1807,12 @@ public CodegenModel fromModel(String name, Schema schema) { m.allVars = new ArrayList(); if (composed.getAllOf() != null) { int modelImplCnt = 0; // only one inline object allowed in a ComposedModel + int modelDiscriminators = 0; // only one discriminator allowed in a ComposedModel for (Schema innerSchema : composed.getAllOf()) { // TOOD need to work with anyOf, oneOf as well - if (m.discriminator == null) { + if (m.discriminator == null && innerSchema.getDiscriminator() != null) { LOGGER.debug("discriminator is set to null (not correctly set earlier): {}", name); - m.discriminator = createDiscriminator(name, schema); + m.discriminator = createDiscriminator(name, innerSchema); + modelDiscriminators++; } if (innerSchema.getXml() != null) { @@ -1818,6 +1820,9 @@ public CodegenModel fromModel(String name, Schema schema) { m.xmlNamespace = innerSchema.getXml().getNamespace(); m.xmlName = innerSchema.getXml().getName(); } + if (modelDiscriminators > 1) { + LOGGER.error("Allof composed schema is inheriting >1 discriminator. Only use one discriminator: {}", composed); + } if (modelImplCnt++ > 1) { LOGGER.warn("More than one inline schema specified in allOf:. Only the first one is recognized. All others are ignored."); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java index 16ec0bd3c03a..4538ee1b5f20 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java @@ -273,7 +273,7 @@ public void processOpts() { } - private static String dropDots(String str) { + protected static String dropDots(String str) { return str.replaceAll("\\.", "_"); } 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 13cbb443aab4..eb3c65438ea9 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 @@ -52,6 +52,8 @@ public PythonClientExperimentalCodegen() { // this may set datatype right for additional properties instantiationTypes.put("map", "dict"); + languageSpecificPrimitives.add("file_type"); + languageSpecificPrimitives.add("none_type"); apiTemplateFiles.remove("api.mustache"); apiTemplateFiles.put("python-experimental/api.mustache", ".py"); @@ -65,6 +67,9 @@ public PythonClientExperimentalCodegen() { modelTemplateFiles.remove("model.mustache"); modelTemplateFiles.put("python-experimental/model.mustache", ".py"); + modelTestTemplateFiles.remove("model_test.mustache", ".py"); + modelTestTemplateFiles.put("python-experimental/model_test.mustache", ".py"); + generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) .stability(Stability.EXPERIMENTAL) .build(); @@ -79,11 +84,33 @@ public void processOpts() { supportingFiles.add(new SupportingFile("python-experimental/model_utils.mustache", packagePath(), "model_utils.py")); + supportingFiles.remove(new SupportingFile("__init__model.mustache", packagePath() + File.separatorChar + "models", "__init__.py")); + supportingFiles.add(new SupportingFile("python-experimental/__init__model.mustache", packagePath() + File.separatorChar + "models", "__init__.py")); + + supportingFiles.remove(new SupportingFile("__init__package.mustache", packagePath(), "__init__.py")); + supportingFiles.add(new SupportingFile("python-experimental/__init__package.mustache", packagePath(), "__init__.py")); + + Boolean generateSourceCodeOnly = false; if (additionalProperties.containsKey(CodegenConstants.SOURCECODEONLY_GENERATION)) { generateSourceCodeOnly = Boolean.valueOf(additionalProperties.get(CodegenConstants.SOURCECODEONLY_GENERATION).toString()); } + // remove what PythonClientCodegen did + String readmePath = "README.md"; + String readmeTemplate = "README.mustache"; + if (generateSourceCodeOnly) { + readmePath = packagePath() + "_" + readmePath; + readmeTemplate = "README_onlypackage.mustache"; + } + supportingFiles.remove(new SupportingFile(readmeTemplate, "", readmePath)); + // add the correct readme + readmeTemplate = "python-experimental/README.mustache"; + if (generateSourceCodeOnly) { + readmeTemplate = "python-experimental/README_onlypackage.mustache"; + } + supportingFiles.add(new SupportingFile(readmeTemplate, "", readmePath)); + if (!generateSourceCodeOnly) { supportingFiles.remove(new SupportingFile("setup.mustache", "", "setup.py")); supportingFiles.add(new SupportingFile("python-experimental/setup.mustache", "", "setup.py")); @@ -213,19 +240,76 @@ public String toDefaultValue(Schema p) { } } - public void addModelImport(Map objs, CodegenModel cm, String otherModelName) { - // adds the absolute path to otherModelName as an import in CodegenModel cm - HashMap referencedModel = (HashMap) objs.get(otherModelName); - if (referencedModel == null) { - // this happens with a model where type=string and format=number which is a non-standard format + @Override + public String toModelImport(String name) { + // name looks like cat.Cat + String moduleName = name.split("\\.")[0]; + // https://exceptionshub.com/circular-or-cyclic-imports-in-python.html + return "from " + modelPackage() + " import "+ moduleName; + } + + private String robustImport(String name) { + // name looks like cat.Cat + String moduleName = name.split("\\.")[0]; + // https://exceptionshub.com/circular-or-cyclic-imports-in-python.html + String modelImport = "try:\n from " + modelPackage() + " import "+ moduleName+ "\nexcept ImportError:\n "+moduleName+" = sys.modules['"+modelPackage() + "."+ moduleName+"']"; + return modelImport; + } + + private String getPythonClassName(String name) { + // name looks like cat.Cat or Cat + String[] pieces = name.split("\\."); + if (pieces.length == 1) { + return pieces[0]; + } + return pieces[1]; + } + + private void fixOperationImports(Set imports) { + if (imports.size() == 0) { return; } - ArrayList myModel = (ArrayList) referencedModel.get("models"); - HashMap modelData = (HashMap) myModel.get(0); - String importPath = (String) modelData.get("importPath"); - // only add importPath to parameters if it isn't in importPaths - if (!cm.imports.contains(importPath)) { - cm.imports.add(importPath); + String[] modelNames = imports.toArray(new String[0]); + imports.clear(); + // loops through imports and converts them all from 'module.Class' to 'from models.module import module' + for (String modelName : modelNames) { + // if a modelName lacks the module (Pet) then we convert it to pet.Pet + if (modelName.indexOf(".") == -1) { + modelName = toModelName(modelName); + } + imports.add(toModelImport(modelName)); + } + } + + @Override + @SuppressWarnings("static-method") + public Map postProcessOperationsWithModels(Map objs, List allModels) { + HashMap val = (HashMap)objs.get("operations"); + ArrayList operations = (ArrayList) val.get("operation"); + ArrayList> imports = (ArrayList>)objs.get("imports"); + imports.clear(); + for (CodegenOperation operation : operations) { + fixOperationImports(operation.imports); + for (String thisImport : operation.imports) { + HashMap higherImport = new HashMap(); + higherImport.put("import", thisImport); + if (!imports.contains(higherImport)) { + imports.add(higherImport); + } + } + } + return objs; + } + + private void fixModelImports(Set imports) { + // loops through imports and converts them all from 'module.Class' to 'import models.module as module' + if (imports.size() == 0) { + return; + } + String[] modelNames = imports.toArray(new String[0]); + imports.clear(); + for (String modelName : modelNames) { + imports.add(robustImport(modelName)); } } @@ -241,40 +325,30 @@ public Map postProcessAllModels(Map objs) { for (Map mo : models) { CodegenModel cm = (CodegenModel) mo.get("model"); - // fix the imports that each model has, change them to absolute - // imports - // clear out imports so we will only include full path imports - cm.imports.clear(); + // make sure discrimonator models are included in imports CodegenDiscriminator discriminator = cm.discriminator; if (discriminator != null) { Set mappedModels = discriminator.getMappedModels(); for (CodegenDiscriminator.MappedModel mappedModel : mappedModels) { String otherModelName = mappedModel.getModelName(); - addModelImport(objs, cm, otherModelName); + cm.imports.add(otherModelName); } } - ArrayList> listOfLists= new ArrayList>(); - listOfLists.add(cm.allVars); - listOfLists.add(cm.requiredVars); - listOfLists.add(cm.optionalVars); - listOfLists.add(cm.vars); - for (List varList : listOfLists) { - for (CodegenProperty cp : varList) { - String otherModelName = null; - if (cp.complexType != null) { - otherModelName = cp.complexType; - } - if (cp.mostInnerItems != null) { - if (cp.mostInnerItems.complexType != null) { - otherModelName = cp.mostInnerItems.complexType; - } - } - if (otherModelName != null) { - addModelImport(objs, cm, otherModelName); - } - } + + // add imports for anyOf, allOf, oneOf + ArrayList> composedSchemaSets = new ArrayList>(); + composedSchemaSets.add(cm.allOf); + composedSchemaSets.add(cm.anyOf); + composedSchemaSets.add(cm.oneOf); + for (Set importSet : composedSchemaSets) { + for (String otherModelName : importSet) { + cm.imports.add(otherModelName); + } } + // fix the imports that each model has, change them to absolute + fixModelImports(cm.imports); + Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name); CodegenProperty modelProperty = fromProperty("value", modelSchema); if (cm.isEnum || cm.isAlias) { @@ -396,17 +470,20 @@ public CodegenParameter fromRequestBody(RequestBody body, Set imports, S CodegenProperty modelProp = fromProperty("body", realSchema); if (modelProp.isPrimitiveType && (modelProp.hasValidation || modelProp.isEnum)) { String simpleDataType = result.dataType; - result.isPrimitiveType = false; - result.isModel = true; - result.dataType = modelName; - imports.add(modelName); + result.dataType = toModelName(modelName); + result.baseType = getPythonClassName(result.dataType); + imports.remove(modelName); + imports.add(result.dataType); // set the example value if (modelProp.isEnum) { String value = modelProp._enum.get(0).toString(); - result.example = modelName + "(" + toEnumValue(value, simpleDataType) + ")"; + result.example = this.packageName + "." + result.baseType + "(" + toEnumValue(value, simpleDataType) + ")"; } else { - result.example = modelName + "(" + result.example + ")"; + result.example = this.packageName + "." + result.baseType + "(" + result.example + ")"; } + } else if (!result.isPrimitiveType) { + // fix the baseType for the api docs so the .md link to the class's documentation file is correct + result.baseType = getPythonClassName(result.baseType); } return result; } @@ -421,7 +498,7 @@ public CodegenParameter fromRequestBody(RequestBody body, Set imports, S @Override public CodegenResponse fromResponse(String responseCode, ApiResponse response) { // if a response points at a model whose type != object and it has validations and/or enums, then we will - // generate the model, and the response.isModel must be changed to true and response.baseType must be the name + // generate the model, and response.baseType must be the name // of the model. Point responses at models if the model is python class type ModelSimple // When we serialize/deserialize ModelSimple models, validations and enums will be checked. Schema responseSchema; @@ -435,13 +512,13 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) { if (responseSchema != null) { CodegenProperty cp = fromProperty("response", responseSchema); if (cp.complexType != null) { - // check the referenced schema to see if it is an type=object model - Schema modelSchema = ModelUtils.getSchema(this.openAPI, cp.complexType); + String modelName = getPythonClassName(cp.complexType); + Schema modelSchema = ModelUtils.getSchema(this.openAPI, modelName); if (modelSchema != null && !"object".equals(modelSchema.getType())) { CodegenProperty modelProp = fromProperty("response", modelSchema); if (modelProp.isEnum == true || modelProp.hasValidation == true) { // this model has validations and/or enums so we will generate it - newBaseType = cp.complexType; + newBaseType = modelName; } } } else { @@ -455,9 +532,12 @@ public CodegenResponse fromResponse(String responseCode, ApiResponse response) { CodegenResponse result = super.fromResponse(responseCode, response); if (newBaseType != null) { - result.isModel = true; - result.baseType = newBaseType; - result.dataType = newBaseType; + result.dataType = toModelName(newBaseType); + // baseType is used to set the link to the model .md documentation + result.baseType = getPythonClassName(newBaseType); + } else if (!result.primitiveType) { + // fix the baseType for the api docs so the .md link to the class's documentation file is correct + result.baseType = getPythonClassName(result.baseType); } return result; @@ -553,6 +633,31 @@ public String toEnumValue(String value, String datatype) { } } + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty p) { + postProcessPattern(p.pattern, p.vendorExtensions); + // set property.complexType so the model docs will link to the ClassName.md + if (p.complexType != null && !languageSpecificPrimitives.contains(p.complexType)) { + p.complexType = getPythonClassName(p.complexType); + } else if (p.isListContainer && p.mostInnerItems.complexType != null && !languageSpecificPrimitives.contains(p.mostInnerItems.complexType)) { + // fix ListContainers + p.complexType = getPythonClassName(p.mostInnerItems.complexType); + } + } + + @Override + public void postProcessParameter(CodegenParameter p) { + postProcessPattern(p.pattern, p.vendorExtensions); + // set baseType to null so the api docs will not point to a model for languageSpecificPrimitives + if (p.baseType != null && languageSpecificPrimitives.contains(p.baseType)){ + p.baseType = null; + } else if (p.isListContainer && p.mostInnerItems.complexType != null && !languageSpecificPrimitives.contains(p.mostInnerItems.complexType)) { + // fix ListContainers + p.baseType = getPythonClassName(p.mostInnerItems.complexType); + } + } + + /** * Convert OAS Model object to Codegen Model object * @@ -588,10 +693,15 @@ public CodegenModel fromModel(String name, Schema schema) { continue; } String modelName = ModelUtils.getSimpleRef(ref); - propertyToModelName.put(pythonPropertyName, modelName); + propertyToModelName.put(pythonPropertyName, toModelName(modelName)); } } CodegenModel result = super.fromModel(name, schema); + // use this to store the model name like Cat + // we can't use result.name because that is used to lookup models in the spec + // we can't use result.classname because that stores cat.Cat + // we can't use result.classVarName because that stores the variable for making example instances + result.unescapedDescription = simpleModelName(name); // make non-object type models have one property so we can use it to store enums and validations if (result.isAlias || result.isEnum) { @@ -636,10 +746,11 @@ public CodegenModel fromModel(String name, Schema schema) { } cp.isPrimitiveType = false; String modelName = propertyToModelName.get(cp.name); - cp.complexType = modelName; + cp.complexType = getPythonClassName(modelName); cp.dataType = modelName; cp.isEnum = false; cp.hasValidation = false; + result.imports.add(modelName); } } return result; @@ -671,7 +782,7 @@ public String getTypeString(Schema p, String prefix, String suffix) { if (ModelUtils.isFreeFormObject(p) && ModelUtils.getAdditionalProperties(p) == null) { return prefix + "bool, date, datetime, dict, float, int, list, str" + fullSuffix; } - if (ModelUtils.isMapSchema(p)) { + if ((ModelUtils.isMapSchema(p) || p.getType() == "object") && ModelUtils.getAdditionalProperties(p) != null) { Schema inner = ModelUtils.getAdditionalProperties(p); return prefix + "{str: " + getTypeString(inner, "(", ")") + "}" + fullSuffix; } else if (ModelUtils.isArraySchema(p)) { @@ -679,10 +790,10 @@ public String getTypeString(Schema p, String prefix, String suffix) { Schema inner = ap.getItems(); return prefix + "[" + getTypeString(inner, "", "") + "]" + fullSuffix; } - String baseType = getSimpleTypeDeclaration(p); if (ModelUtils.isFileSchema(p)) { - baseType = "file_type"; + return prefix + "file_type" + fullSuffix; } + String baseType = getSimpleTypeDeclaration(p); return prefix + baseType + fullSuffix; } @@ -772,8 +883,8 @@ public void setParameterExampleValue(CodegenParameter p) { } example = "'" + escapeText(example) + "'"; } else if (!languageSpecificPrimitives.contains(type)) { - // type is a model class, e.g. User - example = this.packageName + "." + type + "()"; + // type is a model class, e.g. user.User + example = this.packageName + "." + getPythonClassName(type) + "()"; } else { LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); } @@ -788,4 +899,55 @@ public void setParameterExampleValue(CodegenParameter p) { p.example = example; } + + private String simpleModelName(String name) { + // this returns a model name like Cat + String modelName = sanitizeName(name); + // remove dollar sign + modelName = modelName.replaceAll("$", ""); + + // model name cannot use reserved keyword, e.g. return + if (isReservedWord(modelName)) { + LOGGER.warn(modelName + " (reserved word) cannot be used as model name. Renamed to " + camelize("model_" + modelName)); + modelName = "model_" + modelName; // e.g. return => ModelReturn (after camelize) + } + + // model name starts with number + if (modelName.matches("^\\d.*")) { + LOGGER.warn(modelName + " (model name starts with number) cannot be used as model name. Renamed to " + camelize("model_" + modelName)); + modelName = "model_" + modelName; // e.g. 200Response => Model200Response (after camelize) + } + + if (!StringUtils.isEmpty(modelNamePrefix)) { + modelName = modelNamePrefix + "_" + modelName; + } + + if (!StringUtils.isEmpty(modelNameSuffix)) { + modelName = modelName + "_" + modelNameSuffix; + } + + // camelize the model name + // phone_number => PhoneNumber + return camelize(modelName); + } + + + @Override + public String toModelFilename(String name) { + // underscore the model file name + // PhoneNumber => phone_number + return underscore(dropDots(simpleModelName(name))); + } + + @Override + public String toModelName(String name) { + // we have a custom version of this function so we can support circular references in python 2 and 3 + return toModelFilename(name)+"."+simpleModelName(name); + } + + @Override + public String toModelDocFilename(String name) { + // this is used to generate the model's .md documentation file + return simpleModelName(name); + } } diff --git a/modules/openapi-generator/src/main/resources/python/README.mustache b/modules/openapi-generator/src/main/resources/python/README.mustache index 144f72427e9b..94d72af33dcd 100644 --- a/modules/openapi-generator/src/main/resources/python/README.mustache +++ b/modules/openapi-generator/src/main/resources/python/README.mustache @@ -31,7 +31,7 @@ pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git Then import the package: ```python -import {{{packageName}}} +import {{{packageName}}} ``` ### Setuptools diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/README.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/README.mustache new file mode 100644 index 000000000000..f26408cf661a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/README.mustache @@ -0,0 +1,55 @@ +# {{{projectName}}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python 2.7 and 3.4+ + +## Installation & Usage +### pip install + +If the python package is hosted on a repository, you can install directly using: + +```sh +pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`) + +Then import the package: +```python +import {{{packageName}}} +``` + +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). + +```sh +python setup.py install --user +``` +(or `sudo python setup.py install` to install the package for all users) + +Then import the package: +```python +import {{{packageName}}} +``` + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +{{> python-experimental/README_common }} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/README_common.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/README_common.mustache new file mode 100644 index 000000000000..a8b66b0bed5f --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/README_common.mustache @@ -0,0 +1,74 @@ +```python +from __future__ import print_function +import time +import {{{packageName}}} +from pprint import pprint +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +{{> python_doc_auth_partial}} +# Defining host is optional and default to {{{basePath}}} +configuration.host = "{{{basePath}}}" +# Create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}({{{packageName}}}.ApiClient(configuration)) +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except {{{packageName}}}.ApiException as e: + print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{unescapedDescription}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} + All endpoints do not require authorization. +{{/authMethods}} +{{#authMethods}} +{{#last}} Authentication schemes defined for the API:{{/last}} +## {{{name}}} + +{{#isApiKey}} +- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}} +{{^isBasicBearer}} +- **Type**: HTTP basic authentication +{{/isBasicBearer}} +{{#isBasicBearer}} +- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}} +{{/isBasic}} +{{#isOAuth}} +- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorization URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/README_onlypackage.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/README_onlypackage.mustache new file mode 100644 index 000000000000..11c002c9aa53 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/README_onlypackage.mustache @@ -0,0 +1,44 @@ +# {{{projectName}}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Requirements. + +Python 2.7 and 3.4+ + +## Installation & Usage + +This python library package is generated without supporting files like setup.py or requirements files + +To be able to use it, you will need these dependencies in your own package that uses this library: + +* urllib3 >= 1.15 +* six >= 1.10 +* certifi +* python-dateutil +{{#asyncio}} +* aiohttp +{{/asyncio}} +{{#tornado}} +* tornado>=4.2,<5 +{{/tornado}} + +## Getting Started + +In your own code, to use this library to connect and interact with {{{projectName}}}, +you can run the following: + +{{> python-experimental/README_common }} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/__init__model.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/__init__model.mustache new file mode 100644 index 000000000000..ca86cb8a6249 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/__init__model.mustache @@ -0,0 +1,7 @@ +# coding: utf-8 + +# flake8: noqa +{{>partial_header}} + +# we can not import model classes here because that would create a circular +# reference which would not work in python2 diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/__init__package.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/__init__package.mustache new file mode 100644 index 000000000000..b5224a5821e7 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/__init__package.mustache @@ -0,0 +1,36 @@ +# coding: utf-8 + +# flake8: noqa + +{{>partial_header}} + +from __future__ import absolute_import + +__version__ = "{{packageVersion}}" + +# import apis into sdk package +{{#apiInfo}} +{{#apis}} +from {{apiPackage}}.{{classVarName}} import {{classname}} +{{/apis}} +{{/apiInfo}} + +# import ApiClient +from {{packageName}}.api_client import ApiClient + +# import Configuration +from {{packageName}}.configuration import Configuration + +# import exceptions +from {{packageName}}.exceptions import OpenApiException +from {{packageName}}.exceptions import ApiTypeError +from {{packageName}}.exceptions import ApiValueError +from {{packageName}}.exceptions import ApiKeyError +from {{packageName}}.exceptions import ApiException + +# import models into sdk package +{{#models}} +{{#model}} +from {{modelPackage}}.{{classFilename}} import {{unescapedDescription}} +{{/model}} +{{/models}} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/api.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/api.mustache index 651559cf4ff3..734c490caba0 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/api.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/api.mustache @@ -5,6 +5,7 @@ from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 # python 2 and python 3 compatibility library import six diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/api_doc.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/api_doc.mustache index 5cc638a2eb6a..4feb612f1c6d 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/api_doc.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/api_doc.mustache @@ -35,19 +35,16 @@ Method | HTTP request | Description {{#isOAuth}} * OAuth Authentication ({{name}}): {{/isOAuth }} -{{> api_doc_example }} {{/authMethods}} {{/hasAuthMethods}} -{{^hasAuthMethods}} -{{> api_doc_example }} -{{/hasAuthMethods}} +{{> python-experimental/api_doc_example }} ### Parameters {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} -{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | -{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | defaults to {{{.}}} -{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{^isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{baseType}}.md){{/isPrimitiveType}}{{/isFile}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +{{#requiredParams}}{{^defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | +{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | defaults to {{{.}}} +{{/defaultValue}}{{/requiredParams}}{{#optionalParams}} **{{paramName}}** | {{^baseType}}**{{dataType}}**{{/baseType}}{{#baseType}}[**{{dataType}}**]({{baseType}}.md){{/baseType}}| {{description}} | [optional]{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} {{/optionalParams}} ### Return type 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 e5eeee6b0ef2..8a6beabd2d73 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 @@ -2,7 +2,6 @@ from __future__ import print_function import time import {{{packageName}}} -from {{{packageName}}}.rest import ApiException from pprint import pprint {{> python_doc_auth_partial}} {{#hasAuthMethods}} @@ -18,40 +17,40 @@ api_instance = {{{packageName}}}.{{{classname}}}() {{#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}} -except ApiException as e: +except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) {{/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}} -except ApiException as e: +except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) {{/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}} -except ApiException as e: +except {{{packageName}}}.ApiException as e: print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) {{/optionalParams}} {{/requiredParams}} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache index 2513d6b3f867..0ca198ddf96c 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model.mustache @@ -2,37 +2,31 @@ {{>partial_header}} -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from {{packageName}}.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from {{packageName}}.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -{{#models}}{{#model}}{{#imports}}{{.}} -{{/imports}}{{/model}}{{/models}} - {{#models}} {{#model}} +{{#imports}} +{{{.}}} +{{/imports}} + + {{^interfaces}} {{#isAlias}} {{> python-experimental/model_templates/model_simple }} @@ -43,7 +37,7 @@ from {{packageName}}.model_utils import ( # noqa: F401 {{/interfaces}} {{#interfaces}} {{#-last}} -{{> python-experimental/model_templates/model_normal }} +{{> python-experimental/model_templates/model_composed }} {{/-last}} {{/interfaces}} {{/model}} diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_doc.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_doc.mustache index 79abbf613009..a1e57131bc49 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_doc.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_doc.mustache @@ -7,16 +7,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- {{#requiredVars}} {{^defaultValue}} -**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}} {{/defaultValue}} {{/requiredVars}} {{#requiredVars}} {{#defaultValue}} -**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}} {{/defaultValue}} {{/requiredVars}} {{#optionalVars}} -**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} +**{{name}}** | {{^complexType}}**{{dataType}}**{{/complexType}}{{#complexType}}[**{{dataType}}**]({{complexType}}.md){{/complexType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}} {{/optionalVars}} {{#additionalPropertiesType}} **any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional] diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvar_allowed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvar_allowed.mustache deleted file mode 100644 index 2414be114a35..000000000000 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvar_allowed.mustache +++ /dev/null @@ -1,16 +0,0 @@ - allowed_values = { -{{#allVars}} -{{#isEnum}} - ('{{name}}',): { -{{#isNullable}} - 'None': None, -{{/isNullable}} -{{#allowableValues}} -{{#enumVars}} - '{{name}}': {{{value}}}, -{{/enumVars}} -{{/allowableValues}} - }, -{{/isEnum}} -{{/allVars}} - } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvar_openapi_validations.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvar_openapi_validations.mustache deleted file mode 100644 index 1cc7b5855072..000000000000 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvar_openapi_validations.mustache +++ /dev/null @@ -1,42 +0,0 @@ - openapi_types = { -{{#allVars}} - '{{name}}': ({{{dataType}}},), # noqa: E501 -{{/allVars}} - } - - validations = { -{{#allVars}} -{{#hasValidation}} - ('{{name}}',): { -{{#maxLength}} - 'max_length': {{maxLength}}, -{{/maxLength}} -{{#minLength}} - 'min_length': {{minLength}}, -{{/minLength}} -{{#maxItems}} - 'max_items': {{maxItems}}, -{{/maxItems}} -{{#minItems}} - 'min_items': {{minItems}}, -{{/minItems}} -{{#maximum}} - {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, -{{/maximum}} -{{#minimum}} - {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, -{{/minimum}} -{{#pattern}} - 'regex': { - 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} - {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} - }, -{{/pattern}} - }, -{{/hasValidation}} -{{/allVars}} - } - - additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} - - discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvars.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvars.mustache new file mode 100644 index 000000000000..fcd8a71fd124 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvars.mustache @@ -0,0 +1,119 @@ + allowed_values = { +{{#requiredVars}} +{{#isEnum}} + ('{{name}}',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}, +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{/requiredVars}} +{{#optionalVars}} +{{#isEnum}} + ('{{name}}',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}, +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{/optionalVars}} + } + + openapi_types = { +{{#requiredVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': ({{{dataType}}},), # noqa: E501 +{{/optionalVars}} + } + + validations = { +{{#requiredVars}} +{{#hasValidation}} + ('{{name}}',): { +{{#maxLength}} + 'max_length': {{maxLength}}, +{{/maxLength}} +{{#minLength}} + 'min_length': {{minLength}}, +{{/minLength}} +{{#maxItems}} + 'max_items': {{maxItems}}, +{{/maxItems}} +{{#minItems}} + 'min_items': {{minItems}}, +{{/minItems}} +{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, +{{/maximum}} +{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, +{{/minimum}} +{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + }, +{{/pattern}} + }, +{{/hasValidation}} +{{/requiredVars}} +{{#optionalVars}} +{{#hasValidation}} + ('{{name}}',): { +{{#maxLength}} + 'max_length': {{maxLength}}, +{{/maxLength}} +{{#minLength}} + 'min_length': {{minLength}}, +{{/minLength}} +{{#maxItems}} + 'max_items': {{maxItems}}, +{{/maxItems}} +{{#minItems}} + 'min_items': {{minItems}}, +{{/minItems}} +{{#maximum}} + {{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}}, +{{/maximum}} +{{#minimum}} + {{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}}, +{{/minimum}} +{{#pattern}} + 'regex': { + 'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501{{#vendorExtensions.x-modifiers}} + {{#-first}}'flags': (re.{{.}}{{/-first}}{{^-first}} re.{{.}}{{/-first}}{{^-last}} | {{/-last}}{{#-last}}){{/-last}}{{/vendorExtensions.x-modifiers}} + }, +{{/pattern}} + }, +{{/hasValidation}} +{{/optionalVars}} + } + + additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}} + + @staticmethod + def discriminator(): + return {{^discriminator}}None{{/discriminator}}{{#discriminator}}{ + '{{{discriminatorName}}}': { +{{#children}} + '{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': {{{classname}}}, +{{/children}} +{{^children}} +{{#mappedModels}} + '{{mappingName}}': {{{modelName}}}, +{{/mappedModels}} +{{/children}} + }, + }{{/discriminator}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_discriminator.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_discriminator.mustache new file mode 100644 index 000000000000..c4baa722ffb5 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_discriminator.mustache @@ -0,0 +1,12 @@ + @classmethod + def get_discriminator_class(cls, from_server, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator() + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if from_server: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache new file mode 100644 index 000000000000..5ed5993fe9f3 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_composed.mustache @@ -0,0 +1,42 @@ + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + +{{> python-experimental/model_templates/method_init_shared }} + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { +{{#requiredVars}} + '{{name}}': {{name}}, +{{/requiredVars}} + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + +{{#requiredVars}} + self.{{name}} = {{name}} +{{/requiredVars}} + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_normal.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_normal.mustache new file mode 100644 index 000000000000..b053427a7996 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_normal.mustache @@ -0,0 +1,21 @@ + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + +{{> python-experimental/model_templates/method_init_shared }} + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + +{{#requiredVars}} + self.{{name}} = {{name}} +{{/requiredVars}} + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache new file mode 100644 index 000000000000..2f3b70ea6902 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_init_shared.mustache @@ -0,0 +1,23 @@ + def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """{{classname}} - a model defined in OpenAPI + +{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} +{{/hasMore}}{{/requiredVars}} + Keyword Args:{{#requiredVars}}{{#defaultValue}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done.{{#optionalVars}} + {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} + """ \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_set_attribute.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_set_attribute.mustache new file mode 100644 index 000000000000..f4a36e42f25b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/method_set_attribute.mustache @@ -0,0 +1,49 @@ + def set_attribute(self, name, value): + # this is only used to set properties on self + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] + elif self.additional_properties_type is None: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif self.additional_properties_type is not None: + required_types_mixed = self.additional_properties_type + + if get_simple_class(name) != str: + error_msg = type_error_message( + var_name=name, + var_value=name, + valid_classes=(str,), + key_type=True + ) + raise ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=(str,), + key_type=True + ) + + if self._check_type: + value = validate_and_convert_types( + value, required_types_mixed, path_to_item, self._from_server, + self._check_type, configuration=self._configuration) + if (name,) in self.allowed_values: + check_allowed_values( + self.allowed_values, + (name,), + value + ) + if (name,) in self.validations: + check_validations( + self.validations, + (name,), + value + ) + self.__dict__['_data_store'][name] = value \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_init_properties.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_init_properties.mustache deleted file mode 100644 index dab632efab04..000000000000 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_init_properties.mustache +++ /dev/null @@ -1,126 +0,0 @@ - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """{{classname}} - a model defined in OpenAPI - -{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}} -{{/hasMore}}{{/requiredVars}} - Keyword Args:{{#requiredVars}}{{#defaultValue}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}} - _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. - Defaults to True - _path_to_item (tuple/list): This is a list of keys or values to - drill down to the model in received_data - when deserializing a response - _from_server (bool): True if the data is from the server - False if the data is from the client (default) - _configuration (Configuration): the instance to use when - deserializing a file_type parameter. - If passed, type conversion is attempted - If omitted no type conversion is done.{{#optionalVars}} - {{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} - """ - self._data_store = {} - self._check_type = _check_type - self._from_server = _from_server - self._path_to_item = _path_to_item - self._configuration = _configuration - -{{#requiredVars}} - self.__set_item('{{name}}', {{name}}) -{{/requiredVars}} - for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) -{{#allVars}} - - @property - def {{name}}(self): - """Gets the {{name}} of this {{classname}}. # noqa: E501 -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - - Returns: - ({{{dataType}}}): The {{name}} of this {{classname}}. # noqa: E501 - """ - return self.__get_item('{{name}}') - - @{{name}}.setter - def {{name}}(self, value): - """Sets the {{name}} of this {{classname}}. # noqa: E501 -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - """ - return self.__set_item('{{name}}', value) -{{/allVars}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_composed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_composed.mustache new file mode 100644 index 000000000000..e5eee88a9608 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_composed.mustache @@ -0,0 +1,61 @@ + def __setattr__(self, name, value): + """this allows us to set a value with instance.field_name = val""" + if name in self.required_properties: + self.__dict__[name] = value + return + + # set the attribute on the correct instance + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + if model_instances: + for model_instance in model_instances: + if model_instance == self: + self.set_attribute(name, value) + else: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = ( + model_instance + ) + return None + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + + def __getattr__(self, name): + """this allows us to get a value with val = instance.field_name""" + if name in self.required_properties: + return self.__dict__[name] + + # get the attribute from the correct instance + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + if model_instances: + values = set() + for model_instance in model_instances: + if name in model_instance._data_store: + values.add(model_instance._data_store[name]) + if len(values) == 1: + return list(values)[0] + raise ApiValueError( + "Values stored for property {0} in {1} difffer when looking " + "at self and self's composed instances. All values must be " + "the same".format(name, type(self).__name__), + path_to_item + ) + + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_normal.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_normal.mustache new file mode 100644 index 000000000000..f92663ab2083 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_setattr_getattr_normal.mustache @@ -0,0 +1,24 @@ + def __setattr__(self, name, value): + """this allows us to set a value with instance.field_name = val""" + if name in self.required_properties: + self.__dict__[name] = value + return + + self.set_attribute(name, value) + + def __getattr__(self, name): + """this allows us to get a value with val = instance.field_name""" + if name in self.required_properties: + return self.__dict__[name] + + if name in self.__dict__['_data_store']: + return self.__dict__['_data_store'][name] + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + [name] + ) \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_shared.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_shared.mustache new file mode 100644 index 000000000000..d3cf66e41b64 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_shared.mustache @@ -0,0 +1,15 @@ + def __setitem__(self, name, value): + """this allows us to set values with instance[field_name] = val""" + self.__setattr__(name, value) + + def __getitem__(self, name): + """this allows us to get a value with val = instance[field_name]""" + return self.__getattr__(name) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache new file mode 100644 index 000000000000..d01d49ad77c0 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_todict_tostr_eq_shared.mustache @@ -0,0 +1,29 @@ + def to_dict(self): + """Returns the model properties as a dict""" + return model_to_dict(self, serialize=False) + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + if not set(self._data_store.keys()) == set(other._data_store.keys()): + return False + for _var_name, this_val in six.iteritems(self._data_store): + that_val = other._data_store[_var_name] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if (not six.PY3 and + len(types) == 2 and unicode in types): # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_tostr_eq_simple.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_tostr_eq_simple.mustache new file mode 100644 index 000000000000..0bba565d22ce --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_tostr_eq_simple.mustache @@ -0,0 +1,22 @@ + def to_str(self): + """Returns the string representation of the model""" + return str(self.value) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + this_val = self._data_store['value'] + that_val = other._data_store['value'] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_composed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_composed.mustache new file mode 100644 index 000000000000..d53d89cef2be --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_composed.mustache @@ -0,0 +1,56 @@ +class {{unescapedDescription}}(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: +{{> python-experimental/model_templates/docstring_allowed }} + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. +{{> python-experimental/model_templates/docstring_openapi_validations }} + """ + +{{> python-experimental/model_templates/classvars }} + + attribute_map = { +{{#requiredVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/optionalVars}} + } + +{{> python-experimental/model_templates/method_init_composed }} + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ +{{#anyOf}} + {{{.}}}, +{{/anyOf}} + ], + 'allOf': [ +{{#allOf}} + {{{.}}}, +{{/allOf}} + ], + 'oneOf': [ +{{#oneOf}} + {{{.}}}, +{{/oneOf}} + ], + }{{#discriminator}} + +{{> python-experimental/model_templates/method_discriminator }}{{/discriminator}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache index c4e707e036e0..8bfe6ada48d8 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache @@ -1,4 +1,4 @@ -class {{classname}}(ModelNormal): +class {{unescapedDescription}}(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -13,69 +13,21 @@ class {{classname}}(ModelNormal): {{> python-experimental/model_templates/docstring_openapi_validations }} """ -{{> python-experimental/model_templates/classvar_allowed }} +{{> python-experimental/model_templates/classvars }} attribute_map = { -{{#allVars}} - '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} # noqa: E501 -{{/allVars}} +{{#requiredVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/requiredVars}} +{{#optionalVars}} + '{{name}}': '{{baseName}}', # noqa: E501 +{{/optionalVars}} } -{{#discriminator}} - discriminator_value_class_map = { - {{#children}}'{{^vendorExtensions.x-discriminator-value}}{{name}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}': {{{classname}}}{{^-last}}, - {{/-last}}{{/children}} - } -{{/discriminator}} - -{{> python-experimental/model_templates/classvar_openapi_validations }} - -{{> python-experimental/model_templates/methods_init_properties }} -{{#discriminator}} - @classmethod - def get_real_child_model(cls, data): - """Returns the real base class specified by the discriminator - We assume that data has javascript keys - """ - discriminator_key = cls.attribute_map[cls.discriminator] - discriminator_value = data[discriminator_key] - return cls.discriminator_value_class_map.get(discriminator_value) - -{{/discriminator}} - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, {{classname}}): - return False + @staticmethod + def _composed_schemas(): + return None - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True +{{> python-experimental/model_templates/method_init_normal}}{{#discriminator}} - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other \ No newline at end of file +{{> python-experimental/model_templates/method_discriminator }}{{/discriminator}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache index b5939d926c2f..465918dfa5c0 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache @@ -1,4 +1,4 @@ -class {{classname}}(ModelSimple): +class {{unescapedDescription}}(ModelSimple): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -9,38 +9,10 @@ class {{classname}}(ModelSimple): {{> python-experimental/model_templates/docstring_openapi_validations }} """ -{{> python-experimental/model_templates/classvar_allowed }} +{{> python-experimental/model_templates/classvars }} -{{> python-experimental/model_templates/classvar_openapi_validations }} + @staticmethod + def _composed_schemas(): + return None -{{> python-experimental/model_templates/methods_init_properties }} - def to_str(self): - """Returns the string representation of the model""" - return str(self.value) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, {{classname}}): - return False - - this_val = self._data_store['value'] - that_val = other._data_store['value'] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other \ No newline at end of file +{{> python-experimental/model_templates/method_init_normal}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_test.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_test.mustache new file mode 100644 index 000000000000..4fd1263b5f28 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_test.mustache @@ -0,0 +1,33 @@ +# coding: utf-8 + +{{>partial_header}} + +from __future__ import absolute_import + +import unittest + +{{#models}} +{{#model}} +import {{packageName}} + + +class Test{{unescapedDescription}}(unittest.TestCase): + """{{unescapedDescription}} unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def test{{unescapedDescription}}(self): + """Test {{unescapedDescription}}""" + # FIXME: construct object with mandatory attributes with example values + # model = {{packageName}}.{{unescapedDescription}}() # noqa: E501 + pass + +{{/model}} +{{/models}} + +if __name__ == '__main__': + unittest.main() diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache index 101b5466c31b..dbd592c37e8f 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache @@ -2,10 +2,10 @@ {{>partial_header}} -import copy from datetime import date, datetime # noqa: F401 import inspect import os +import pprint import re import tempfile @@ -38,30 +38,52 @@ else: class OpenApiModel(object): """The base class for all OpenAPIModels""" +{{> python-experimental/model_templates/method_set_attribute }} + +{{> python-experimental/model_templates/methods_shared }} + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their swagger/openapi""" +{{> python-experimental/model_templates/methods_setattr_getattr_normal }} + +{{> python-experimental/model_templates/methods_tostr_eq_simple }} + class ModelNormal(OpenApiModel): """the parent class of models whose type == object in their swagger/openapi""" +{{> python-experimental/model_templates/methods_setattr_getattr_normal }} + +{{> python-experimental/model_templates/methods_todict_tostr_eq_shared}} + + +class ModelComposed(OpenApiModel): + """the parent class of models whose type == object in their + swagger/openapi and have oneOf/allOf/anyOf""" + +{{> python-experimental/model_templates/methods_setattr_getattr_composed }} + +{{> python-experimental/model_templates/methods_todict_tostr_eq_shared}} + COERCION_INDEX_BY_TYPE = { - ModelNormal: 0, - ModelSimple: 1, - none_type: 2, - list: 3, - dict: 4, - float: 5, - int: 6, - bool: 7, - datetime: 8, - date: 9, - str: 10, - file_type: 11, + ModelComposed: 0, + ModelNormal: 1, + ModelSimple: 2, + none_type: 3, + list: 4, + dict: 5, + float: 6, + int: 7, + bool: 8, + datetime: 9, + date: 10, + str: 11, + file_type: 12, } # these are used to limit what type conversions we try to do @@ -70,6 +92,8 @@ COERCION_INDEX_BY_TYPE = { UPCONVERSION_TYPE_PAIRS = ( (str, datetime), (str, date), + (list, ModelComposed), + (dict, ModelComposed), (list, ModelNormal), (dict, ModelNormal), (str, ModelSimple), @@ -80,6 +104,8 @@ UPCONVERSION_TYPE_PAIRS = ( COERCIBLE_TYPE_PAIRS = { False: ( # client instantiation of a model with client data + # (dict, ModelComposed), + # (list, ModelComposed), # (dict, ModelNormal), # (list, ModelNormal), # (str, ModelSimple), @@ -94,6 +120,8 @@ COERCIBLE_TYPE_PAIRS = { # (float, str), ), True: ( # server -> client data + (dict, ModelComposed), + (list, ModelComposed), (dict, ModelNormal), (list, ModelNormal), (str, ModelSimple), @@ -336,6 +364,9 @@ def order_response_types(required_types): return COERCION_INDEX_BY_TYPE[list] elif isinstance(class_or_instance, dict): return COERCION_INDEX_BY_TYPE[dict] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelComposed)): + return COERCION_INDEX_BY_TYPE[ModelComposed] elif (inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelNormal)): return COERCION_INDEX_BY_TYPE[ModelNormal] @@ -377,7 +408,9 @@ def remove_uncoercible(required_types_classes, current_item, from_server, # convert our models to OpenApiModel required_type_class_simplified = required_type_class if isinstance(required_type_class_simplified, type): - if issubclass(required_type_class_simplified, ModelNormal): + if issubclass(required_type_class_simplified, ModelComposed): + required_type_class_simplified = ModelComposed + elif issubclass(required_type_class_simplified, ModelNormal): required_type_class_simplified = ModelNormal elif issubclass(required_type_class_simplified, ModelSimple): required_type_class_simplified = ModelSimple @@ -514,6 +547,21 @@ def deserialize_primitive(data, klass, path_to_item): ) +def fix_model_input_data(model_data, model_class): + # this is only called on classes where the input data is a dict + fixed_model_data = change_keys_js_to_python( + model_data, + model_class + ) + if model_class._composed_schemas() is not None: + for allof_class in model_class._composed_schemas()['allOf']: + fixed_model_data = change_keys_js_to_python( + fixed_model_data, + allof_class + ) + return fixed_model_data + + def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, from_server): """Deserializes model_data to model instance. @@ -536,42 +584,29 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, ApiValueError ApiKeyError """ - fixed_model_data = copy.deepcopy(model_data) - - if isinstance(fixed_model_data, dict): - fixed_model_data = change_keys_js_to_python(fixed_model_data, - model_class) kw_args = dict(_check_type=check_type, _path_to_item=path_to_item, _configuration=configuration, _from_server=from_server) - if hasattr(model_class, 'get_real_child_model'): - # discriminator case - discriminator_class = model_class.get_real_child_model(model_data) - if discriminator_class: - if isinstance(model_data, list): - instance = discriminator_class(*model_data, **kw_args) - elif isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python( - fixed_model_data, - discriminator_class - ) - kw_args.update(fixed_model_data) - instance = discriminator_class(**kw_args) - else: - # all other cases - if isinstance(model_data, list): - instance = model_class(*model_data, **kw_args) - if isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python(fixed_model_data, - model_class) - kw_args.update(fixed_model_data) - instance = model_class(**kw_args) - else: - instance = model_class(model_data, **kw_args) - + used_model_class = model_class + if model_class.discriminator() is not None: + used_model_class = model_class.get_discriminator_class( + from_server, model_data) + + if issubclass(used_model_class, ModelSimple): + instance = used_model_class(value=model_data, **kw_args) + return instance + if isinstance(model_data, list): + instance = used_model_class(*model_data, **kw_args) + if isinstance(model_data, dict): + fixed_model_data = change_keys_js_to_python( + model_data, + used_model_class + ) + kw_args.update(fixed_model_data) + instance = used_model_class(**kw_args) return instance @@ -626,7 +661,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, key_type (bool): if True we need to convert a key type (not supported) must_convert (bool): if True we must convert check_type (bool): if True we check the type or the returned data in - ModelNormal and ModelSimple instances + ModelComposed/ModelNormal/ModelSimple instances Returns: instance (any) the fixed item @@ -790,27 +825,31 @@ def model_to_dict(model_instance, serialize=True): """ result = {} - for attr, value in six.iteritems(model_instance._data_store): - if serialize: - # we use get here because additional property key names do not - # exist in attribute_map - attr = model_instance.attribute_map.get(attr, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: model_to_dict(x, serialize=serialize) - if hasattr(x, '_data_store') else x, value - )) - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], - model_to_dict(item[1], serialize=serialize)) - if hasattr(item[1], '_data_store') else item, - value.items() - )) - elif hasattr(value, '_data_store'): - result[attr] = model_to_dict(value, serialize=serialize) - else: - result[attr] = value + model_instances = [model_instance] + if model_instance._composed_schemas() is not None: + model_instances = model_instance._composed_instances + for model_instance in model_instances: + for attr, value in six.iteritems(model_instance._data_store): + if serialize: + # we use get here because additional property key names do not + # exist in attribute_map + attr = model_instance.attribute_map.get(attr, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: model_to_dict(x, serialize=serialize) + if hasattr(x, '_data_store') else x, value + )) + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], + model_to_dict(item[1], serialize=serialize)) + if hasattr(item[1], '_data_store') else item, + value.items() + )) + elif hasattr(value, '_data_store'): + result[attr] = model_to_dict(value, serialize=serialize) + else: + result[attr] = value return result @@ -866,3 +905,235 @@ def get_py3_class_name(input_class): elif input_class == int: return 'int' return input_class.__name__ + + +def get_allof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + composed_instances (list) + """ + composed_instances = [] + for allof_class in self._composed_schemas()['allOf']: + + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python( + model_args, allof_class) + + # extract a dict of only required keys from fixed_model_args + kwargs = {} + var_names = set(allof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + allof_instance = allof_class(**kwargs) + composed_instances.append(allof_instance) + return composed_instances + + +def get_oneof_instance(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + oneof_instance (instance) + """ + oneof_instance = None + if len(self._composed_schemas()['oneOf']) == 0: + return oneof_instance + + for oneof_class in self._composed_schemas()['oneOf']: + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python( + model_args, oneof_class) + + # extract a dict of only required keys from fixed_model_args + kwargs = {} + var_names = set(oneof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + try: + oneof_instance = oneof_class(**kwargs) + break + except Exception: + pass + if oneof_instance is None: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Unable to " + "make any instances of the classes in oneOf definition." % + self.__class__.__name__ + ) + return oneof_instance + + +def get_anyof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + anyof_instances (list) + """ + anyof_instances = [] + if len(self._composed_schemas()['anyOf']) == 0: + return anyof_instances + + for anyof_class in self._composed_schemas()['anyOf']: + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python(model_args, anyof_class) + + # extract a dict of only required keys from these_model_vars + kwargs = {} + var_names = set(anyof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + try: + anyof_instance = anyof_class(**kwargs) + anyof_instances.append(anyof_instance) + except Exception: + pass + if len(anyof_instances) == 0: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Unable to " + "make any instances of the classes in anyOf definition." % + self.__class__.__name__ + ) + return anyof_instances + + +def get_additional_properties_model_instances( + composed_instances, self): + additional_properties_model_instances = [] + all_instances = [self] + all_instances.extend(composed_instances) + for instance in all_instances: + if instance.additional_properties_type is not None: + additional_properties_model_instances.append(instance) + return additional_properties_model_instances + + +def get_var_name_to_model_instances(self, composed_instances): + var_name_to_model_instances = {} + all_instances = [self] + all_instances.extend(composed_instances) + for instance in all_instances: + for var_name in instance.openapi_types: + if var_name not in var_name_to_model_instances: + var_name_to_model_instances[var_name] = [instance] + else: + var_name_to_model_instances[var_name].append(instance) + return var_name_to_model_instances + + +def get_unused_args(self, composed_instances, model_args): + unused_args = dict(model_args) + # arguments apssed to self were already converted to python names + # before __init__ was called + for var_name_py in self.attribute_map: + if var_name_py in unused_args: + del unused_args[var_name_py] + for instance in composed_instances: + if instance.__class__ in self._composed_schemas()['allOf']: + for var_name_py in instance.attribute_map: + if var_name_py in unused_args: + del unused_args[var_name_py] + else: + for var_name_js in instance.attribute_map.values(): + if var_name_js in unused_args: + del unused_args[var_name_js] + return unused_args + + +def validate_get_composed_info(constant_args, model_args, self): + """ + For composed schemas/classes, validates the classes to make sure that + they do not share any of the same parameters. If there is no collision + then composed model instances are created and returned tot the calling + self model + + Args: + constant_args (dict): these are the args that every model requires + model_args (dict): these are the required and optional spec args that + were passed in to make this model + self (class): the class that we are instantiating + This class contains self._composed_schemas() + + Returns: + composed_info (list): length three + composed_instances (list): the composed instances which are not + self + var_name_to_model_instances (dict): a dict going from var_name + to the model_instance which holds that var_name + the model_instance may be self or an instance of one of the + classes in self.composed_instances() + additional_properties_model_instances (list): a list of the + model instances which have the property + additional_properties_type. This list can include self + """ + # create composed_instances + composed_instances = [] + allof_instances = get_allof_instances(self, model_args, constant_args) + composed_instances.extend(allof_instances) + oneof_instance = get_oneof_instance(self, model_args, constant_args) + if oneof_instance is not None: + composed_instances.append(oneof_instance) + anyof_instances = get_anyof_instances(self, model_args, constant_args) + composed_instances.extend(anyof_instances) + + # map variable names to composed_instances + var_name_to_model_instances = get_var_name_to_model_instances( + self, composed_instances) + + # set additional_properties_model_instances + additional_properties_model_instances = ( + get_additional_properties_model_instances(composed_instances, self) + ) + + # set any remaining values + unused_args = get_unused_args(self, composed_instances, model_args) + if len(unused_args) > 0: + if len(additional_properties_model_instances) == 0: + raise ApiValueError( + "Invalid input arguments input when making an instance of " + "class %s. Not all inputs were used. The unused input data " + "is %s" % (self.__class__.__name__, unused_args) + ) + for var_name, var_value in six.iteritems(unused_args): + for instance in additional_properties_model_instances: + setattr(instance, var_name, var_value) + # no need to add additional_properties to var_name_to_model_instances here + # because additional_properties_model_instances will direct us to that + # instance when we use getattr or setattr + # and we update var_name_to_model_instances in setattr + + return [ + composed_instances, + var_name_to_model_instances, + additional_properties_model_instances + ] 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 d85652ee4b2f..19d169ae7c8d 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 @@ -38,19 +38,19 @@ public void modelTest() { codegen.setOpenAPI(openAPI); final CodegenModel simpleName = codegen.fromModel("v1beta3.Binding", openAPI.getComponents().getSchemas().get("v1beta3.Binding")); Assert.assertEquals(simpleName.name, "v1beta3.Binding"); - Assert.assertEquals(simpleName.classname, "V1beta3Binding"); + Assert.assertEquals(simpleName.classname, "v1beta3_binding.V1beta3Binding"); Assert.assertEquals(simpleName.classVarName, "v1beta3_binding"); codegen.setOpenAPI(openAPI); final CodegenModel compoundName = codegen.fromModel("v1beta3.ComponentStatus", openAPI.getComponents().getSchemas().get("v1beta3.ComponentStatus")); Assert.assertEquals(compoundName.name, "v1beta3.ComponentStatus"); - Assert.assertEquals(compoundName.classname, "V1beta3ComponentStatus"); + Assert.assertEquals(compoundName.classname, "v1beta3_component_status.V1beta3ComponentStatus"); Assert.assertEquals(compoundName.classVarName, "v1beta3_component_status"); 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); - Assert.assertEquals(codegenOperation.returnType, "V1beta3Binding"); + Assert.assertEquals(codegenOperation.returnType, "v1beta3_binding.V1beta3Binding"); Assert.assertEquals(codegenOperation.returnBaseType, "V1beta3Binding"); } @@ -69,7 +69,7 @@ public void simpleModelTest() { final CodegenModel cm = codegen.fromModel("sample", schema); Assert.assertEquals(cm.name, "sample"); - Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.classname, "sample.Sample"); Assert.assertEquals(cm.description, "a sample model"); Assert.assertEquals(cm.vars.size(), 3); @@ -117,7 +117,7 @@ public void listPropertyTest() { final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); - Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.classname, "sample.Sample"); Assert.assertEquals(cm.description, "a sample model"); Assert.assertEquals(cm.vars.size(), 2); @@ -157,7 +157,7 @@ public void mapPropertyTest() { final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); - Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.classname, "sample.Sample"); Assert.assertEquals(cm.description, "a sample model"); Assert.assertEquals(cm.vars.size(), 1); @@ -183,15 +183,15 @@ public void complexPropertyTest() { final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); - Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.classname, "sample.Sample"); Assert.assertEquals(cm.description, "a sample model"); Assert.assertEquals(cm.vars.size(), 1); final CodegenProperty property1 = cm.vars.get(0); Assert.assertEquals(property1.baseName, "children"); - Assert.assertEquals(property1.dataType, "Children"); + Assert.assertEquals(property1.dataType, "children.Children"); Assert.assertEquals(property1.name, "children"); - Assert.assertEquals(property1.baseType, "Children"); + Assert.assertEquals(property1.baseType, "children.Children"); Assert.assertFalse(property1.required); Assert.assertFalse(property1.isContainer); } @@ -208,14 +208,14 @@ public void complexListPropertyTest() { final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); - Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.classname, "sample.Sample"); Assert.assertEquals(cm.description, "a sample model"); Assert.assertEquals(cm.vars.size(), 1); final CodegenProperty property1 = cm.vars.get(0); Assert.assertEquals(property1.baseName, "children"); Assert.assertEquals(property1.complexType, "Children"); - Assert.assertEquals(property1.dataType, "[Children]"); + Assert.assertEquals(property1.dataType, "[children.Children]"); Assert.assertEquals(property1.name, "children"); Assert.assertEquals(property1.baseType, "list"); Assert.assertEquals(property1.containerType, "array"); @@ -235,15 +235,15 @@ public void complexMapPropertyTest() { final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); - Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.classname, "sample.Sample"); Assert.assertEquals(cm.description, "a sample model"); Assert.assertEquals(cm.vars.size(), 1); - Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("children.Children")).size(), 1); final CodegenProperty property1 = cm.vars.get(0); Assert.assertEquals(property1.baseName, "children"); Assert.assertEquals(property1.complexType, "Children"); - Assert.assertEquals(property1.dataType, "{str: (Children,)}"); + Assert.assertEquals(property1.dataType, "{str: (children.Children,)}"); Assert.assertEquals(property1.name, "children"); Assert.assertEquals(property1.baseType, "dict"); Assert.assertEquals(property1.containerType, "map"); @@ -265,12 +265,13 @@ public void arrayModelTest() { final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); - Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.classname, "sample.Sample"); + Assert.assertEquals(cm.classVarName, "sample"); Assert.assertEquals(cm.description, "an array model"); Assert.assertEquals(cm.vars.size(), 0); Assert.assertEquals(cm.parent, "list"); Assert.assertEquals(cm.imports.size(), 1); - Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("children.Children")).size(), 1); } // should not start with 'null'. need help from the community to investigate further @@ -285,12 +286,12 @@ public void mapModelTest() { final CodegenModel cm = codegen.fromModel("sample", model); Assert.assertEquals(cm.name, "sample"); - Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.classname, "sample.Sample"); Assert.assertEquals(cm.description, "a map model"); Assert.assertEquals(cm.vars.size(), 0); Assert.assertEquals(cm.parent, "dict"); Assert.assertEquals(cm.imports.size(), 1); - Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("children.Children")).size(), 1); } } diff --git a/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml index a443f059b7ef..fa1bdfe009c6 100644 --- a/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml @@ -1238,6 +1238,10 @@ definitions: format: int64 name: type: string + # we added fullName to make sure that serialization/deserialization + # works for a submodel of Pet that also uses js variable names + fullName: + type: string xml: name: Tag Pet: @@ -2038,4 +2042,57 @@ definitions: type: integer xml: namespace: http://g.com/schema - prefix: g \ No newline at end of file + prefix: g + Grandparent: + type: object + properties: + radioWaves: + type: boolean + Parent: + allOf: + - $ref: '#/definitions/Grandparent' + - type: object + properties: + teleVision: + type: boolean + Child: + allOf: + - $ref: '#/definitions/Parent' + - type: object + properties: + interNet: + type: boolean + GrandparentAnimal: + type: object + required: + - pet_type + properties: + pet_type: + type: string + ParentPet: + type: object + allOf: + - $ref: '#/definitions/GrandparentAnimal' + - type: object + discriminator: pet_type + ChildCat: + allOf: + - $ref: '#/definitions/ParentPet' + - type: object + properties: + name: + type: string + ChildDog: + allOf: + - $ref: '#/definitions/ParentPet' + - type: object + properties: + bark: + type: string + ChildLizard: + allOf: + - $ref: '#/definitions/ParentPet' + - type: object + properties: + lovesRocks: + type: boolean \ No newline at end of file diff --git a/samples/client/petstore/python-asyncio/README.md b/samples/client/petstore/python-asyncio/README.md index 8534592c1506..b92f4eecf8d4 100644 --- a/samples/client/petstore/python-asyncio/README.md +++ b/samples/client/petstore/python-asyncio/README.md @@ -23,7 +23,7 @@ pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git Then import the package: ```python -import petstore_api +import petstore_api ``` ### Setuptools diff --git a/samples/client/petstore/python-experimental/README.md b/samples/client/petstore/python-experimental/README.md index 2a5a1f6c149d..ffffbf80eb0e 100644 --- a/samples/client/petstore/python-experimental/README.md +++ b/samples/client/petstore/python-experimental/README.md @@ -23,7 +23,7 @@ pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git Then import the package: ```python -import petstore_api +import petstore_api ``` ### Setuptools @@ -48,7 +48,6 @@ Please follow the [installation procedure](#installation--usage) and then run th from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint @@ -56,13 +55,13 @@ from pprint import pprint configuration.host = "http://petstore.swagger.io:80/v2" # Create an instance of the API class api_instance = petstore_api.AnotherFakeApi(petstore_api.ApiClient(configuration)) -body = petstore_api.Client() # Client | client model +body = petstore_api.Client() # client.Client | client model try: # To test special tags api_response = api_instance.call_123_test_special_tags(body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) ``` @@ -115,54 +114,67 @@ Class | Method | HTTP request | Description ## Documentation For Models - - [AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md) - - [AdditionalPropertiesArray](docs/AdditionalPropertiesArray.md) - - [AdditionalPropertiesBoolean](docs/AdditionalPropertiesBoolean.md) - - [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) - - [AdditionalPropertiesInteger](docs/AdditionalPropertiesInteger.md) - - [AdditionalPropertiesNumber](docs/AdditionalPropertiesNumber.md) - - [AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md) - - [AdditionalPropertiesString](docs/AdditionalPropertiesString.md) - - [Animal](docs/Animal.md) - - [ApiResponse](docs/ApiResponse.md) - - [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - - [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - - [ArrayTest](docs/ArrayTest.md) - - [Capitalization](docs/Capitalization.md) - - [Cat](docs/Cat.md) - - [CatAllOf](docs/CatAllOf.md) - - [Category](docs/Category.md) - - [ClassModel](docs/ClassModel.md) - - [Client](docs/Client.md) - - [Dog](docs/Dog.md) - - [DogAllOf](docs/DogAllOf.md) - - [EnumArrays](docs/EnumArrays.md) - - [EnumClass](docs/EnumClass.md) - - [EnumTest](docs/EnumTest.md) - - [File](docs/File.md) - - [FileSchemaTestClass](docs/FileSchemaTestClass.md) - - [FormatTest](docs/FormatTest.md) - - [HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - - [List](docs/List.md) - - [MapTest](docs/MapTest.md) - - [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) - - [Model200Response](docs/Model200Response.md) - - [ModelReturn](docs/ModelReturn.md) - - [Name](docs/Name.md) - - [NumberOnly](docs/NumberOnly.md) - - [Order](docs/Order.md) - - [OuterComposite](docs/OuterComposite.md) - - [OuterEnum](docs/OuterEnum.md) - - [OuterNumber](docs/OuterNumber.md) - - [Pet](docs/Pet.md) - - [ReadOnlyFirst](docs/ReadOnlyFirst.md) - - [SpecialModelName](docs/SpecialModelName.md) - - [StringBooleanMap](docs/StringBooleanMap.md) - - [Tag](docs/Tag.md) - - [TypeHolderDefault](docs/TypeHolderDefault.md) - - [TypeHolderExample](docs/TypeHolderExample.md) - - [User](docs/User.md) - - [XmlItem](docs/XmlItem.md) + - [additional_properties_any_type.AdditionalPropertiesAnyType](docs/AdditionalPropertiesAnyType.md) + - [additional_properties_array.AdditionalPropertiesArray](docs/AdditionalPropertiesArray.md) + - [additional_properties_boolean.AdditionalPropertiesBoolean](docs/AdditionalPropertiesBoolean.md) + - [additional_properties_class.AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md) + - [additional_properties_integer.AdditionalPropertiesInteger](docs/AdditionalPropertiesInteger.md) + - [additional_properties_number.AdditionalPropertiesNumber](docs/AdditionalPropertiesNumber.md) + - [additional_properties_object.AdditionalPropertiesObject](docs/AdditionalPropertiesObject.md) + - [additional_properties_string.AdditionalPropertiesString](docs/AdditionalPropertiesString.md) + - [animal.Animal](docs/Animal.md) + - [api_response.ApiResponse](docs/ApiResponse.md) + - [array_of_array_of_number_only.ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) + - [array_of_number_only.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) + - [array_test.ArrayTest](docs/ArrayTest.md) + - [capitalization.Capitalization](docs/Capitalization.md) + - [cat.Cat](docs/Cat.md) + - [cat_all_of.CatAllOf](docs/CatAllOf.md) + - [category.Category](docs/Category.md) + - [child.Child](docs/Child.md) + - [child_all_of.ChildAllOf](docs/ChildAllOf.md) + - [child_cat.ChildCat](docs/ChildCat.md) + - [child_cat_all_of.ChildCatAllOf](docs/ChildCatAllOf.md) + - [child_dog.ChildDog](docs/ChildDog.md) + - [child_dog_all_of.ChildDogAllOf](docs/ChildDogAllOf.md) + - [child_lizard.ChildLizard](docs/ChildLizard.md) + - [child_lizard_all_of.ChildLizardAllOf](docs/ChildLizardAllOf.md) + - [class_model.ClassModel](docs/ClassModel.md) + - [client.Client](docs/Client.md) + - [dog.Dog](docs/Dog.md) + - [dog_all_of.DogAllOf](docs/DogAllOf.md) + - [enum_arrays.EnumArrays](docs/EnumArrays.md) + - [enum_class.EnumClass](docs/EnumClass.md) + - [enum_test.EnumTest](docs/EnumTest.md) + - [file.File](docs/File.md) + - [file_schema_test_class.FileSchemaTestClass](docs/FileSchemaTestClass.md) + - [format_test.FormatTest](docs/FormatTest.md) + - [grandparent.Grandparent](docs/Grandparent.md) + - [grandparent_animal.GrandparentAnimal](docs/GrandparentAnimal.md) + - [has_only_read_only.HasOnlyReadOnly](docs/HasOnlyReadOnly.md) + - [list.List](docs/List.md) + - [map_test.MapTest](docs/MapTest.md) + - [mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md) + - [model200_response.Model200Response](docs/Model200Response.md) + - [model_return.ModelReturn](docs/ModelReturn.md) + - [name.Name](docs/Name.md) + - [number_only.NumberOnly](docs/NumberOnly.md) + - [order.Order](docs/Order.md) + - [outer_composite.OuterComposite](docs/OuterComposite.md) + - [outer_enum.OuterEnum](docs/OuterEnum.md) + - [outer_number.OuterNumber](docs/OuterNumber.md) + - [parent.Parent](docs/Parent.md) + - [parent_all_of.ParentAllOf](docs/ParentAllOf.md) + - [parent_pet.ParentPet](docs/ParentPet.md) + - [pet.Pet](docs/Pet.md) + - [read_only_first.ReadOnlyFirst](docs/ReadOnlyFirst.md) + - [special_model_name.SpecialModelName](docs/SpecialModelName.md) + - [string_boolean_map.StringBooleanMap](docs/StringBooleanMap.md) + - [tag.Tag](docs/Tag.md) + - [type_holder_default.TypeHolderDefault](docs/TypeHolderDefault.md) + - [type_holder_example.TypeHolderExample](docs/TypeHolderExample.md) + - [user.User](docs/User.md) + - [xml_item.XmlItem](docs/XmlItem.md) ## Documentation For Authorization diff --git a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesAnyType.md b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesAnyType.md index 754b2f3ada4c..d27928ab7527 100644 --- a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesAnyType.md +++ b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesAnyType.md @@ -1,4 +1,4 @@ -# AdditionalPropertiesAnyType +# additional_properties_any_type.AdditionalPropertiesAnyType ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesArray.md b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesArray.md index 61ac566c14d2..6eac3ace2eca 100644 --- a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesArray.md +++ b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesArray.md @@ -1,4 +1,4 @@ -# AdditionalPropertiesArray +# additional_properties_array.AdditionalPropertiesArray ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesBoolean.md b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesBoolean.md index f2567f064cfd..b403323c5532 100644 --- a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesBoolean.md +++ b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesBoolean.md @@ -1,4 +1,4 @@ -# AdditionalPropertiesBoolean +# additional_properties_boolean.AdditionalPropertiesBoolean ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesClass.md b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesClass.md index 1a379bff6f0a..4b232aa174af 100644 --- a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesClass.md +++ b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesClass.md @@ -1,4 +1,4 @@ -# AdditionalPropertiesClass +# additional_properties_class.AdditionalPropertiesClass ## Properties Name | Type | Description | Notes @@ -11,9 +11,9 @@ Name | Type | Description | Notes **map_array_anytype** | **{str: ([bool, date, datetime, dict, float, int, list, str],)}** | | [optional] **map_map_string** | **{str: ({str: (str,)},)}** | | [optional] **map_map_anytype** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)}** | | [optional] -**anytype_1** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional] -**anytype_2** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional] -**anytype_3** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional] +**anytype_1** | **bool, date, datetime, dict, float, int, list, str** | | [optional] +**anytype_2** | **bool, date, datetime, dict, float, int, list, str** | | [optional] +**anytype_3** | **bool, date, datetime, dict, float, int, list, str** | | [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/AdditionalPropertiesInteger.md b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesInteger.md index fe0ba709c8ef..461419e03759 100644 --- a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesInteger.md +++ b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesInteger.md @@ -1,4 +1,4 @@ -# AdditionalPropertiesInteger +# additional_properties_integer.AdditionalPropertiesInteger ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesNumber.md b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesNumber.md index bec81854b950..e0e328aed8eb 100644 --- a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesNumber.md +++ b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesNumber.md @@ -1,4 +1,4 @@ -# AdditionalPropertiesNumber +# additional_properties_number.AdditionalPropertiesNumber ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesObject.md b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesObject.md index 3fcf2c9299df..36026fe72f82 100644 --- a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesObject.md +++ b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesObject.md @@ -1,4 +1,4 @@ -# AdditionalPropertiesObject +# additional_properties_object.AdditionalPropertiesObject ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesString.md b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesString.md index bbe0b1cbbbb9..41594fd730d0 100644 --- a/samples/client/petstore/python-experimental/docs/AdditionalPropertiesString.md +++ b/samples/client/petstore/python-experimental/docs/AdditionalPropertiesString.md @@ -1,4 +1,4 @@ -# AdditionalPropertiesString +# additional_properties_string.AdditionalPropertiesString ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Animal.md b/samples/client/petstore/python-experimental/docs/Animal.md index e59166a62e83..fda84ee28eea 100644 --- a/samples/client/petstore/python-experimental/docs/Animal.md +++ b/samples/client/petstore/python-experimental/docs/Animal.md @@ -1,4 +1,4 @@ -# Animal +# animal.Animal ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/AnotherFakeApi.md b/samples/client/petstore/python-experimental/docs/AnotherFakeApi.md index 67906afc0cdc..75406ffa107c 100644 --- a/samples/client/petstore/python-experimental/docs/AnotherFakeApi.md +++ b/samples/client/petstore/python-experimental/docs/AnotherFakeApi.md @@ -8,7 +8,7 @@ Method | HTTP request | Description # **call_123_test_special_tags** -> Client call_123_test_special_tags(body) +> client.Client call_123_test_special_tags(body) To test special tags @@ -20,18 +20,18 @@ To test special tags and operation ID starting with number from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.AnotherFakeApi() -body = petstore_api.Client() # Client | client model +body = petstore_api.Client() # client.Client | client model +# example passing only required values which don't have defaults set try: # To test special tags api_response = api_instance.call_123_test_special_tags(body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e) ``` @@ -39,11 +39,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Client**](Client.md)| client model | + **body** | [**client.Client**](Client.md)| client model | ### Return type -[**Client**](Client.md) +[**client.Client**](Client.md) ### Authorization diff --git a/samples/client/petstore/python-experimental/docs/ApiResponse.md b/samples/client/petstore/python-experimental/docs/ApiResponse.md index 8fc302305abe..8f7ffa461340 100644 --- a/samples/client/petstore/python-experimental/docs/ApiResponse.md +++ b/samples/client/petstore/python-experimental/docs/ApiResponse.md @@ -1,4 +1,4 @@ -# ApiResponse +# api_response.ApiResponse ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/python-experimental/docs/ArrayOfArrayOfNumberOnly.md index 1a68df0090bb..ab82c8c556d0 100644 --- a/samples/client/petstore/python-experimental/docs/ArrayOfArrayOfNumberOnly.md +++ b/samples/client/petstore/python-experimental/docs/ArrayOfArrayOfNumberOnly.md @@ -1,4 +1,4 @@ -# ArrayOfArrayOfNumberOnly +# array_of_array_of_number_only.ArrayOfArrayOfNumberOnly ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/ArrayOfNumberOnly.md b/samples/client/petstore/python-experimental/docs/ArrayOfNumberOnly.md index b8a760f56dc2..b8ffd843c8d8 100644 --- a/samples/client/petstore/python-experimental/docs/ArrayOfNumberOnly.md +++ b/samples/client/petstore/python-experimental/docs/ArrayOfNumberOnly.md @@ -1,4 +1,4 @@ -# ArrayOfNumberOnly +# array_of_number_only.ArrayOfNumberOnly ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/ArrayTest.md b/samples/client/petstore/python-experimental/docs/ArrayTest.md index c677e324ad47..22f198440e7b 100644 --- a/samples/client/petstore/python-experimental/docs/ArrayTest.md +++ b/samples/client/petstore/python-experimental/docs/ArrayTest.md @@ -1,11 +1,11 @@ -# ArrayTest +# array_test.ArrayTest ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **array_of_string** | **[str]** | | [optional] **array_array_of_integer** | **[[int]]** | | [optional] -**array_array_of_model** | **[[ReadOnlyFirst]]** | | [optional] +**array_array_of_model** | [**[[read_only_first.ReadOnlyFirst]]**](ReadOnlyFirst.md) | | [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/Capitalization.md b/samples/client/petstore/python-experimental/docs/Capitalization.md index 85d88d239ee7..d402f2a571a8 100644 --- a/samples/client/petstore/python-experimental/docs/Capitalization.md +++ b/samples/client/petstore/python-experimental/docs/Capitalization.md @@ -1,4 +1,4 @@ -# Capitalization +# capitalization.Capitalization ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Cat.md b/samples/client/petstore/python-experimental/docs/Cat.md index 8bdbf9b3bcca..1d7b5b26d715 100644 --- a/samples/client/petstore/python-experimental/docs/Cat.md +++ b/samples/client/petstore/python-experimental/docs/Cat.md @@ -1,4 +1,4 @@ -# Cat +# cat.Cat ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/CatAllOf.md b/samples/client/petstore/python-experimental/docs/CatAllOf.md index 35434374fc97..653bb0aa3538 100644 --- a/samples/client/petstore/python-experimental/docs/CatAllOf.md +++ b/samples/client/petstore/python-experimental/docs/CatAllOf.md @@ -1,4 +1,4 @@ -# CatAllOf +# cat_all_of.CatAllOf ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Category.md b/samples/client/petstore/python-experimental/docs/Category.md index 33b2242d703f..bb122d910fcd 100644 --- a/samples/client/petstore/python-experimental/docs/Category.md +++ b/samples/client/petstore/python-experimental/docs/Category.md @@ -1,4 +1,4 @@ -# Category +# category.Category ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Child.md b/samples/client/petstore/python-experimental/docs/Child.md new file mode 100644 index 000000000000..bc3c7f3922d3 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/Child.md @@ -0,0 +1,12 @@ +# child.Child + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**radio_waves** | **bool** | | [optional] +**tele_vision** | **bool** | | [optional] +**inter_net** | **bool** | | [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/ChildAllOf.md b/samples/client/petstore/python-experimental/docs/ChildAllOf.md new file mode 100644 index 000000000000..9d2e42e1894e --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ChildAllOf.md @@ -0,0 +1,10 @@ +# child_all_of.ChildAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**inter_net** | **bool** | | [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/ChildCat.md b/samples/client/petstore/python-experimental/docs/ChildCat.md new file mode 100644 index 000000000000..8f5ea4b2ced0 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ChildCat.md @@ -0,0 +1,11 @@ +# child_cat.ChildCat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | +**name** | **str** | | [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/ChildCatAllOf.md b/samples/client/petstore/python-experimental/docs/ChildCatAllOf.md new file mode 100644 index 000000000000..2e84f31081f9 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ChildCatAllOf.md @@ -0,0 +1,10 @@ +# child_cat_all_of.ChildCatAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | | [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/ChildDog.md b/samples/client/petstore/python-experimental/docs/ChildDog.md new file mode 100644 index 000000000000..2680d987a452 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ChildDog.md @@ -0,0 +1,11 @@ +# child_dog.ChildDog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | +**bark** | **str** | | [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/ChildDogAllOf.md b/samples/client/petstore/python-experimental/docs/ChildDogAllOf.md new file mode 100644 index 000000000000..c7dded9a6df1 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ChildDogAllOf.md @@ -0,0 +1,10 @@ +# child_dog_all_of.ChildDogAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**bark** | **str** | | [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/ChildLizard.md b/samples/client/petstore/python-experimental/docs/ChildLizard.md new file mode 100644 index 000000000000..97b8891a27e2 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ChildLizard.md @@ -0,0 +1,11 @@ +# child_lizard.ChildLizard + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | +**loves_rocks** | **bool** | | [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/ChildLizardAllOf.md b/samples/client/petstore/python-experimental/docs/ChildLizardAllOf.md new file mode 100644 index 000000000000..517f1260b968 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ChildLizardAllOf.md @@ -0,0 +1,10 @@ +# child_lizard_all_of.ChildLizardAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**loves_rocks** | **bool** | | [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/ClassModel.md b/samples/client/petstore/python-experimental/docs/ClassModel.md index 657d51a944de..3f5d0075c1bb 100644 --- a/samples/client/petstore/python-experimental/docs/ClassModel.md +++ b/samples/client/petstore/python-experimental/docs/ClassModel.md @@ -1,4 +1,4 @@ -# ClassModel +# class_model.ClassModel Model for testing model with \"_class\" property ## Properties diff --git a/samples/client/petstore/python-experimental/docs/Client.md b/samples/client/petstore/python-experimental/docs/Client.md index 88e99384f92c..4c7ce57f750f 100644 --- a/samples/client/petstore/python-experimental/docs/Client.md +++ b/samples/client/petstore/python-experimental/docs/Client.md @@ -1,4 +1,4 @@ -# Client +# client.Client ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Dog.md b/samples/client/petstore/python-experimental/docs/Dog.md index 81de56780725..ec98b99dcec5 100644 --- a/samples/client/petstore/python-experimental/docs/Dog.md +++ b/samples/client/petstore/python-experimental/docs/Dog.md @@ -1,4 +1,4 @@ -# Dog +# dog.Dog ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/DogAllOf.md b/samples/client/petstore/python-experimental/docs/DogAllOf.md index 36d3216f7b35..da3c29557df7 100644 --- a/samples/client/petstore/python-experimental/docs/DogAllOf.md +++ b/samples/client/petstore/python-experimental/docs/DogAllOf.md @@ -1,4 +1,4 @@ -# DogAllOf +# dog_all_of.DogAllOf ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/EnumArrays.md b/samples/client/petstore/python-experimental/docs/EnumArrays.md index e0b5582e9d5b..c2f22d45047c 100644 --- a/samples/client/petstore/python-experimental/docs/EnumArrays.md +++ b/samples/client/petstore/python-experimental/docs/EnumArrays.md @@ -1,4 +1,4 @@ -# EnumArrays +# enum_arrays.EnumArrays ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/EnumClass.md b/samples/client/petstore/python-experimental/docs/EnumClass.md index 510dff4df0cf..333307fde46c 100644 --- a/samples/client/petstore/python-experimental/docs/EnumClass.md +++ b/samples/client/petstore/python-experimental/docs/EnumClass.md @@ -1,4 +1,4 @@ -# EnumClass +# enum_class.EnumClass ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/EnumTest.md b/samples/client/petstore/python-experimental/docs/EnumTest.md index 5fc28b6c1ce3..94477ea5a511 100644 --- a/samples/client/petstore/python-experimental/docs/EnumTest.md +++ b/samples/client/petstore/python-experimental/docs/EnumTest.md @@ -1,4 +1,4 @@ -# EnumTest +# enum_test.EnumTest ## Properties Name | Type | Description | Notes @@ -7,7 +7,7 @@ Name | Type | Description | Notes **enum_string** | **str** | | [optional] **enum_integer** | **int** | | [optional] **enum_number** | **float** | | [optional] -**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional] +**outer_enum** | [**outer_enum.OuterEnum**](OuterEnum.md) | | [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/FakeApi.md b/samples/client/petstore/python-experimental/docs/FakeApi.md index 0677687d5927..610d804757b2 100644 --- a/samples/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/client/petstore/python-experimental/docs/FakeApi.md @@ -34,17 +34,17 @@ this route creates an XmlItem from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() -xml_item = petstore_api.XmlItem() # XmlItem | XmlItem Body +xml_item = petstore_api.XmlItem() # xml_item.XmlItem | XmlItem Body +# example passing only required values which don't have defaults set try: # creates an XmlItem api_instance.create_xml_item(xml_item) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->create_xml_item: %s\n" % e) ``` @@ -52,7 +52,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **xml_item** | [**XmlItem**](XmlItem.md)| XmlItem Body | + **xml_item** | [**xml_item.XmlItem**](XmlItem.md)| XmlItem Body | ### Return type @@ -87,17 +87,18 @@ Test serialization of outer boolean types from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() body = True # bool | Input boolean as post body (optional) +# example passing only required values which don't have defaults set +# and optional values try: api_response = api_instance.fake_outer_boolean_serialize(body=body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->fake_outer_boolean_serialize: %s\n" % e) ``` @@ -128,7 +129,7 @@ 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) # **fake_outer_composite_serialize** -> OuterComposite fake_outer_composite_serialize() +> outer_composite.OuterComposite fake_outer_composite_serialize() @@ -140,17 +141,18 @@ Test serialization of object with outer number type from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() -body = petstore_api.OuterComposite() # OuterComposite | Input composite as post body (optional) +body = petstore_api.OuterComposite() # outer_composite.OuterComposite | Input composite as post body (optional) +# example passing only required values which don't have defaults set +# and optional values try: api_response = api_instance.fake_outer_composite_serialize(body=body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->fake_outer_composite_serialize: %s\n" % e) ``` @@ -158,11 +160,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + **body** | [**outer_composite.OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] ### Return type -[**OuterComposite**](OuterComposite.md) +[**outer_composite.OuterComposite**](OuterComposite.md) ### Authorization @@ -181,7 +183,7 @@ 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) # **fake_outer_enum_serialize** -> OuterEnum fake_outer_enum_serialize() +> outer_enum.OuterEnum fake_outer_enum_serialize() @@ -193,17 +195,18 @@ Test serialization of outer enum from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() -body = OuterEnum("placed") # OuterEnum | Input enum as post body (optional) +body = petstore_api.OuterEnum("placed") # outer_enum.OuterEnum | Input enum as post body (optional) +# example passing only required values which don't have defaults set +# and optional values try: api_response = api_instance.fake_outer_enum_serialize(body=body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->fake_outer_enum_serialize: %s\n" % e) ``` @@ -211,11 +214,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterEnum**](str.md)| Input enum as post body | [optional] + **body** | [**outer_enum.OuterEnum**](OuterEnum.md)| Input enum as post body | [optional] ### Return type -[**OuterEnum**](OuterEnum.md) +[**outer_enum.OuterEnum**](OuterEnum.md) ### Authorization @@ -234,7 +237,7 @@ 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) # **fake_outer_number_serialize** -> OuterNumber fake_outer_number_serialize() +> outer_number.OuterNumber fake_outer_number_serialize() @@ -246,17 +249,18 @@ Test serialization of outer number types from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() -body = OuterNumber(3.4) # OuterNumber | Input number as post body (optional) +body = petstore_api.OuterNumber(3.4) # outer_number.OuterNumber | Input number as post body (optional) +# example passing only required values which don't have defaults set +# and optional values try: api_response = api_instance.fake_outer_number_serialize(body=body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->fake_outer_number_serialize: %s\n" % e) ``` @@ -264,11 +268,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**OuterNumber**](float.md)| Input number as post body | [optional] + **body** | [**outer_number.OuterNumber**](OuterNumber.md)| Input number as post body | [optional] ### Return type -[**OuterNumber**](OuterNumber.md) +[**outer_number.OuterNumber**](OuterNumber.md) ### Authorization @@ -299,17 +303,18 @@ Test serialization of outer string types from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() body = 'body_example' # str | Input string as post body (optional) +# example passing only required values which don't have defaults set +# and optional values try: api_response = api_instance.fake_outer_string_serialize(body=body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->fake_outer_string_serialize: %s\n" % e) ``` @@ -352,16 +357,16 @@ For this test, the body for this request much reference a schema named `File`. from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() -body = petstore_api.FileSchemaTestClass() # FileSchemaTestClass | +body = petstore_api.FileSchemaTestClass() # file_schema_test_class.FileSchemaTestClass | +# example passing only required values which don't have defaults set try: api_instance.test_body_with_file_schema(body) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_body_with_file_schema: %s\n" % e) ``` @@ -369,7 +374,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**FileSchemaTestClass**](FileSchemaTestClass.md)| | + **body** | [**file_schema_test_class.FileSchemaTestClass**](FileSchemaTestClass.md)| | ### Return type @@ -402,17 +407,17 @@ No authorization required from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() query = 'query_example' # str | -body = petstore_api.User() # User | +body = petstore_api.User() # user.User | +# example passing only required values which don't have defaults set try: api_instance.test_body_with_query_params(query, body) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_body_with_query_params: %s\n" % e) ``` @@ -421,7 +426,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **query** | **str**| | - **body** | [**User**](User.md)| | + **body** | [**user.User**](User.md)| | ### Return type @@ -444,7 +449,7 @@ 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) # **test_client_model** -> Client test_client_model(body) +> client.Client test_client_model(body) To test \"client\" model @@ -456,18 +461,18 @@ To test \"client\" model from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() -body = petstore_api.Client() # Client | client model +body = petstore_api.Client() # client.Client | client model +# example passing only required values which don't have defaults set try: # To test \"client\" model api_response = api_instance.test_client_model(body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_client_model: %s\n" % e) ``` @@ -475,11 +480,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Client**](Client.md)| client model | + **body** | [**client.Client**](Client.md)| client model | ### Return type -[**Client**](Client.md) +[**client.Client**](Client.md) ### Authorization @@ -510,20 +515,15 @@ This route has required values with enums of 1 from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() -query_integer = 3 # int | (default to 3) -query_string = 'brillig' # str | (default to 'brillig') -path_string = 'hello' # str | (default to 'hello') -path_integer = 34 # int | (default to 34) -header_number = 1.234 # float | (default to 1.234) +# example passing only required values which don't have defaults set try: - api_instance.test_endpoint_enums_length_one(query_integer, query_string, path_string, path_integer, header_number) -except ApiException as e: + api_instance.test_endpoint_enums_length_one() +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_endpoint_enums_length_one: %s\n" % e) ``` @@ -571,7 +571,6 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure HTTP basic authorization: http_basic_test @@ -597,10 +596,19 @@ 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) +# example passing only required values which don't have defaults set +try: + # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 + api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte) +except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e) + +# example passing only required values which don't have defaults set +# and optional values try: # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password, param_callback=param_callback) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e) ``` @@ -657,24 +665,25 @@ To test enum parameters from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() 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) (default to '-efg') +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) (default to '-efg') +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) (default to '$') -enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to '-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 = '-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 try: # To test enum parameters api_instance.test_enum_parameters(enum_header_string_array=enum_header_string_array, enum_header_string=enum_header_string, enum_query_string_array=enum_query_string_array, enum_query_string=enum_query_string, enum_query_integer=enum_query_integer, enum_query_double=enum_query_double, enum_form_string_array=enum_form_string_array, enum_form_string=enum_form_string) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_enum_parameters: %s\n" % e) ``` @@ -682,13 +691,13 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **enum_header_string_array** | [**[str]**](str.md)| Header parameter enum test (string array) | [optional] + **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_query_string_array** | [**[str]**](str.md)| Query parameter enum test (string array) | [optional] + **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_integer** | **int**| Query parameter enum test (double) | [optional] **enum_query_double** | **float**| Query parameter enum test (double) | [optional] - **enum_form_string_array** | [**[str]**](str.md)| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$' + **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 @@ -725,7 +734,6 @@ Fake endpoint to test group parameters (optional) from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class @@ -737,10 +745,19 @@ 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) +# example passing only required values which don't have defaults set +try: + # Fake endpoint to test group parameters (optional) + api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group) +except petstore_api.ApiException as e: + print("Exception when calling FakeApi->test_group_parameters: %s\n" % e) + +# example passing only required values which don't have defaults set +# and optional values try: # Fake endpoint to test group parameters (optional) api_instance.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, string_group=string_group, boolean_group=boolean_group, int64_group=int64_group) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_group_parameters: %s\n" % e) ``` @@ -786,17 +803,17 @@ test inline additionalProperties from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() param = {'key': 'param_example'} # {str: (str,)} | request body +# example passing only required values which don't have defaults set try: # test inline additionalProperties api_instance.test_inline_additional_properties(param) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_inline_additional_properties: %s\n" % e) ``` @@ -804,7 +821,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **param** | [**{str: (str,)}**](str.md)| request body | + **param** | **{str: (str,)}**| request body | ### Return type @@ -837,7 +854,6 @@ test json serialization of form data from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class @@ -845,10 +861,11 @@ api_instance = petstore_api.FakeApi() 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 api_instance.test_json_form_data(param, param2) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeApi->test_json_form_data: %s\n" % e) ``` diff --git a/samples/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md b/samples/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md index 321fd9e1854e..2335c666fd81 100644 --- a/samples/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md +++ b/samples/client/petstore/python-experimental/docs/FakeClassnameTags123Api.md @@ -8,7 +8,7 @@ Method | HTTP request | Description # **test_classname** -> Client test_classname(body) +> client.Client test_classname(body) To test class name in snake case @@ -21,7 +21,6 @@ To test class name in snake case from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure API key authorization: api_key_query @@ -33,13 +32,14 @@ configuration.api_key['api_key_query'] = 'YOUR_API_KEY' configuration.host = "http://petstore.swagger.io:80/v2" # Create an instance of the API class api_instance = petstore_api.FakeClassnameTags123Api(petstore_api.ApiClient(configuration)) -body = petstore_api.Client() # Client | client model +body = petstore_api.Client() # client.Client | client model +# example passing only required values which don't have defaults set try: # To test class name in snake case api_response = api_instance.test_classname(body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling FakeClassnameTags123Api->test_classname: %s\n" % e) ``` @@ -47,11 +47,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Client**](Client.md)| client model | + **body** | [**client.Client**](Client.md)| client model | ### Return type -[**Client**](Client.md) +[**client.Client**](Client.md) ### Authorization diff --git a/samples/client/petstore/python-experimental/docs/File.md b/samples/client/petstore/python-experimental/docs/File.md index f17ba0057d04..2847323a0989 100644 --- a/samples/client/petstore/python-experimental/docs/File.md +++ b/samples/client/petstore/python-experimental/docs/File.md @@ -1,4 +1,4 @@ -# File +# file.File Must be named `File` for test. ## Properties diff --git a/samples/client/petstore/python-experimental/docs/FileSchemaTestClass.md b/samples/client/petstore/python-experimental/docs/FileSchemaTestClass.md index d0a8bbaaba95..807350c62f2c 100644 --- a/samples/client/petstore/python-experimental/docs/FileSchemaTestClass.md +++ b/samples/client/petstore/python-experimental/docs/FileSchemaTestClass.md @@ -1,10 +1,10 @@ -# FileSchemaTestClass +# file_schema_test_class.FileSchemaTestClass ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**file** | [**File**](File.md) | | [optional] -**files** | [**[File]**](File.md) | | [optional] +**file** | [**file.File**](File.md) | | [optional] +**files** | [**[file.File]**](File.md) | | [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/FormatTest.md b/samples/client/petstore/python-experimental/docs/FormatTest.md index 083b0bd4c98a..0f0e2f7cfe18 100644 --- a/samples/client/petstore/python-experimental/docs/FormatTest.md +++ b/samples/client/petstore/python-experimental/docs/FormatTest.md @@ -1,4 +1,4 @@ -# FormatTest +# format_test.FormatTest ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Grandparent.md b/samples/client/petstore/python-experimental/docs/Grandparent.md new file mode 100644 index 000000000000..66f493338381 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/Grandparent.md @@ -0,0 +1,10 @@ +# grandparent.Grandparent + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**radio_waves** | **bool** | | [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/GrandparentAnimal.md b/samples/client/petstore/python-experimental/docs/GrandparentAnimal.md new file mode 100644 index 000000000000..8a6679f3895f --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/GrandparentAnimal.md @@ -0,0 +1,10 @@ +# grandparent_animal.GrandparentAnimal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | + +[[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/HasOnlyReadOnly.md b/samples/client/petstore/python-experimental/docs/HasOnlyReadOnly.md index f731a42eab54..f2194e269ed3 100644 --- a/samples/client/petstore/python-experimental/docs/HasOnlyReadOnly.md +++ b/samples/client/petstore/python-experimental/docs/HasOnlyReadOnly.md @@ -1,4 +1,4 @@ -# HasOnlyReadOnly +# has_only_read_only.HasOnlyReadOnly ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/List.md b/samples/client/petstore/python-experimental/docs/List.md index 11f4f3a05f32..28e2ec05968c 100644 --- a/samples/client/petstore/python-experimental/docs/List.md +++ b/samples/client/petstore/python-experimental/docs/List.md @@ -1,4 +1,4 @@ -# List +# list.List ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/MapTest.md b/samples/client/petstore/python-experimental/docs/MapTest.md index ad561b7220bf..9fc13abebdc0 100644 --- a/samples/client/petstore/python-experimental/docs/MapTest.md +++ b/samples/client/petstore/python-experimental/docs/MapTest.md @@ -1,4 +1,4 @@ -# MapTest +# map_test.MapTest ## Properties Name | Type | Description | Notes @@ -6,7 +6,7 @@ Name | Type | Description | Notes **map_map_of_string** | **{str: ({str: (str,)},)}** | | [optional] **map_of_enum_string** | **{str: (str,)}** | | [optional] **direct_map** | **{str: (bool,)}** | | [optional] -**indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional] +**indirect_map** | [**string_boolean_map.StringBooleanMap**](StringBooleanMap.md) | | [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/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/client/petstore/python-experimental/docs/MixedPropertiesAndAdditionalPropertiesClass.md index 1484c0638d83..87cda996e769 100644 --- a/samples/client/petstore/python-experimental/docs/MixedPropertiesAndAdditionalPropertiesClass.md +++ b/samples/client/petstore/python-experimental/docs/MixedPropertiesAndAdditionalPropertiesClass.md @@ -1,11 +1,11 @@ -# MixedPropertiesAndAdditionalPropertiesClass +# mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **uuid** | **str** | | [optional] **date_time** | **datetime** | | [optional] -**map** | [**{str: (Animal,)}**](Animal.md) | | [optional] +**map** | [**{str: (animal.Animal,)}**](Animal.md) | | [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/Model200Response.md b/samples/client/petstore/python-experimental/docs/Model200Response.md index 40d0d7828e14..90f5c2c025d8 100644 --- a/samples/client/petstore/python-experimental/docs/Model200Response.md +++ b/samples/client/petstore/python-experimental/docs/Model200Response.md @@ -1,4 +1,4 @@ -# Model200Response +# model200_response.Model200Response Model for testing model name starting with number ## Properties diff --git a/samples/client/petstore/python-experimental/docs/ModelReturn.md b/samples/client/petstore/python-experimental/docs/ModelReturn.md index 65ec73ddae78..3be9912b753e 100644 --- a/samples/client/petstore/python-experimental/docs/ModelReturn.md +++ b/samples/client/petstore/python-experimental/docs/ModelReturn.md @@ -1,4 +1,4 @@ -# ModelReturn +# model_return.ModelReturn Model for testing reserved words ## Properties diff --git a/samples/client/petstore/python-experimental/docs/Name.md b/samples/client/petstore/python-experimental/docs/Name.md index 807b76afc6ee..777b79a3d8bd 100644 --- a/samples/client/petstore/python-experimental/docs/Name.md +++ b/samples/client/petstore/python-experimental/docs/Name.md @@ -1,4 +1,4 @@ -# Name +# name.Name Model for testing model name same as property name ## Properties diff --git a/samples/client/petstore/python-experimental/docs/NumberOnly.md b/samples/client/petstore/python-experimental/docs/NumberOnly.md index 93a0fde7b931..ea1a09d2934d 100644 --- a/samples/client/petstore/python-experimental/docs/NumberOnly.md +++ b/samples/client/petstore/python-experimental/docs/NumberOnly.md @@ -1,4 +1,4 @@ -# NumberOnly +# number_only.NumberOnly ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Order.md b/samples/client/petstore/python-experimental/docs/Order.md index c21210a3bd59..9569ea55e55c 100644 --- a/samples/client/petstore/python-experimental/docs/Order.md +++ b/samples/client/petstore/python-experimental/docs/Order.md @@ -1,4 +1,4 @@ -# Order +# order.Order ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/OuterComposite.md b/samples/client/petstore/python-experimental/docs/OuterComposite.md index 3df277a30fa5..88a190c7df99 100644 --- a/samples/client/petstore/python-experimental/docs/OuterComposite.md +++ b/samples/client/petstore/python-experimental/docs/OuterComposite.md @@ -1,9 +1,9 @@ -# OuterComposite +# outer_composite.OuterComposite ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**my_number** | [**OuterNumber**](OuterNumber.md) | | [optional] +**my_number** | [**outer_number.OuterNumber**](OuterNumber.md) | | [optional] **my_string** | **str** | | [optional] **my_boolean** | **bool** | | [optional] diff --git a/samples/client/petstore/python-experimental/docs/OuterEnum.md b/samples/client/petstore/python-experimental/docs/OuterEnum.md index cba017068980..1428a27552db 100644 --- a/samples/client/petstore/python-experimental/docs/OuterEnum.md +++ b/samples/client/petstore/python-experimental/docs/OuterEnum.md @@ -1,4 +1,4 @@ -# OuterEnum +# outer_enum.OuterEnum ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/OuterNumber.md b/samples/client/petstore/python-experimental/docs/OuterNumber.md index 5d75342bd8e3..7e3728b519cb 100644 --- a/samples/client/petstore/python-experimental/docs/OuterNumber.md +++ b/samples/client/petstore/python-experimental/docs/OuterNumber.md @@ -1,4 +1,4 @@ -# OuterNumber +# outer_number.OuterNumber ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Parent.md b/samples/client/petstore/python-experimental/docs/Parent.md new file mode 100644 index 000000000000..2437d3c81ac9 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/Parent.md @@ -0,0 +1,11 @@ +# parent.Parent + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**radio_waves** | **bool** | | [optional] +**tele_vision** | **bool** | | [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/ParentAllOf.md b/samples/client/petstore/python-experimental/docs/ParentAllOf.md new file mode 100644 index 000000000000..6a27f70d4ad5 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ParentAllOf.md @@ -0,0 +1,10 @@ +# parent_all_of.ParentAllOf + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tele_vision** | **bool** | | [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/ParentPet.md b/samples/client/petstore/python-experimental/docs/ParentPet.md new file mode 100644 index 000000000000..12bfa5c7fe5c --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/ParentPet.md @@ -0,0 +1,10 @@ +# parent_pet.ParentPet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**pet_type** | **str** | | + +[[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/Pet.md b/samples/client/petstore/python-experimental/docs/Pet.md index ce09d401c899..a1ea5598e861 100644 --- a/samples/client/petstore/python-experimental/docs/Pet.md +++ b/samples/client/petstore/python-experimental/docs/Pet.md @@ -1,4 +1,4 @@ -# Pet +# pet.Pet ## Properties Name | Type | Description | Notes @@ -6,8 +6,8 @@ Name | Type | Description | Notes **name** | **str** | | **photo_urls** | **[str]** | | **id** | **int** | | [optional] -**category** | [**Category**](Category.md) | | [optional] -**tags** | [**[Tag]**](Tag.md) | | [optional] +**category** | [**category.Category**](Category.md) | | [optional] +**tags** | [**[tag.Tag]**](Tag.md) | | [optional] **status** | **str** | pet status in the store | [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/PetApi.md b/samples/client/petstore/python-experimental/docs/PetApi.md index 8364f8fa8fc8..dbeb8dfe5ac8 100644 --- a/samples/client/petstore/python-experimental/docs/PetApi.md +++ b/samples/client/petstore/python-experimental/docs/PetApi.md @@ -27,7 +27,6 @@ Add a new pet to the store from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure OAuth2 access token for authorization: petstore_auth @@ -37,12 +36,13 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' configuration.host = "http://petstore.swagger.io:80/v2" # Create an instance of the API class api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) -body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store +body = petstore_api.Pet() # pet.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 api_instance.add_pet(body) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->add_pet: %s\n" % e) ``` @@ -50,7 +50,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**pet.Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -85,7 +85,6 @@ Deletes a pet from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure OAuth2 access token for authorization: petstore_auth @@ -98,10 +97,19 @@ api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) pet_id = 56 # int | Pet id to delete api_key = 'api_key_example' # str | (optional) +# example passing only required values which don't have defaults set +try: + # Deletes a pet + api_instance.delete_pet(pet_id) +except petstore_api.ApiException as e: + print("Exception when calling PetApi->delete_pet: %s\n" % e) + +# example passing only required values which don't have defaults set +# and optional values try: # Deletes a pet api_instance.delete_pet(pet_id, api_key=api_key) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->delete_pet: %s\n" % e) ``` @@ -134,7 +142,7 @@ void (empty response body) [[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) # **find_pets_by_status** -> [Pet] find_pets_by_status(status) +> [pet.Pet] find_pets_by_status(status) Finds Pets by status @@ -147,7 +155,6 @@ Multiple status values can be provided with comma separated strings from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure OAuth2 access token for authorization: petstore_auth @@ -159,11 +166,12 @@ configuration.host = "http://petstore.swagger.io:80/v2" api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) status = ['status_example'] # [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 api_response = api_instance.find_pets_by_status(status) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->find_pets_by_status: %s\n" % e) ``` @@ -171,11 +179,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | [**[str]**](str.md)| Status values that need to be considered for filter | + **status** | **[str]**| Status values that need to be considered for filter | ### Return type -[**[Pet]**](Pet.md) +[**[pet.Pet]**](Pet.md) ### Authorization @@ -195,7 +203,7 @@ Name | Type | Description | Notes [[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) # **find_pets_by_tags** -> [Pet] find_pets_by_tags(tags) +> [pet.Pet] find_pets_by_tags(tags) Finds Pets by tags @@ -208,7 +216,6 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure OAuth2 access token for authorization: petstore_auth @@ -220,11 +227,12 @@ configuration.host = "http://petstore.swagger.io:80/v2" api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) tags = ['tags_example'] # [str] | Tags to filter by +# example passing only required values which don't have defaults set try: # Finds Pets by tags api_response = api_instance.find_pets_by_tags(tags) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e) ``` @@ -232,11 +240,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **tags** | [**[str]**](str.md)| Tags to filter by | + **tags** | **[str]**| Tags to filter by | ### Return type -[**[Pet]**](Pet.md) +[**[pet.Pet]**](Pet.md) ### Authorization @@ -256,7 +264,7 @@ Name | Type | Description | Notes [[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) # **get_pet_by_id** -> Pet get_pet_by_id(pet_id) +> pet.Pet get_pet_by_id(pet_id) Find pet by ID @@ -269,7 +277,6 @@ Returns a single pet from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure API key authorization: api_key @@ -283,11 +290,12 @@ configuration.host = "http://petstore.swagger.io:80/v2" api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) pet_id = 56 # int | ID of pet to return +# example passing only required values which don't have defaults set try: # Find pet by ID api_response = api_instance.get_pet_by_id(pet_id) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->get_pet_by_id: %s\n" % e) ``` @@ -299,7 +307,7 @@ Name | Type | Description | Notes ### Return type -[**Pet**](Pet.md) +[**pet.Pet**](Pet.md) ### Authorization @@ -331,7 +339,6 @@ Update an existing pet from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure OAuth2 access token for authorization: petstore_auth @@ -341,12 +348,13 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN' configuration.host = "http://petstore.swagger.io:80/v2" # Create an instance of the API class api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration)) -body = petstore_api.Pet() # Pet | Pet object that needs to be added to the store +body = petstore_api.Pet() # pet.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 api_instance.update_pet(body) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->update_pet: %s\n" % e) ``` @@ -354,7 +362,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + **body** | [**pet.Pet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -391,7 +399,6 @@ Updates a pet in the store with form data from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure OAuth2 access token for authorization: petstore_auth @@ -405,10 +412,19 @@ 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) +# example passing only required values which don't have defaults set +try: + # Updates a pet in the store with form data + api_instance.update_pet_with_form(pet_id) +except petstore_api.ApiException as e: + print("Exception when calling PetApi->update_pet_with_form: %s\n" % e) + +# example passing only required values which don't have defaults set +# and optional values try: # Updates a pet in the store with form data api_instance.update_pet_with_form(pet_id, name=name, status=status) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->update_pet_with_form: %s\n" % e) ``` @@ -441,7 +457,7 @@ void (empty response body) [[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) # **upload_file** -> ApiResponse upload_file(pet_id) +> api_response.ApiResponse upload_file(pet_id) uploads an image @@ -452,7 +468,6 @@ uploads an image from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure OAuth2 access token for authorization: petstore_auth @@ -467,11 +482,21 @@ additional_metadata = 'additional_metadata_example' # str | Additional data to p file = open('/path/to/file', 'rb') # file_type | file to upload (optional) files = open('/path/to/file', 'rb') # [file_type] | files to upload (optional) +# example passing only required values which don't have defaults set +try: + # uploads an image + api_response = api_instance.upload_file(pet_id) + pprint(api_response) +except petstore_api.ApiException as e: + print("Exception when calling PetApi->upload_file: %s\n" % e) + +# example passing only required values which don't have defaults set +# and optional values try: # uploads an image api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file, files=files) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->upload_file: %s\n" % e) ``` @@ -482,11 +507,11 @@ Name | Type | Description | Notes **pet_id** | **int**| ID of pet to update | **additional_metadata** | **str**| Additional data to pass to server | [optional] **file** | **file_type**| file to upload | [optional] - **files** | [**[file_type]**](file_type.md)| files to upload | [optional] + **files** | **[file_type]**| files to upload | [optional] ### Return type -[**ApiResponse**](ApiResponse.md) +[**api_response.ApiResponse**](ApiResponse.md) ### Authorization @@ -505,7 +530,7 @@ Name | Type | Description | Notes [[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) # **upload_file_with_required_file** -> ApiResponse upload_file_with_required_file(pet_id, required_file) +> api_response.ApiResponse upload_file_with_required_file(pet_id, required_file) uploads an image (required) @@ -516,7 +541,6 @@ uploads an image (required) from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure OAuth2 access token for authorization: petstore_auth @@ -530,11 +554,21 @@ 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) +# example passing only required values which don't have defaults set +try: + # uploads an image (required) + api_response = api_instance.upload_file_with_required_file(pet_id, required_file) + pprint(api_response) +except petstore_api.ApiException as e: + print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e) + +# example passing only required values which don't have defaults set +# and optional values try: # uploads an image (required) api_response = api_instance.upload_file_with_required_file(pet_id, required_file, additional_metadata=additional_metadata) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling PetApi->upload_file_with_required_file: %s\n" % e) ``` @@ -548,7 +582,7 @@ Name | Type | Description | Notes ### Return type -[**ApiResponse**](ApiResponse.md) +[**api_response.ApiResponse**](ApiResponse.md) ### Authorization diff --git a/samples/client/petstore/python-experimental/docs/ReadOnlyFirst.md b/samples/client/petstore/python-experimental/docs/ReadOnlyFirst.md index 6bc1447c1d71..252641787c3a 100644 --- a/samples/client/petstore/python-experimental/docs/ReadOnlyFirst.md +++ b/samples/client/petstore/python-experimental/docs/ReadOnlyFirst.md @@ -1,4 +1,4 @@ -# ReadOnlyFirst +# read_only_first.ReadOnlyFirst ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/SpecialModelName.md b/samples/client/petstore/python-experimental/docs/SpecialModelName.md index 022ee19169ce..312539af45e3 100644 --- a/samples/client/petstore/python-experimental/docs/SpecialModelName.md +++ b/samples/client/petstore/python-experimental/docs/SpecialModelName.md @@ -1,4 +1,4 @@ -# SpecialModelName +# special_model_name.SpecialModelName ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/StoreApi.md b/samples/client/petstore/python-experimental/docs/StoreApi.md index bc010729c4e9..6dfdac72b496 100644 --- a/samples/client/petstore/python-experimental/docs/StoreApi.md +++ b/samples/client/petstore/python-experimental/docs/StoreApi.md @@ -23,17 +23,17 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.StoreApi() 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 api_instance.delete_order(order_id) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling StoreApi->delete_order: %s\n" % e) ``` @@ -78,7 +78,6 @@ Returns a map of status codes to quantities from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint configuration = petstore_api.Configuration() # Configure API key authorization: api_key @@ -91,11 +90,12 @@ configuration.host = "http://petstore.swagger.io:80/v2" # Create an instance of the API class api_instance = petstore_api.StoreApi(petstore_api.ApiClient(configuration)) +# example, this endpoint has no required or optional parameters try: # Returns pet inventories by status api_response = api_instance.get_inventory() pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling StoreApi->get_inventory: %s\n" % e) ``` @@ -123,7 +123,7 @@ This endpoint does not need any parameter. [[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) # **get_order_by_id** -> Order get_order_by_id(order_id) +> order.Order get_order_by_id(order_id) Find purchase order by ID @@ -135,18 +135,18 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.StoreApi() order_id = 56 # 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 api_response = api_instance.get_order_by_id(order_id) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling StoreApi->get_order_by_id: %s\n" % e) ``` @@ -158,7 +158,7 @@ Name | Type | Description | Notes ### Return type -[**Order**](Order.md) +[**order.Order**](Order.md) ### Authorization @@ -179,7 +179,7 @@ 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) # **place_order** -> Order place_order(body) +> order.Order place_order(body) Place an order for a pet @@ -189,18 +189,18 @@ Place an order for a pet from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.StoreApi() -body = petstore_api.Order() # Order | order placed for purchasing the pet +body = petstore_api.Order() # order.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 api_response = api_instance.place_order(body) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling StoreApi->place_order: %s\n" % e) ``` @@ -208,11 +208,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**Order**](Order.md)| order placed for purchasing the pet | + **body** | [**order.Order**](Order.md)| order placed for purchasing the pet | ### Return type -[**Order**](Order.md) +[**order.Order**](Order.md) ### Authorization diff --git a/samples/client/petstore/python-experimental/docs/StringBooleanMap.md b/samples/client/petstore/python-experimental/docs/StringBooleanMap.md index 2fbf3b3767d0..2eb94fd9a73d 100644 --- a/samples/client/petstore/python-experimental/docs/StringBooleanMap.md +++ b/samples/client/petstore/python-experimental/docs/StringBooleanMap.md @@ -1,4 +1,4 @@ -# StringBooleanMap +# string_boolean_map.StringBooleanMap ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/Tag.md b/samples/client/petstore/python-experimental/docs/Tag.md index 243cd98eda69..827e9db83e35 100644 --- a/samples/client/petstore/python-experimental/docs/Tag.md +++ b/samples/client/petstore/python-experimental/docs/Tag.md @@ -1,10 +1,11 @@ -# Tag +# tag.Tag ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **int** | | [optional] **name** | **str** | | [optional] +**full_name** | **str** | | [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/TypeHolderDefault.md b/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md index 21d125a8e5f4..001509eba5f2 100644 --- a/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md +++ b/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md @@ -1,4 +1,4 @@ -# TypeHolderDefault +# type_holder_default.TypeHolderDefault a model to test optional properties with server defaults ## Properties diff --git a/samples/client/petstore/python-experimental/docs/TypeHolderExample.md b/samples/client/petstore/python-experimental/docs/TypeHolderExample.md index b74c520d447a..a681dc9440cd 100644 --- a/samples/client/petstore/python-experimental/docs/TypeHolderExample.md +++ b/samples/client/petstore/python-experimental/docs/TypeHolderExample.md @@ -1,4 +1,4 @@ -# TypeHolderExample +# type_holder_example.TypeHolderExample a model to test required properties with an example and length one enum ## Properties diff --git a/samples/client/petstore/python-experimental/docs/User.md b/samples/client/petstore/python-experimental/docs/User.md index 443ac123fdca..52ff07af2963 100644 --- a/samples/client/petstore/python-experimental/docs/User.md +++ b/samples/client/petstore/python-experimental/docs/User.md @@ -1,4 +1,4 @@ -# User +# user.User ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/docs/UserApi.md b/samples/client/petstore/python-experimental/docs/UserApi.md index d8d8b59a7d86..d93a4059c3b3 100644 --- a/samples/client/petstore/python-experimental/docs/UserApi.md +++ b/samples/client/petstore/python-experimental/docs/UserApi.md @@ -27,17 +27,17 @@ This can only be done by the logged in user. from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.UserApi() -body = petstore_api.User() # User | Created user object +body = petstore_api.User() # user.User | Created user object +# example passing only required values which don't have defaults set try: # Create user api_instance.create_user(body) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling UserApi->create_user: %s\n" % e) ``` @@ -45,7 +45,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**User**](User.md)| Created user object | + **body** | [**user.User**](User.md)| Created user object | ### Return type @@ -78,17 +78,17 @@ Creates list of users with given input array from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.UserApi() -body = [petstore_api.User()] # [User] | List of user object +body = [petstore_api.User()] # [user.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 api_instance.create_users_with_array_input(body) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling UserApi->create_users_with_array_input: %s\n" % e) ``` @@ -96,7 +96,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**[User]**](User.md)| List of user object | + **body** | [**[user.User]**](User.md)| List of user object | ### Return type @@ -129,17 +129,17 @@ Creates list of users with given input array from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.UserApi() -body = [petstore_api.User()] # [User] | List of user object +body = [petstore_api.User()] # [user.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 api_instance.create_users_with_list_input(body) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling UserApi->create_users_with_list_input: %s\n" % e) ``` @@ -147,7 +147,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**[User]**](User.md)| List of user object | + **body** | [**[user.User]**](User.md)| List of user object | ### Return type @@ -182,17 +182,17 @@ This can only be done by the logged in user. from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.UserApi() 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 api_instance.delete_user(username) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling UserApi->delete_user: %s\n" % e) ``` @@ -224,7 +224,7 @@ 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) # **get_user_by_name** -> User get_user_by_name(username) +> user.User get_user_by_name(username) Get user by user name @@ -234,18 +234,18 @@ Get user by user name from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.UserApi() 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 api_response = api_instance.get_user_by_name(username) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling UserApi->get_user_by_name: %s\n" % e) ``` @@ -257,7 +257,7 @@ Name | Type | Description | Notes ### Return type -[**User**](User.md) +[**user.User**](User.md) ### Authorization @@ -288,7 +288,6 @@ Logs user into the system from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class @@ -296,11 +295,12 @@ api_instance = petstore_api.UserApi() 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 api_response = api_instance.login_user(username, password) pprint(api_response) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling UserApi->login_user: %s\n" % e) ``` @@ -343,16 +343,16 @@ Logs out current logged in user session from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.UserApi() +# example, this endpoint has no required or optional parameters try: # Logs out current logged in user session api_instance.logout_user() -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling UserApi->logout_user: %s\n" % e) ``` @@ -392,18 +392,18 @@ This can only be done by the logged in user. from __future__ import print_function import time import petstore_api -from petstore_api.rest import ApiException from pprint import pprint # Create an instance of the API class api_instance = petstore_api.UserApi() username = 'username_example' # str | name that need to be deleted -body = petstore_api.User() # User | Updated user object +body = petstore_api.User() # user.User | Updated user object +# example passing only required values which don't have defaults set try: # Updated user api_instance.update_user(username, body) -except ApiException as e: +except petstore_api.ApiException as e: print("Exception when calling UserApi->update_user: %s\n" % e) ``` @@ -412,7 +412,7 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **str**| name that need to be deleted | - **body** | [**User**](User.md)| Updated user object | + **body** | [**user.User**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/python-experimental/docs/XmlItem.md b/samples/client/petstore/python-experimental/docs/XmlItem.md index d30ca4362293..0228e238165d 100644 --- a/samples/client/petstore/python-experimental/docs/XmlItem.md +++ b/samples/client/petstore/python-experimental/docs/XmlItem.md @@ -1,4 +1,4 @@ -# XmlItem +# xml_item.XmlItem ## Properties Name | Type | Description | Notes diff --git a/samples/client/petstore/python-experimental/petstore_api/__init__.py b/samples/client/petstore/python-experimental/petstore_api/__init__.py index 905c4d344909..4b47774e2fd8 100644 --- a/samples/client/petstore/python-experimental/petstore_api/__init__.py +++ b/samples/client/petstore/python-experimental/petstore_api/__init__.py @@ -26,12 +26,17 @@ # import ApiClient from petstore_api.api_client import ApiClient + +# import Configuration from petstore_api.configuration import Configuration + +# import exceptions from petstore_api.exceptions import OpenApiException from petstore_api.exceptions import ApiTypeError from petstore_api.exceptions import ApiValueError from petstore_api.exceptions import ApiKeyError from petstore_api.exceptions import ApiException + # import models into sdk package from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType from petstore_api.models.additional_properties_array import AdditionalPropertiesArray @@ -50,6 +55,14 @@ from petstore_api.models.cat import Cat from petstore_api.models.cat_all_of import CatAllOf from petstore_api.models.category import Category +from petstore_api.models.child import Child +from petstore_api.models.child_all_of import ChildAllOf +from petstore_api.models.child_cat import ChildCat +from petstore_api.models.child_cat_all_of import ChildCatAllOf +from petstore_api.models.child_dog import ChildDog +from petstore_api.models.child_dog_all_of import ChildDogAllOf +from petstore_api.models.child_lizard import ChildLizard +from petstore_api.models.child_lizard_all_of import ChildLizardAllOf from petstore_api.models.class_model import ClassModel from petstore_api.models.client import Client from petstore_api.models.dog import Dog @@ -60,6 +73,8 @@ from petstore_api.models.file import File from petstore_api.models.file_schema_test_class import FileSchemaTestClass from petstore_api.models.format_test import FormatTest +from petstore_api.models.grandparent import Grandparent +from petstore_api.models.grandparent_animal import GrandparentAnimal from petstore_api.models.has_only_read_only import HasOnlyReadOnly from petstore_api.models.list import List from petstore_api.models.map_test import MapTest @@ -72,6 +87,9 @@ from petstore_api.models.outer_composite import OuterComposite from petstore_api.models.outer_enum import OuterEnum from petstore_api.models.outer_number import OuterNumber +from petstore_api.models.parent import Parent +from petstore_api.models.parent_all_of import ParentAllOf +from petstore_api.models.parent_pet import ParentPet from petstore_api.models.pet import Pet from petstore_api.models.read_only_first import ReadOnlyFirst from petstore_api.models.special_model_name import SpecialModelName @@ -81,4 +99,3 @@ from petstore_api.models.type_holder_example import TypeHolderExample from petstore_api.models.user import User from petstore_api.models.xml_item import XmlItem - diff --git a/samples/client/petstore/python-experimental/petstore_api/api/another_fake_api.py b/samples/client/petstore/python-experimental/petstore_api/api/another_fake_api.py index 2a875ae78764..c8e87491d52a 100644 --- a/samples/client/petstore/python-experimental/petstore_api/api/another_fake_api.py +++ b/samples/client/petstore/python-experimental/petstore_api/api/another_fake_api.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 # python 2 and python 3 compatibility library import six @@ -33,7 +34,7 @@ str, validate_and_convert_types ) -from petstore_api.models.client import Client +from petstore_api.models import client class AnotherFakeApi(object): @@ -59,7 +60,7 @@ def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param Client body: client model (required) + :param client.Client body: client model (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -78,7 +79,7 @@ def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: Client + :return: client.Client If the method is called asynchronously, returns the request thread. """ @@ -106,7 +107,7 @@ def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501 self.call_123_test_special_tags = Endpoint( settings={ - 'response_type': (Client,), + 'response_type': (client.Client,), 'auth': [], 'endpoint_path': '/another-fake/dummy', 'operation_id': 'call_123_test_special_tags', @@ -133,7 +134,7 @@ def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (Client,), + 'body': (client.Client,), }, 'attribute_map': { }, 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 c38dac0a5b0d..31a6500d55f1 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 @@ -13,6 +13,7 @@ from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 # python 2 and python 3 compatibility library import six @@ -33,13 +34,13 @@ str, validate_and_convert_types ) -from petstore_api.models.client import Client -from petstore_api.models.file_schema_test_class import FileSchemaTestClass -from petstore_api.models.outer_composite import OuterComposite -from petstore_api.models.outer_enum import OuterEnum -from petstore_api.models.outer_number import OuterNumber -from petstore_api.models.user import User -from petstore_api.models.xml_item import XmlItem +from petstore_api.models import xml_item +from petstore_api.models import outer_composite +from petstore_api.models import outer_enum +from petstore_api.models import outer_number +from petstore_api.models import file_schema_test_class +from petstore_api.models import user +from petstore_api.models import client class FakeApi(object): @@ -65,7 +66,7 @@ def __create_xml_item(self, xml_item, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param XmlItem xml_item: XmlItem Body (required) + :param xml_item.XmlItem xml_item: XmlItem Body (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -139,7 +140,7 @@ def __create_xml_item(self, xml_item, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'xml_item': (XmlItem,), + 'xml_item': (xml_item.XmlItem,), }, 'attribute_map': { }, @@ -277,7 +278,7 @@ def __fake_outer_composite_serialize(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param OuterComposite body: Input composite as post body + :param outer_composite.OuterComposite body: Input composite as post body :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -296,7 +297,7 @@ def __fake_outer_composite_serialize(self, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: OuterComposite + :return: outer_composite.OuterComposite If the method is called asynchronously, returns the request thread. """ @@ -323,7 +324,7 @@ def __fake_outer_composite_serialize(self, **kwargs): # noqa: E501 self.fake_outer_composite_serialize = Endpoint( settings={ - 'response_type': (OuterComposite,), + 'response_type': (outer_composite.OuterComposite,), 'auth': [], 'endpoint_path': '/fake/outer/composite', 'operation_id': 'fake_outer_composite_serialize', @@ -348,7 +349,7 @@ def __fake_outer_composite_serialize(self, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (OuterComposite,), + 'body': (outer_composite.OuterComposite,), }, 'attribute_map': { }, @@ -379,7 +380,7 @@ def __fake_outer_enum_serialize(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param OuterEnum body: Input enum as post body + :param outer_enum.OuterEnum body: Input enum as post body :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -398,7 +399,7 @@ def __fake_outer_enum_serialize(self, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: OuterEnum + :return: outer_enum.OuterEnum If the method is called asynchronously, returns the request thread. """ @@ -425,7 +426,7 @@ def __fake_outer_enum_serialize(self, **kwargs): # noqa: E501 self.fake_outer_enum_serialize = Endpoint( settings={ - 'response_type': (OuterEnum,), + 'response_type': (outer_enum.OuterEnum,), 'auth': [], 'endpoint_path': '/fake/outer/enum', 'operation_id': 'fake_outer_enum_serialize', @@ -450,7 +451,7 @@ def __fake_outer_enum_serialize(self, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (OuterEnum,), + 'body': (outer_enum.OuterEnum,), }, 'attribute_map': { }, @@ -481,7 +482,7 @@ def __fake_outer_number_serialize(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param OuterNumber body: Input number as post body + :param outer_number.OuterNumber body: Input number as post body :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -500,7 +501,7 @@ def __fake_outer_number_serialize(self, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: OuterNumber + :return: outer_number.OuterNumber If the method is called asynchronously, returns the request thread. """ @@ -527,7 +528,7 @@ def __fake_outer_number_serialize(self, **kwargs): # noqa: E501 self.fake_outer_number_serialize = Endpoint( settings={ - 'response_type': (OuterNumber,), + 'response_type': (outer_number.OuterNumber,), 'auth': [], 'endpoint_path': '/fake/outer/number', 'operation_id': 'fake_outer_number_serialize', @@ -552,7 +553,7 @@ def __fake_outer_number_serialize(self, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (OuterNumber,), + 'body': (outer_number.OuterNumber,), }, 'attribute_map': { }, @@ -685,7 +686,7 @@ def __test_body_with_file_schema(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param FileSchemaTestClass body: (required) + :param file_schema_test_class.FileSchemaTestClass body: (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -759,7 +760,7 @@ def __test_body_with_file_schema(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (FileSchemaTestClass,), + 'body': (file_schema_test_class.FileSchemaTestClass,), }, 'attribute_map': { }, @@ -790,7 +791,7 @@ def __test_body_with_query_params(self, query, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. :param str query: (required) - :param User body: (required) + :param user.User body: (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -868,7 +869,7 @@ def __test_body_with_query_params(self, query, body, **kwargs): # noqa: E501 }, 'openapi_types': { 'query': (str,), - 'body': (User,), + 'body': (user.User,), }, 'attribute_map': { 'query': 'query', @@ -901,7 +902,7 @@ def __test_client_model(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param Client body: client model (required) + :param client.Client body: client model (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -920,7 +921,7 @@ def __test_client_model(self, body, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: Client + :return: client.Client If the method is called asynchronously, returns the request thread. """ @@ -948,7 +949,7 @@ def __test_client_model(self, body, **kwargs): # noqa: E501 self.test_client_model = Endpoint( settings={ - 'response_type': (Client,), + 'response_type': (client.Client,), 'auth': [], 'endpoint_path': '/fake', 'operation_id': 'test_client_model', @@ -975,7 +976,7 @@ def __test_client_model(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (Client,), + 'body': (client.Client,), }, 'attribute_map': { }, diff --git a/samples/client/petstore/python-experimental/petstore_api/api/fake_classname_tags_123_api.py b/samples/client/petstore/python-experimental/petstore_api/api/fake_classname_tags_123_api.py index 459318014230..b10c7cd39150 100644 --- a/samples/client/petstore/python-experimental/petstore_api/api/fake_classname_tags_123_api.py +++ b/samples/client/petstore/python-experimental/petstore_api/api/fake_classname_tags_123_api.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 # python 2 and python 3 compatibility library import six @@ -33,7 +34,7 @@ str, validate_and_convert_types ) -from petstore_api.models.client import Client +from petstore_api.models import client class FakeClassnameTags123Api(object): @@ -59,7 +60,7 @@ def __test_classname(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param Client body: client model (required) + :param client.Client body: client model (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -78,7 +79,7 @@ def __test_classname(self, body, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: Client + :return: client.Client If the method is called asynchronously, returns the request thread. """ @@ -106,7 +107,7 @@ def __test_classname(self, body, **kwargs): # noqa: E501 self.test_classname = Endpoint( settings={ - 'response_type': (Client,), + 'response_type': (client.Client,), 'auth': [ 'api_key_query' ], @@ -135,7 +136,7 @@ def __test_classname(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (Client,), + 'body': (client.Client,), }, 'attribute_map': { }, diff --git a/samples/client/petstore/python-experimental/petstore_api/api/pet_api.py b/samples/client/petstore/python-experimental/petstore_api/api/pet_api.py index ba58ba92a814..e7e1cf19c009 100644 --- a/samples/client/petstore/python-experimental/petstore_api/api/pet_api.py +++ b/samples/client/petstore/python-experimental/petstore_api/api/pet_api.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 # python 2 and python 3 compatibility library import six @@ -33,8 +34,8 @@ str, validate_and_convert_types ) -from petstore_api.models.api_response import ApiResponse -from petstore_api.models.pet import Pet +from petstore_api.models import pet +from petstore_api.models import api_response class PetApi(object): @@ -59,7 +60,7 @@ def __add_pet(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param Pet body: Pet object that needs to be added to the store (required) + :param pet.Pet body: Pet object that needs to be added to the store (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -135,7 +136,7 @@ def __add_pet(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (Pet,), + 'body': (pet.Pet,), }, 'attribute_map': { }, @@ -296,7 +297,7 @@ def __find_pets_by_status(self, status, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: [Pet] + :return: [pet.Pet] If the method is called asynchronously, returns the request thread. """ @@ -324,7 +325,7 @@ def __find_pets_by_status(self, status, **kwargs): # noqa: E501 self.find_pets_by_status = Endpoint( settings={ - 'response_type': ([Pet],), + 'response_type': ([pet.Pet],), 'auth': [ 'petstore_auth' ], @@ -413,7 +414,7 @@ def __find_pets_by_tags(self, tags, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: [Pet] + :return: [pet.Pet] If the method is called asynchronously, returns the request thread. """ @@ -441,7 +442,7 @@ def __find_pets_by_tags(self, tags, **kwargs): # noqa: E501 self.find_pets_by_tags = Endpoint( settings={ - 'response_type': ([Pet],), + 'response_type': ([pet.Pet],), 'auth': [ 'petstore_auth' ], @@ -523,7 +524,7 @@ def __get_pet_by_id(self, pet_id, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: Pet + :return: pet.Pet If the method is called asynchronously, returns the request thread. """ @@ -551,7 +552,7 @@ def __get_pet_by_id(self, pet_id, **kwargs): # noqa: E501 self.get_pet_by_id = Endpoint( settings={ - 'response_type': (Pet,), + 'response_type': (pet.Pet,), 'auth': [ 'api_key' ], @@ -612,7 +613,7 @@ def __update_pet(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param Pet body: Pet object that needs to be added to the store (required) + :param pet.Pet body: Pet object that needs to be added to the store (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -688,7 +689,7 @@ def __update_pet(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (Pet,), + 'body': (pet.Pet,), }, 'attribute_map': { }, @@ -858,7 +859,7 @@ def __upload_file(self, pet_id, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: ApiResponse + :return: api_response.ApiResponse If the method is called asynchronously, returns the request thread. """ @@ -886,7 +887,7 @@ def __upload_file(self, pet_id, **kwargs): # noqa: E501 self.upload_file = Endpoint( settings={ - 'response_type': (ApiResponse,), + 'response_type': (api_response.ApiResponse,), 'auth': [ 'petstore_auth' ], @@ -982,7 +983,7 @@ def __upload_file_with_required_file(self, pet_id, required_file, **kwargs): # :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: ApiResponse + :return: api_response.ApiResponse If the method is called asynchronously, returns the request thread. """ @@ -1011,7 +1012,7 @@ def __upload_file_with_required_file(self, pet_id, required_file, **kwargs): # self.upload_file_with_required_file = Endpoint( settings={ - 'response_type': (ApiResponse,), + 'response_type': (api_response.ApiResponse,), 'auth': [ 'petstore_auth' ], diff --git a/samples/client/petstore/python-experimental/petstore_api/api/store_api.py b/samples/client/petstore/python-experimental/petstore_api/api/store_api.py index cdeebcce432c..bb1367b167e9 100644 --- a/samples/client/petstore/python-experimental/petstore_api/api/store_api.py +++ b/samples/client/petstore/python-experimental/petstore_api/api/store_api.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 # python 2 and python 3 compatibility library import six @@ -33,7 +34,7 @@ str, validate_and_convert_types ) -from petstore_api.models.order import Order +from petstore_api.models import order class StoreApi(object): @@ -282,7 +283,7 @@ def __get_order_by_id(self, order_id, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: Order + :return: order.Order If the method is called asynchronously, returns the request thread. """ @@ -310,7 +311,7 @@ def __get_order_by_id(self, order_id, **kwargs): # noqa: E501 self.get_order_by_id = Endpoint( settings={ - 'response_type': (Order,), + 'response_type': (order.Order,), 'auth': [], 'endpoint_path': '/store/order/{order_id}', 'operation_id': 'get_order_by_id', @@ -375,7 +376,7 @@ def __place_order(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param Order body: order placed for purchasing the pet (required) + :param order.Order body: order placed for purchasing the pet (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -394,7 +395,7 @@ def __place_order(self, body, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: Order + :return: order.Order If the method is called asynchronously, returns the request thread. """ @@ -422,7 +423,7 @@ def __place_order(self, body, **kwargs): # noqa: E501 self.place_order = Endpoint( settings={ - 'response_type': (Order,), + 'response_type': (order.Order,), 'auth': [], 'endpoint_path': '/store/order', 'operation_id': 'place_order', @@ -449,7 +450,7 @@ def __place_order(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (Order,), + 'body': (order.Order,), }, 'attribute_map': { }, diff --git a/samples/client/petstore/python-experimental/petstore_api/api/user_api.py b/samples/client/petstore/python-experimental/petstore_api/api/user_api.py index 3e668cf374b5..17e2428b84c7 100644 --- a/samples/client/petstore/python-experimental/petstore_api/api/user_api.py +++ b/samples/client/petstore/python-experimental/petstore_api/api/user_api.py @@ -13,6 +13,7 @@ from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 # python 2 and python 3 compatibility library import six @@ -33,7 +34,7 @@ str, validate_and_convert_types ) -from petstore_api.models.user import User +from petstore_api.models import user class UserApi(object): @@ -59,7 +60,7 @@ def __create_user(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param User body: Created user object (required) + :param user.User body: Created user object (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -133,7 +134,7 @@ def __create_user(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': (User,), + 'body': (user.User,), }, 'attribute_map': { }, @@ -161,7 +162,7 @@ def __create_users_with_array_input(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param [User] body: List of user object (required) + :param [user.User] body: List of user object (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -235,7 +236,7 @@ def __create_users_with_array_input(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': ([User],), + 'body': ([user.User],), }, 'attribute_map': { }, @@ -263,7 +264,7 @@ def __create_users_with_list_input(self, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. - :param [User] body: List of user object (required) + :param [user.User] body: List of user object (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -337,7 +338,7 @@ def __create_users_with_list_input(self, body, **kwargs): # noqa: E501 'allowed_values': { }, 'openapi_types': { - 'body': ([User],), + 'body': ([user.User],), }, 'attribute_map': { }, @@ -488,7 +489,7 @@ def __get_user_by_name(self, username, **kwargs): # noqa: E501 :param _host_index: integer specifying the index of the server that we want to use. Default is 0. - :return: User + :return: user.User If the method is called asynchronously, returns the request thread. """ @@ -516,7 +517,7 @@ def __get_user_by_name(self, username, **kwargs): # noqa: E501 self.get_user_by_name = Endpoint( settings={ - 'response_type': (User,), + 'response_type': (user.User,), 'auth': [], 'endpoint_path': '/user/{username}', 'operation_id': 'get_user_by_name', @@ -785,7 +786,7 @@ def __update_user(self, username, body, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously Default is False. :param str username: name that need to be deleted (required) - :param User body: Updated user object (required) + :param user.User body: Updated user object (required) :param _return_http_data_only: response data without head status code and headers. Default is True. :param _preload_content: if False, the urllib3.HTTPResponse object @@ -863,7 +864,7 @@ def __update_user(self, username, body, **kwargs): # noqa: E501 }, 'openapi_types': { 'username': (str,), - 'body': (User,), + 'body': (user.User,), }, 'attribute_map': { 'username': 'username', diff --git a/samples/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/client/petstore/python-experimental/petstore_api/model_utils.py index 22d9ee459de7..5deb24585396 100644 --- a/samples/client/petstore/python-experimental/petstore_api/model_utils.py +++ b/samples/client/petstore/python-experimental/petstore_api/model_utils.py @@ -10,10 +10,10 @@ """ -import copy from datetime import date, datetime # noqa: F401 import inspect import os +import pprint import re import tempfile @@ -46,30 +46,297 @@ class OpenApiModel(object): """The base class for all OpenAPIModels""" + def set_attribute(self, name, value): + # this is only used to set properties on self + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + + if name in self.openapi_types: + required_types_mixed = self.openapi_types[name] + elif self.additional_properties_type is None: + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + elif self.additional_properties_type is not None: + required_types_mixed = self.additional_properties_type + + if get_simple_class(name) != str: + error_msg = type_error_message( + var_name=name, + var_value=name, + valid_classes=(str,), + key_type=True + ) + raise ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=(str,), + key_type=True + ) + + if self._check_type: + value = validate_and_convert_types( + value, required_types_mixed, path_to_item, self._from_server, + self._check_type, configuration=self._configuration) + if (name,) in self.allowed_values: + check_allowed_values( + self.allowed_values, + (name,), + value + ) + if (name,) in self.validations: + check_validations( + self.validations, + (name,), + value + ) + self.__dict__['_data_store'][name] = value + + def __setitem__(self, name, value): + """this allows us to set values with instance[field_name] = val""" + self.__setattr__(name, value) + + def __getitem__(self, name): + """this allows us to get a value with val = instance[field_name]""" + return self.__getattr__(name) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other + class ModelSimple(OpenApiModel): """the parent class of models whose type != object in their swagger/openapi""" + def __setattr__(self, name, value): + """this allows us to set a value with instance.field_name = val""" + if name in self.required_properties: + self.__dict__[name] = value + return + + self.set_attribute(name, value) + + def __getattr__(self, name): + """this allows us to get a value with val = instance.field_name""" + if name in self.required_properties: + return self.__dict__[name] + + if name in self.__dict__['_data_store']: + return self.__dict__['_data_store'][name] + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + [name] + ) + + def to_str(self): + """Returns the string representation of the model""" + return str(self.value) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + this_val = self._data_store['value'] + that_val = other._data_store['value'] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True + class ModelNormal(OpenApiModel): """the parent class of models whose type == object in their swagger/openapi""" + def __setattr__(self, name, value): + """this allows us to set a value with instance.field_name = val""" + if name in self.required_properties: + self.__dict__[name] = value + return + + self.set_attribute(name, value) + + def __getattr__(self, name): + """this allows us to get a value with val = instance.field_name""" + if name in self.required_properties: + return self.__dict__[name] + + if name in self.__dict__['_data_store']: + return self.__dict__['_data_store'][name] + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + [name] + ) + + def to_dict(self): + """Returns the model properties as a dict""" + return model_to_dict(self, serialize=False) + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + if not set(self._data_store.keys()) == set(other._data_store.keys()): + return False + for _var_name, this_val in six.iteritems(self._data_store): + that_val = other._data_store[_var_name] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if (not six.PY3 and + len(types) == 2 and unicode in types): # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True + + +class ModelComposed(OpenApiModel): + """the parent class of models whose type == object in their + swagger/openapi and have oneOf/allOf/anyOf""" + + def __setattr__(self, name, value): + """this allows us to set a value with instance.field_name = val""" + if name in self.required_properties: + self.__dict__[name] = value + return + + # set the attribute on the correct instance + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + if model_instances: + for model_instance in model_instances: + if model_instance == self: + self.set_attribute(name, value) + else: + setattr(model_instance, name, value) + if name not in self._var_name_to_model_instances: + # we assigned an additional property + self.__dict__['_var_name_to_model_instances'][name] = ( + model_instance + ) + return None + + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + + def __getattr__(self, name): + """this allows us to get a value with val = instance.field_name""" + if name in self.required_properties: + return self.__dict__[name] + + # get the attribute from the correct instance + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) + path_to_item = [] + if self._path_to_item: + path_to_item.extend(self._path_to_item) + path_to_item.append(name) + if model_instances: + values = set() + for model_instance in model_instances: + if name in model_instance._data_store: + values.add(model_instance._data_store[name]) + if len(values) == 1: + return list(values)[0] + raise ApiValueError( + "Values stored for property {0} in {1} difffer when looking " + "at self and self's composed instances. All values must be " + "the same".format(name, type(self).__name__), + path_to_item + ) + + raise ApiKeyError( + "{0} has no key '{1}'".format(type(self).__name__, name), + path_to_item + ) + + def to_dict(self): + """Returns the model properties as a dict""" + return model_to_dict(self, serialize=False) + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, self.__class__): + return False + + if not set(self._data_store.keys()) == set(other._data_store.keys()): + return False + for _var_name, this_val in six.iteritems(self._data_store): + that_val = other._data_store[_var_name] + types = set() + types.add(this_val.__class__) + types.add(that_val.__class__) + vals_equal = this_val == that_val + if (not six.PY3 and + len(types) == 2 and unicode in types): # noqa: F821 + vals_equal = ( + this_val.encode('utf-8') == that_val.encode('utf-8') + ) + if not vals_equal: + return False + return True + COERCION_INDEX_BY_TYPE = { - ModelNormal: 0, - ModelSimple: 1, - none_type: 2, - list: 3, - dict: 4, - float: 5, - int: 6, - bool: 7, - datetime: 8, - date: 9, - str: 10, - file_type: 11, + ModelComposed: 0, + ModelNormal: 1, + ModelSimple: 2, + none_type: 3, + list: 4, + dict: 5, + float: 6, + int: 7, + bool: 8, + datetime: 9, + date: 10, + str: 11, + file_type: 12, } # these are used to limit what type conversions we try to do @@ -78,6 +345,8 @@ class ModelNormal(OpenApiModel): UPCONVERSION_TYPE_PAIRS = ( (str, datetime), (str, date), + (list, ModelComposed), + (dict, ModelComposed), (list, ModelNormal), (dict, ModelNormal), (str, ModelSimple), @@ -88,6 +357,8 @@ class ModelNormal(OpenApiModel): COERCIBLE_TYPE_PAIRS = { False: ( # client instantiation of a model with client data + # (dict, ModelComposed), + # (list, ModelComposed), # (dict, ModelNormal), # (list, ModelNormal), # (str, ModelSimple), @@ -102,6 +373,8 @@ class ModelNormal(OpenApiModel): # (float, str), ), True: ( # server -> client data + (dict, ModelComposed), + (list, ModelComposed), (dict, ModelNormal), (list, ModelNormal), (str, ModelSimple), @@ -344,6 +617,9 @@ def index_getter(class_or_instance): return COERCION_INDEX_BY_TYPE[list] elif isinstance(class_or_instance, dict): return COERCION_INDEX_BY_TYPE[dict] + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelComposed)): + return COERCION_INDEX_BY_TYPE[ModelComposed] elif (inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelNormal)): return COERCION_INDEX_BY_TYPE[ModelNormal] @@ -385,7 +661,9 @@ def remove_uncoercible(required_types_classes, current_item, from_server, # convert our models to OpenApiModel required_type_class_simplified = required_type_class if isinstance(required_type_class_simplified, type): - if issubclass(required_type_class_simplified, ModelNormal): + if issubclass(required_type_class_simplified, ModelComposed): + required_type_class_simplified = ModelComposed + elif issubclass(required_type_class_simplified, ModelNormal): required_type_class_simplified = ModelNormal elif issubclass(required_type_class_simplified, ModelSimple): required_type_class_simplified = ModelSimple @@ -522,6 +800,21 @@ def deserialize_primitive(data, klass, path_to_item): ) +def fix_model_input_data(model_data, model_class): + # this is only called on classes where the input data is a dict + fixed_model_data = change_keys_js_to_python( + model_data, + model_class + ) + if model_class._composed_schemas() is not None: + for allof_class in model_class._composed_schemas()['allOf']: + fixed_model_data = change_keys_js_to_python( + fixed_model_data, + allof_class + ) + return fixed_model_data + + def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, from_server): """Deserializes model_data to model instance. @@ -544,42 +837,29 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, ApiValueError ApiKeyError """ - fixed_model_data = copy.deepcopy(model_data) - - if isinstance(fixed_model_data, dict): - fixed_model_data = change_keys_js_to_python(fixed_model_data, - model_class) kw_args = dict(_check_type=check_type, _path_to_item=path_to_item, _configuration=configuration, _from_server=from_server) - if hasattr(model_class, 'get_real_child_model'): - # discriminator case - discriminator_class = model_class.get_real_child_model(model_data) - if discriminator_class: - if isinstance(model_data, list): - instance = discriminator_class(*model_data, **kw_args) - elif isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python( - fixed_model_data, - discriminator_class - ) - kw_args.update(fixed_model_data) - instance = discriminator_class(**kw_args) - else: - # all other cases - if isinstance(model_data, list): - instance = model_class(*model_data, **kw_args) - if isinstance(model_data, dict): - fixed_model_data = change_keys_js_to_python(fixed_model_data, - model_class) - kw_args.update(fixed_model_data) - instance = model_class(**kw_args) - else: - instance = model_class(model_data, **kw_args) - + used_model_class = model_class + if model_class.discriminator() is not None: + used_model_class = model_class.get_discriminator_class( + from_server, model_data) + + if issubclass(used_model_class, ModelSimple): + instance = used_model_class(value=model_data, **kw_args) + return instance + if isinstance(model_data, list): + instance = used_model_class(*model_data, **kw_args) + if isinstance(model_data, dict): + fixed_model_data = change_keys_js_to_python( + model_data, + used_model_class + ) + kw_args.update(fixed_model_data) + instance = used_model_class(**kw_args) return instance @@ -634,7 +914,7 @@ def attempt_convert_item(input_value, valid_classes, path_to_item, key_type (bool): if True we need to convert a key type (not supported) must_convert (bool): if True we must convert check_type (bool): if True we check the type or the returned data in - ModelNormal and ModelSimple instances + ModelComposed/ModelNormal/ModelSimple instances Returns: instance (any) the fixed item @@ -798,27 +1078,31 @@ def model_to_dict(model_instance, serialize=True): """ result = {} - for attr, value in six.iteritems(model_instance._data_store): - if serialize: - # we use get here because additional property key names do not - # exist in attribute_map - attr = model_instance.attribute_map.get(attr, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: model_to_dict(x, serialize=serialize) - if hasattr(x, '_data_store') else x, value - )) - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], - model_to_dict(item[1], serialize=serialize)) - if hasattr(item[1], '_data_store') else item, - value.items() - )) - elif hasattr(value, '_data_store'): - result[attr] = model_to_dict(value, serialize=serialize) - else: - result[attr] = value + model_instances = [model_instance] + if model_instance._composed_schemas() is not None: + model_instances = model_instance._composed_instances + for model_instance in model_instances: + for attr, value in six.iteritems(model_instance._data_store): + if serialize: + # we use get here because additional property key names do not + # exist in attribute_map + attr = model_instance.attribute_map.get(attr, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: model_to_dict(x, serialize=serialize) + if hasattr(x, '_data_store') else x, value + )) + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], + model_to_dict(item[1], serialize=serialize)) + if hasattr(item[1], '_data_store') else item, + value.items() + )) + elif hasattr(value, '_data_store'): + result[attr] = model_to_dict(value, serialize=serialize) + else: + result[attr] = value return result @@ -874,3 +1158,235 @@ def get_py3_class_name(input_class): elif input_class == int: return 'int' return input_class.__name__ + + +def get_allof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + composed_instances (list) + """ + composed_instances = [] + for allof_class in self._composed_schemas()['allOf']: + + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python( + model_args, allof_class) + + # extract a dict of only required keys from fixed_model_args + kwargs = {} + var_names = set(allof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + allof_instance = allof_class(**kwargs) + composed_instances.append(allof_instance) + return composed_instances + + +def get_oneof_instance(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + oneof_instance (instance) + """ + oneof_instance = None + if len(self._composed_schemas()['oneOf']) == 0: + return oneof_instance + + for oneof_class in self._composed_schemas()['oneOf']: + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python( + model_args, oneof_class) + + # extract a dict of only required keys from fixed_model_args + kwargs = {} + var_names = set(oneof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + try: + oneof_instance = oneof_class(**kwargs) + break + except Exception: + pass + if oneof_instance is None: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Unable to " + "make any instances of the classes in oneOf definition." % + self.__class__.__name__ + ) + return oneof_instance + + +def get_anyof_instances(self, model_args, constant_args): + """ + Args: + self: the class we are handling + model_args (dict): var_name to var_value + used to make instances + constant_args (dict): var_name to var_value + used to make instances + + Returns + anyof_instances (list) + """ + anyof_instances = [] + if len(self._composed_schemas()['anyOf']) == 0: + return anyof_instances + + for anyof_class in self._composed_schemas()['anyOf']: + # transform js keys to python keys in fixed_model_args + fixed_model_args = change_keys_js_to_python(model_args, anyof_class) + + # extract a dict of only required keys from these_model_vars + kwargs = {} + var_names = set(anyof_class.openapi_types.keys()) + for var_name in var_names: + if var_name in fixed_model_args: + kwargs[var_name] = fixed_model_args[var_name] + + # and use it to make the instance + kwargs.update(constant_args) + try: + anyof_instance = anyof_class(**kwargs) + anyof_instances.append(anyof_instance) + except Exception: + pass + if len(anyof_instances) == 0: + raise ApiValueError( + "Invalid inputs given to generate an instance of %s. Unable to " + "make any instances of the classes in anyOf definition." % + self.__class__.__name__ + ) + return anyof_instances + + +def get_additional_properties_model_instances( + composed_instances, self): + additional_properties_model_instances = [] + all_instances = [self] + all_instances.extend(composed_instances) + for instance in all_instances: + if instance.additional_properties_type is not None: + additional_properties_model_instances.append(instance) + return additional_properties_model_instances + + +def get_var_name_to_model_instances(self, composed_instances): + var_name_to_model_instances = {} + all_instances = [self] + all_instances.extend(composed_instances) + for instance in all_instances: + for var_name in instance.openapi_types: + if var_name not in var_name_to_model_instances: + var_name_to_model_instances[var_name] = [instance] + else: + var_name_to_model_instances[var_name].append(instance) + return var_name_to_model_instances + + +def get_unused_args(self, composed_instances, model_args): + unused_args = dict(model_args) + # arguments apssed to self were already converted to python names + # before __init__ was called + for var_name_py in self.attribute_map: + if var_name_py in unused_args: + del unused_args[var_name_py] + for instance in composed_instances: + if instance.__class__ in self._composed_schemas()['allOf']: + for var_name_py in instance.attribute_map: + if var_name_py in unused_args: + del unused_args[var_name_py] + else: + for var_name_js in instance.attribute_map.values(): + if var_name_js in unused_args: + del unused_args[var_name_js] + return unused_args + + +def validate_get_composed_info(constant_args, model_args, self): + """ + For composed schemas/classes, validates the classes to make sure that + they do not share any of the same parameters. If there is no collision + then composed model instances are created and returned tot the calling + self model + + Args: + constant_args (dict): these are the args that every model requires + model_args (dict): these are the required and optional spec args that + were passed in to make this model + self (class): the class that we are instantiating + This class contains self._composed_schemas() + + Returns: + composed_info (list): length three + composed_instances (list): the composed instances which are not + self + var_name_to_model_instances (dict): a dict going from var_name + to the model_instance which holds that var_name + the model_instance may be self or an instance of one of the + classes in self.composed_instances() + additional_properties_model_instances (list): a list of the + model instances which have the property + additional_properties_type. This list can include self + """ + # create composed_instances + composed_instances = [] + allof_instances = get_allof_instances(self, model_args, constant_args) + composed_instances.extend(allof_instances) + oneof_instance = get_oneof_instance(self, model_args, constant_args) + if oneof_instance is not None: + composed_instances.append(oneof_instance) + anyof_instances = get_anyof_instances(self, model_args, constant_args) + composed_instances.extend(anyof_instances) + + # map variable names to composed_instances + var_name_to_model_instances = get_var_name_to_model_instances( + self, composed_instances) + + # set additional_properties_model_instances + additional_properties_model_instances = ( + get_additional_properties_model_instances(composed_instances, self) + ) + + # set any remaining values + unused_args = get_unused_args(self, composed_instances, model_args) + if len(unused_args) > 0: + if len(additional_properties_model_instances) == 0: + raise ApiValueError( + "Invalid input arguments input when making an instance of " + "class %s. Not all inputs were used. The unused input data " + "is %s" % (self.__class__.__name__, unused_args) + ) + for var_name, var_value in six.iteritems(unused_args): + for instance in additional_properties_model_instances: + setattr(instance, var_name, var_value) + # no need to add additional_properties to var_name_to_model_instances here + # because additional_properties_model_instances will direct us to that + # instance when we use getattr or setattr + # and we update var_name_to_model_instances in setattr + + return [ + composed_instances, + var_name_to_model_instances, + additional_properties_model_instances + ] diff --git a/samples/client/petstore/python-experimental/petstore_api/models/__init__.py b/samples/client/petstore/python-experimental/petstore_api/models/__init__.py index 1f2bb89aa33d..e02c66519259 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/__init__.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/__init__.py @@ -11,54 +11,5 @@ """ -from __future__ import absolute_import - -# import models into model package -from petstore_api.models.additional_properties_any_type import AdditionalPropertiesAnyType -from petstore_api.models.additional_properties_array import AdditionalPropertiesArray -from petstore_api.models.additional_properties_boolean import AdditionalPropertiesBoolean -from petstore_api.models.additional_properties_class import AdditionalPropertiesClass -from petstore_api.models.additional_properties_integer import AdditionalPropertiesInteger -from petstore_api.models.additional_properties_number import AdditionalPropertiesNumber -from petstore_api.models.additional_properties_object import AdditionalPropertiesObject -from petstore_api.models.additional_properties_string import AdditionalPropertiesString -from petstore_api.models.animal import Animal -from petstore_api.models.api_response import ApiResponse -from petstore_api.models.array_of_array_of_number_only import ArrayOfArrayOfNumberOnly -from petstore_api.models.array_of_number_only import ArrayOfNumberOnly -from petstore_api.models.array_test import ArrayTest -from petstore_api.models.capitalization import Capitalization -from petstore_api.models.cat import Cat -from petstore_api.models.cat_all_of import CatAllOf -from petstore_api.models.category import Category -from petstore_api.models.class_model import ClassModel -from petstore_api.models.client import Client -from petstore_api.models.dog import Dog -from petstore_api.models.dog_all_of import DogAllOf -from petstore_api.models.enum_arrays import EnumArrays -from petstore_api.models.enum_class import EnumClass -from petstore_api.models.enum_test import EnumTest -from petstore_api.models.file import File -from petstore_api.models.file_schema_test_class import FileSchemaTestClass -from petstore_api.models.format_test import FormatTest -from petstore_api.models.has_only_read_only import HasOnlyReadOnly -from petstore_api.models.list import List -from petstore_api.models.map_test import MapTest -from petstore_api.models.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass -from petstore_api.models.model200_response import Model200Response -from petstore_api.models.model_return import ModelReturn -from petstore_api.models.name import Name -from petstore_api.models.number_only import NumberOnly -from petstore_api.models.order import Order -from petstore_api.models.outer_composite import OuterComposite -from petstore_api.models.outer_enum import OuterEnum -from petstore_api.models.outer_number import OuterNumber -from petstore_api.models.pet import Pet -from petstore_api.models.read_only_first import ReadOnlyFirst -from petstore_api.models.special_model_name import SpecialModelName -from petstore_api.models.string_boolean_map import StringBooleanMap -from petstore_api.models.tag import Tag -from petstore_api.models.type_holder_default import TypeHolderDefault -from petstore_api.models.type_holder_example import TypeHolderExample -from petstore_api.models.user import User -from petstore_api.models.xml_item import XmlItem +# we can not import model classes here because that would create a circular +# reference which would not work in python2 diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py index 16b3e933e7fe..e3bdd37fcc98 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_any_type.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class AdditionalPropertiesAnyType(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name' # noqa: E501 - } - openapi_types = { 'name': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class AdditionalPropertiesAnyType(ModelNormal): additional_properties_type = (bool, date, datetime, dict, float, int, list, str,) # noqa: E501 - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """AdditionalPropertiesAnyType - a model defined in OpenAPI + """additional_properties_any_type.AdditionalPropertiesAnyType - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. name (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this AdditionalPropertiesAnyType. # noqa: E501 - - Returns: - (str): The name of this AdditionalPropertiesAnyType. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this AdditionalPropertiesAnyType. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, AdditionalPropertiesAnyType): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py index 91e75256f551..12f228e9ba9d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_array.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class AdditionalPropertiesArray(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name' # noqa: E501 - } - openapi_types = { 'name': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class AdditionalPropertiesArray(ModelNormal): additional_properties_type = ([bool, date, datetime, dict, float, int, list, str],) # noqa: E501 - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """AdditionalPropertiesArray - a model defined in OpenAPI + """additional_properties_array.AdditionalPropertiesArray - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. name (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this AdditionalPropertiesArray. # noqa: E501 - - Returns: - (str): The name of this AdditionalPropertiesArray. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this AdditionalPropertiesArray. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, AdditionalPropertiesArray): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py index ee30aacc80bf..ed37ef90c4f6 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_boolean.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class AdditionalPropertiesBoolean(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name' # noqa: E501 - } - openapi_types = { 'name': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class AdditionalPropertiesBoolean(ModelNormal): additional_properties_type = (bool,) # noqa: E501 - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """AdditionalPropertiesBoolean - a model defined in OpenAPI + """additional_properties_boolean.AdditionalPropertiesBoolean - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. name (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this AdditionalPropertiesBoolean. # noqa: E501 - - Returns: - (str): The name of this AdditionalPropertiesBoolean. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this AdditionalPropertiesBoolean. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, AdditionalPropertiesBoolean): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py index 407b63975b78..3f34d95684b1 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_class.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,20 +59,6 @@ class AdditionalPropertiesClass(ModelNormal): allowed_values = { } - attribute_map = { - 'map_string': 'map_string', # noqa: E501 - 'map_number': 'map_number', # noqa: E501 - 'map_integer': 'map_integer', # noqa: E501 - 'map_boolean': 'map_boolean', # noqa: E501 - 'map_array_integer': 'map_array_integer', # noqa: E501 - 'map_array_anytype': 'map_array_anytype', # noqa: E501 - 'map_map_string': 'map_map_string', # noqa: E501 - 'map_map_anytype': 'map_map_anytype', # noqa: E501 - 'anytype_1': 'anytype_1', # noqa: E501 - 'anytype_2': 'anytype_2', # noqa: E501 - 'anytype_3': 'anytype_3' # noqa: E501 - } - openapi_types = { 'map_string': ({str: (str,)},), # noqa: E501 'map_number': ({str: (float,)},), # noqa: E501 @@ -100,10 +78,38 @@ class AdditionalPropertiesClass(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'map_string': 'map_string', # noqa: E501 + 'map_number': 'map_number', # noqa: E501 + 'map_integer': 'map_integer', # noqa: E501 + 'map_boolean': 'map_boolean', # noqa: E501 + 'map_array_integer': 'map_array_integer', # noqa: E501 + 'map_array_anytype': 'map_array_anytype', # noqa: E501 + 'map_map_string': 'map_map_string', # noqa: E501 + 'map_map_anytype': 'map_map_anytype', # noqa: E501 + 'anytype_1': 'anytype_1', # noqa: E501 + 'anytype_2': 'anytype_2', # noqa: E501 + 'anytype_3': 'anytype_3', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """AdditionalPropertiesClass - a model defined in OpenAPI + """additional_properties_class.AdditionalPropertiesClass - a model defined in OpenAPI Keyword Args: @@ -132,6 +138,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf anytype_2 (bool, date, datetime, dict, float, int, list, str): [optional] # noqa: E501 anytype_3 (bool, date, datetime, dict, float, int, list, str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -139,276 +146,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def map_string(self): - """Gets the map_string of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: (str,)}): The map_string of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map_string') - - @map_string.setter - def map_string(self, value): - """Sets the map_string of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map_string', value) - - @property - def map_number(self): - """Gets the map_number of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: (float,)}): The map_number of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map_number') - - @map_number.setter - def map_number(self, value): - """Sets the map_number of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map_number', value) - - @property - def map_integer(self): - """Gets the map_integer of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: (int,)}): The map_integer of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map_integer') - - @map_integer.setter - def map_integer(self, value): - """Sets the map_integer of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map_integer', value) - - @property - def map_boolean(self): - """Gets the map_boolean of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: (bool,)}): The map_boolean of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map_boolean') - - @map_boolean.setter - def map_boolean(self, value): - """Sets the map_boolean of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map_boolean', value) - - @property - def map_array_integer(self): - """Gets the map_array_integer of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: ([int],)}): The map_array_integer of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map_array_integer') - - @map_array_integer.setter - def map_array_integer(self, value): - """Sets the map_array_integer of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map_array_integer', value) - - @property - def map_array_anytype(self): - """Gets the map_array_anytype of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: ([bool, date, datetime, dict, float, int, list, str],)}): The map_array_anytype of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map_array_anytype') - - @map_array_anytype.setter - def map_array_anytype(self, value): - """Sets the map_array_anytype of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map_array_anytype', value) - - @property - def map_map_string(self): - """Gets the map_map_string of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: ({str: (str,)},)}): The map_map_string of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map_map_string') - - @map_map_string.setter - def map_map_string(self, value): - """Sets the map_map_string of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map_map_string', value) - - @property - def map_map_anytype(self): - """Gets the map_map_anytype of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)}): The map_map_anytype of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map_map_anytype') - - @map_map_anytype.setter - def map_map_anytype(self, value): - """Sets the map_map_anytype of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map_map_anytype', value) - - @property - def anytype_1(self): - """Gets the anytype_1 of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - (bool, date, datetime, dict, float, int, list, str): The anytype_1 of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('anytype_1') - - @anytype_1.setter - def anytype_1(self, value): - """Sets the anytype_1 of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('anytype_1', value) - - @property - def anytype_2(self): - """Gets the anytype_2 of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - (bool, date, datetime, dict, float, int, list, str): The anytype_2 of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('anytype_2') - - @anytype_2.setter - def anytype_2(self, value): - """Sets the anytype_2 of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('anytype_2', value) - - @property - def anytype_3(self): - """Gets the anytype_3 of this AdditionalPropertiesClass. # noqa: E501 - - Returns: - (bool, date, datetime, dict, float, int, list, str): The anytype_3 of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('anytype_3') - - @anytype_3.setter - def anytype_3(self, value): - """Sets the anytype_3 of this AdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('anytype_3', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, AdditionalPropertiesClass): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py index 558f48422a43..653350f6b55d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_integer.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class AdditionalPropertiesInteger(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name' # noqa: E501 - } - openapi_types = { 'name': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class AdditionalPropertiesInteger(ModelNormal): additional_properties_type = (int,) # noqa: E501 - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """AdditionalPropertiesInteger - a model defined in OpenAPI + """additional_properties_integer.AdditionalPropertiesInteger - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. name (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this AdditionalPropertiesInteger. # noqa: E501 - - Returns: - (str): The name of this AdditionalPropertiesInteger. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this AdditionalPropertiesInteger. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, AdditionalPropertiesInteger): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py index 25c9298cea98..e6d75b406361 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_number.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class AdditionalPropertiesNumber(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name' # noqa: E501 - } - openapi_types = { 'name': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class AdditionalPropertiesNumber(ModelNormal): additional_properties_type = (float,) # noqa: E501 - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """AdditionalPropertiesNumber - a model defined in OpenAPI + """additional_properties_number.AdditionalPropertiesNumber - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. name (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this AdditionalPropertiesNumber. # noqa: E501 - - Returns: - (str): The name of this AdditionalPropertiesNumber. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this AdditionalPropertiesNumber. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, AdditionalPropertiesNumber): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py index 67acc4099b8a..a3cb690eb769 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_object.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class AdditionalPropertiesObject(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name' # noqa: E501 - } - openapi_types = { 'name': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class AdditionalPropertiesObject(ModelNormal): additional_properties_type = ({str: (bool, date, datetime, dict, float, int, list, str,)},) # noqa: E501 - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """AdditionalPropertiesObject - a model defined in OpenAPI + """additional_properties_object.AdditionalPropertiesObject - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. name (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this AdditionalPropertiesObject. # noqa: E501 - - Returns: - (str): The name of this AdditionalPropertiesObject. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this AdditionalPropertiesObject. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, AdditionalPropertiesObject): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py index 5906157a158c..1611d7c64081 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/additional_properties_string.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class AdditionalPropertiesString(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name' # noqa: E501 - } - openapi_types = { 'name': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class AdditionalPropertiesString(ModelNormal): additional_properties_type = (str,) # noqa: E501 - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """AdditionalPropertiesString - a model defined in OpenAPI + """additional_properties_string.AdditionalPropertiesString - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. name (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this AdditionalPropertiesString. # noqa: E501 - - Returns: - (str): The name of this AdditionalPropertiesString. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this AdditionalPropertiesString. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, AdditionalPropertiesString): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/animal.py b/samples/client/petstore/python-experimental/petstore_api/models/animal.py index d625389dd634..106bf5e7649e 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/animal.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/animal.py @@ -10,34 +10,32 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -from petstore_api.models.cat import Cat -from petstore_api.models.dog import Dog +try: + from petstore_api.models import cat +except ImportError: + cat = sys.modules['petstore_api.models.cat'] +try: + from petstore_api.models import dog +except ImportError: + dog = sys.modules['petstore_api.models.dog'] class Animal(ModelNormal): @@ -69,16 +67,6 @@ class Animal(ModelNormal): allowed_values = { } - attribute_map = { - 'class_name': 'className', # noqa: E501 - 'color': 'color' # noqa: E501 - } - - discriminator_value_class_map = { - 'Dog': Dog, - 'Cat': Cat - } - openapi_types = { 'class_name': (str,), # noqa: E501 'color': (str,), # noqa: E501 @@ -89,10 +77,34 @@ class Animal(ModelNormal): additional_properties_type = None - discriminator = 'class_name' + @staticmethod + def discriminator(): + return { + 'class_name': { + 'Cat': cat.Cat, + 'Dog': dog.Dog, + }, + } + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'color': 'color', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Animal - a model defined in OpenAPI + """animal.Animal - a model defined in OpenAPI Args: class_name (str): @@ -113,158 +125,26 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it If omitted no type conversion is done. color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('class_name', class_name) + self.class_name = class_name for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def class_name(self): - """Gets the class_name of this Animal. # noqa: E501 - - Returns: - (str): The class_name of this Animal. # noqa: E501 - """ - return self.__get_item('class_name') - - @class_name.setter - def class_name(self, value): - """Sets the class_name of this Animal. # noqa: E501 - """ - return self.__set_item('class_name', value) - - @property - def color(self): - """Gets the color of this Animal. # noqa: E501 - - Returns: - (str): The color of this Animal. # noqa: E501 - """ - return self.__get_item('color') - - @color.setter - def color(self, value): - """Sets the color of this Animal. # noqa: E501 - """ - return self.__set_item('color', value) + setattr(self, var_name, var_value) @classmethod - def get_real_child_model(cls, data): - """Returns the real base class specified by the discriminator - We assume that data has javascript keys - """ - discriminator_key = cls.attribute_map[cls.discriminator] - discriminator_value = data[discriminator_key] - return cls.discriminator_value_class_map.get(discriminator_value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Animal): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + def get_discriminator_class(cls, from_server, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator() + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if from_server: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/api_response.py b/samples/client/petstore/python-experimental/petstore_api/models/api_response.py index 40713b75479a..e7516d6c7590 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/api_response.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/api_response.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,12 +59,6 @@ class ApiResponse(ModelNormal): allowed_values = { } - attribute_map = { - 'code': 'code', # noqa: E501 - 'type': 'type', # noqa: E501 - 'message': 'message' # noqa: E501 - } - openapi_types = { 'code': (int,), # noqa: E501 'type': (str,), # noqa: E501 @@ -84,10 +70,30 @@ class ApiResponse(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'code': 'code', # noqa: E501 + 'type': 'type', # noqa: E501 + 'message': 'message', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """ApiResponse - a model defined in OpenAPI + """api_response.ApiResponse - a model defined in OpenAPI Keyword Args: @@ -108,6 +114,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf type (str): [optional] # noqa: E501 message (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -115,156 +122,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def code(self): - """Gets the code of this ApiResponse. # noqa: E501 - - Returns: - (int): The code of this ApiResponse. # noqa: E501 - """ - return self.__get_item('code') - - @code.setter - def code(self, value): - """Sets the code of this ApiResponse. # noqa: E501 - """ - return self.__set_item('code', value) - - @property - def type(self): - """Gets the type of this ApiResponse. # noqa: E501 - - Returns: - (str): The type of this ApiResponse. # noqa: E501 - """ - return self.__get_item('type') - - @type.setter - def type(self, value): - """Sets the type of this ApiResponse. # noqa: E501 - """ - return self.__set_item('type', value) - - @property - def message(self): - """Gets the message of this ApiResponse. # noqa: E501 - - Returns: - (str): The message of this ApiResponse. # noqa: E501 - """ - return self.__get_item('message') - - @message.setter - def message(self, value): - """Sets the message of this ApiResponse. # noqa: E501 - """ - return self.__set_item('message', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ApiResponse): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py index a2e3c7326a68..76165622532e 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_of_array_of_number_only.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class ArrayOfArrayOfNumberOnly(ModelNormal): allowed_values = { } - attribute_map = { - 'array_array_number': 'ArrayArrayNumber' # noqa: E501 - } - openapi_types = { 'array_array_number': ([[float]],), # noqa: E501 } @@ -80,10 +68,28 @@ class ArrayOfArrayOfNumberOnly(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'array_array_number': 'ArrayArrayNumber', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """ArrayOfArrayOfNumberOnly - a model defined in OpenAPI + """array_of_array_of_number_only.ArrayOfArrayOfNumberOnly - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. array_array_number ([[float]]): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def array_array_number(self): - """Gets the array_array_number of this ArrayOfArrayOfNumberOnly. # noqa: E501 - - Returns: - ([[float]]): The array_array_number of this ArrayOfArrayOfNumberOnly. # noqa: E501 - """ - return self.__get_item('array_array_number') - - @array_array_number.setter - def array_array_number(self, value): - """Sets the array_array_number of this ArrayOfArrayOfNumberOnly. # noqa: E501 - """ - return self.__set_item('array_array_number', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ArrayOfArrayOfNumberOnly): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py index c35c8e59631c..165e0eed8192 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_of_number_only.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class ArrayOfNumberOnly(ModelNormal): allowed_values = { } - attribute_map = { - 'array_number': 'ArrayNumber' # noqa: E501 - } - openapi_types = { 'array_number': ([float],), # noqa: E501 } @@ -80,10 +68,28 @@ class ArrayOfNumberOnly(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'array_number': 'ArrayNumber', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """ArrayOfNumberOnly - a model defined in OpenAPI + """array_of_number_only.ArrayOfNumberOnly - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. array_number ([float]): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def array_number(self): - """Gets the array_number of this ArrayOfNumberOnly. # noqa: E501 - - Returns: - ([float]): The array_number of this ArrayOfNumberOnly. # noqa: E501 - """ - return self.__get_item('array_number') - - @array_number.setter - def array_number(self, value): - """Sets the array_number of this ArrayOfNumberOnly. # noqa: E501 - """ - return self.__set_item('array_number', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ArrayOfNumberOnly): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/array_test.py b/samples/client/petstore/python-experimental/petstore_api/models/array_test.py index cc52f04d318f..72418960f571 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/array_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/array_test.py @@ -10,33 +10,28 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -from petstore_api.models.read_only_first import ReadOnlyFirst +try: + from petstore_api.models import read_only_first +except ImportError: + read_only_first = sys.modules['petstore_api.models.read_only_first'] class ArrayTest(ModelNormal): @@ -68,16 +63,10 @@ class ArrayTest(ModelNormal): allowed_values = { } - attribute_map = { - 'array_of_string': 'array_of_string', # noqa: E501 - 'array_array_of_integer': 'array_array_of_integer', # noqa: E501 - 'array_array_of_model': 'array_array_of_model' # noqa: E501 - } - openapi_types = { 'array_of_string': ([str],), # noqa: E501 'array_array_of_integer': ([[int]],), # noqa: E501 - 'array_array_of_model': ([[ReadOnlyFirst]],), # noqa: E501 + 'array_array_of_model': ([[read_only_first.ReadOnlyFirst]],), # noqa: E501 } validations = { @@ -85,10 +74,30 @@ class ArrayTest(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'array_of_string': 'array_of_string', # noqa: E501 + 'array_array_of_integer': 'array_array_of_integer', # noqa: E501 + 'array_array_of_model': 'array_array_of_model', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """ArrayTest - a model defined in OpenAPI + """array_test.ArrayTest - a model defined in OpenAPI Keyword Args: @@ -107,8 +116,9 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. array_of_string ([str]): [optional] # noqa: E501 array_array_of_integer ([[int]]): [optional] # noqa: E501 - array_array_of_model ([[ReadOnlyFirst]]): [optional] # noqa: E501 + array_array_of_model ([[read_only_first.ReadOnlyFirst]]): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -116,156 +126,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def array_of_string(self): - """Gets the array_of_string of this ArrayTest. # noqa: E501 - - Returns: - ([str]): The array_of_string of this ArrayTest. # noqa: E501 - """ - return self.__get_item('array_of_string') - - @array_of_string.setter - def array_of_string(self, value): - """Sets the array_of_string of this ArrayTest. # noqa: E501 - """ - return self.__set_item('array_of_string', value) - - @property - def array_array_of_integer(self): - """Gets the array_array_of_integer of this ArrayTest. # noqa: E501 - - Returns: - ([[int]]): The array_array_of_integer of this ArrayTest. # noqa: E501 - """ - return self.__get_item('array_array_of_integer') - - @array_array_of_integer.setter - def array_array_of_integer(self, value): - """Sets the array_array_of_integer of this ArrayTest. # noqa: E501 - """ - return self.__set_item('array_array_of_integer', value) - - @property - def array_array_of_model(self): - """Gets the array_array_of_model of this ArrayTest. # noqa: E501 - - Returns: - ([[ReadOnlyFirst]]): The array_array_of_model of this ArrayTest. # noqa: E501 - """ - return self.__get_item('array_array_of_model') - - @array_array_of_model.setter - def array_array_of_model(self, value): - """Sets the array_array_of_model of this ArrayTest. # noqa: E501 - """ - return self.__set_item('array_array_of_model', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ArrayTest): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py b/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py index 9134f5e4251f..a25472b19da3 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,15 +59,6 @@ class Capitalization(ModelNormal): allowed_values = { } - attribute_map = { - 'small_camel': 'smallCamel', # noqa: E501 - 'capital_camel': 'CapitalCamel', # noqa: E501 - 'small_snake': 'small_Snake', # noqa: E501 - 'capital_snake': 'Capital_Snake', # noqa: E501 - 'sca_eth_flow_points': 'SCA_ETH_Flow_Points', # noqa: E501 - 'att_name': 'ATT_NAME' # noqa: E501 - } - openapi_types = { 'small_camel': (str,), # noqa: E501 'capital_camel': (str,), # noqa: E501 @@ -90,10 +73,33 @@ class Capitalization(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'small_camel': 'smallCamel', # noqa: E501 + 'capital_camel': 'CapitalCamel', # noqa: E501 + 'small_snake': 'small_Snake', # noqa: E501 + 'capital_snake': 'Capital_Snake', # noqa: E501 + 'sca_eth_flow_points': 'SCA_ETH_Flow_Points', # noqa: E501 + 'att_name': 'ATT_NAME', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Capitalization - a model defined in OpenAPI + """capitalization.Capitalization - a model defined in OpenAPI Keyword Args: @@ -117,6 +123,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf sca_eth_flow_points (str): [optional] # noqa: E501 att_name (str): Name of the pet . [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -124,203 +131,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def small_camel(self): - """Gets the small_camel of this Capitalization. # noqa: E501 - - Returns: - (str): The small_camel of this Capitalization. # noqa: E501 - """ - return self.__get_item('small_camel') - - @small_camel.setter - def small_camel(self, value): - """Sets the small_camel of this Capitalization. # noqa: E501 - """ - return self.__set_item('small_camel', value) - - @property - def capital_camel(self): - """Gets the capital_camel of this Capitalization. # noqa: E501 - - Returns: - (str): The capital_camel of this Capitalization. # noqa: E501 - """ - return self.__get_item('capital_camel') - - @capital_camel.setter - def capital_camel(self, value): - """Sets the capital_camel of this Capitalization. # noqa: E501 - """ - return self.__set_item('capital_camel', value) - - @property - def small_snake(self): - """Gets the small_snake of this Capitalization. # noqa: E501 - - Returns: - (str): The small_snake of this Capitalization. # noqa: E501 - """ - return self.__get_item('small_snake') - - @small_snake.setter - def small_snake(self, value): - """Sets the small_snake of this Capitalization. # noqa: E501 - """ - return self.__set_item('small_snake', value) - - @property - def capital_snake(self): - """Gets the capital_snake of this Capitalization. # noqa: E501 - - Returns: - (str): The capital_snake of this Capitalization. # noqa: E501 - """ - return self.__get_item('capital_snake') - - @capital_snake.setter - def capital_snake(self, value): - """Sets the capital_snake of this Capitalization. # noqa: E501 - """ - return self.__set_item('capital_snake', value) - - @property - def sca_eth_flow_points(self): - """Gets the sca_eth_flow_points of this Capitalization. # noqa: E501 - - Returns: - (str): The sca_eth_flow_points of this Capitalization. # noqa: E501 - """ - return self.__get_item('sca_eth_flow_points') - - @sca_eth_flow_points.setter - def sca_eth_flow_points(self, value): - """Sets the sca_eth_flow_points of this Capitalization. # noqa: E501 - """ - return self.__set_item('sca_eth_flow_points', value) - - @property - def att_name(self): - """Gets the att_name of this Capitalization. # noqa: E501 - Name of the pet # noqa: E501 - - Returns: - (str): The att_name of this Capitalization. # noqa: E501 - """ - return self.__get_item('att_name') - - @att_name.setter - def att_name(self, value): - """Sets the att_name of this Capitalization. # noqa: E501 - Name of the pet # noqa: E501 - """ - return self.__set_item('att_name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Capitalization): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/cat.py b/samples/client/petstore/python-experimental/petstore_api/models/cat.py index 40508dd3ce79..fc9ab76fbfda 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/cat.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/cat.py @@ -10,35 +10,35 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) +try: + from petstore_api.models import animal +except ImportError: + animal = sys.modules['petstore_api.models.animal'] +try: + from petstore_api.models import cat_all_of +except ImportError: + cat_all_of = sys.modules['petstore_api.models.cat_all_of'] -class Cat(ModelNormal): +class Cat(ModelComposed): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -67,16 +67,10 @@ class Cat(ModelNormal): allowed_values = { } - attribute_map = { - 'class_name': 'className', # noqa: E501 - 'color': 'color', # noqa: E501 - 'declawed': 'declawed' # noqa: E501 - } - openapi_types = { 'class_name': (str,), # noqa: E501 - 'color': (str,), # noqa: E501 'declawed': (bool,), # noqa: E501 + 'color': (str,), # noqa: E501 } validations = { @@ -84,10 +78,29 @@ class Cat(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'declawed': 'declawed', # noqa: E501 + 'color': 'color', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Cat - a model defined in OpenAPI + """cat.Cat - a model defined in OpenAPI Args: class_name (str): @@ -109,164 +122,49 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it declawed (bool): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('class_name', class_name) + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + 'class_name': class_name, + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + self.class_name = class_name for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def class_name(self): - """Gets the class_name of this Cat. # noqa: E501 - - Returns: - (str): The class_name of this Cat. # noqa: E501 - """ - return self.__get_item('class_name') - - @class_name.setter - def class_name(self, value): - """Sets the class_name of this Cat. # noqa: E501 - """ - return self.__set_item('class_name', value) - - @property - def color(self): - """Gets the color of this Cat. # noqa: E501 - - Returns: - (str): The color of this Cat. # noqa: E501 - """ - return self.__get_item('color') - - @color.setter - def color(self, value): - """Sets the color of this Cat. # noqa: E501 - """ - return self.__set_item('color', value) - - @property - def declawed(self): - """Gets the declawed of this Cat. # noqa: E501 - - Returns: - (bool): The declawed of this Cat. # noqa: E501 - """ - return self.__get_item('declawed') - - @declawed.setter - def declawed(self, value): - """Sets the declawed of this Cat. # noqa: E501 - """ - return self.__set_item('declawed', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Cat): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + animal.Animal, + cat_all_of.CatAllOf, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py index cb1f0d815a0f..4e4c87e90d42 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/cat_all_of.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class CatAllOf(ModelNormal): allowed_values = { } - attribute_map = { - 'declawed': 'declawed' # noqa: E501 - } - openapi_types = { 'declawed': (bool,), # noqa: E501 } @@ -80,10 +68,28 @@ class CatAllOf(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'declawed': 'declawed', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """CatAllOf - a model defined in OpenAPI + """cat_all_of.CatAllOf - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. declawed (bool): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def declawed(self): - """Gets the declawed of this CatAllOf. # noqa: E501 - - Returns: - (bool): The declawed of this CatAllOf. # noqa: E501 - """ - return self.__get_item('declawed') - - @declawed.setter - def declawed(self, value): - """Sets the declawed of this CatAllOf. # noqa: E501 - """ - return self.__set_item('declawed', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, CatAllOf): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/category.py b/samples/client/petstore/python-experimental/petstore_api/models/category.py index ca367ad9c3d2..08c3e8aad969 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/category.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/category.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,14 +59,9 @@ class Category(ModelNormal): allowed_values = { } - attribute_map = { - 'id': 'id', # noqa: E501 - 'name': 'name' # noqa: E501 - } - openapi_types = { - 'id': (int,), # noqa: E501 'name': (str,), # noqa: E501 + 'id': (int,), # noqa: E501 } validations = { @@ -82,10 +69,29 @@ class Category(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + 'id': 'id', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, name='default-name', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Category - a model defined in OpenAPI + """category.Category - a model defined in OpenAPI Args: @@ -106,149 +112,13 @@ def __init__(self, name='default-name', _check_type=True, _from_server=False, _p If omitted no type conversion is done. id (int): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('name', name) + self.name = name for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def id(self): - """Gets the id of this Category. # noqa: E501 - - Returns: - (int): The id of this Category. # noqa: E501 - """ - return self.__get_item('id') - - @id.setter - def id(self, value): - """Sets the id of this Category. # noqa: E501 - """ - return self.__set_item('id', value) - - @property - def name(self): - """Gets the name of this Category. # noqa: E501 - - Returns: - (str): The name of this Category. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this Category. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Category): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child.py b/samples/client/petstore/python-experimental/petstore_api/models/child.py new file mode 100644 index 000000000000..7e5e332f0088 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/child.py @@ -0,0 +1,167 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import child_all_of +except ImportError: + child_all_of = sys.modules['petstore_api.models.child_all_of'] +try: + from petstore_api.models import parent +except ImportError: + parent = sys.modules['petstore_api.models.parent'] + + +class Child(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'radio_waves': (bool,), # noqa: E501 + 'tele_vision': (bool,), # noqa: E501 + 'inter_net': (bool,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'radio_waves': 'radioWaves', # noqa: E501 + 'tele_vision': 'teleVision', # noqa: E501 + 'inter_net': 'interNet', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """child.Child - a model defined in OpenAPI + + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + radio_waves (bool): [optional] # noqa: E501 + tele_vision (bool): [optional] # noqa: E501 + inter_net (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + child_all_of.ChildAllOf, + parent.Parent, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py new file mode 100644 index 000000000000..3cb28139b174 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_all_of.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class ChildAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'inter_net': (bool,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'inter_net': 'interNet', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """child_all_of.ChildAllOf - a model defined in OpenAPI + + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + inter_net (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py b/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py new file mode 100644 index 000000000000..58c0318faf0f --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_cat.py @@ -0,0 +1,167 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import child_cat_all_of +except ImportError: + child_cat_all_of = sys.modules['petstore_api.models.child_cat_all_of'] +try: + from petstore_api.models import parent_pet +except ImportError: + parent_pet = sys.modules['petstore_api.models.parent_pet'] + + +class ChildCat(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'pet_type': (str,), # noqa: E501 + 'name': (str,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + 'name': 'name', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """child_cat.ChildCat - a model defined in OpenAPI + + Args: + pet_type (str): + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + name (str): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + 'pet_type': pet_type, + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + self.pet_type = pet_type + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + child_cat_all_of.ChildCatAllOf, + parent_pet.ParentPet, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py new file mode 100644 index 000000000000..de70d839cf28 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_cat_all_of.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class ChildCatAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'name': (str,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """child_cat_all_of.ChildCatAllOf - a model defined in OpenAPI + + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + name (str): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py b/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py new file mode 100644 index 000000000000..450e6983fca5 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_dog.py @@ -0,0 +1,167 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import child_dog_all_of +except ImportError: + child_dog_all_of = sys.modules['petstore_api.models.child_dog_all_of'] +try: + from petstore_api.models import parent_pet +except ImportError: + parent_pet = sys.modules['petstore_api.models.parent_pet'] + + +class ChildDog(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'pet_type': (str,), # noqa: E501 + 'bark': (str,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + 'bark': 'bark', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """child_dog.ChildDog - a model defined in OpenAPI + + Args: + pet_type (str): + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + bark (str): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + 'pet_type': pet_type, + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + self.pet_type = pet_type + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + child_dog_all_of.ChildDogAllOf, + parent_pet.ParentPet, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py new file mode 100644 index 000000000000..37d900f2c2be --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_dog_all_of.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class ChildDogAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'bark': (str,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'bark': 'bark', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """child_dog_all_of.ChildDogAllOf - a model defined in OpenAPI + + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + bark (str): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py new file mode 100644 index 000000000000..169d05b51364 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard.py @@ -0,0 +1,167 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import child_lizard_all_of +except ImportError: + child_lizard_all_of = sys.modules['petstore_api.models.child_lizard_all_of'] +try: + from petstore_api.models import parent_pet +except ImportError: + parent_pet = sys.modules['petstore_api.models.parent_pet'] + + +class ChildLizard(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'pet_type': (str,), # noqa: E501 + 'loves_rocks': (bool,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + 'loves_rocks': 'lovesRocks', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """child_lizard.ChildLizard - a model defined in OpenAPI + + Args: + pet_type (str): + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + loves_rocks (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + 'pet_type': pet_type, + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + self.pet_type = pet_type + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + child_lizard_all_of.ChildLizardAllOf, + parent_pet.ParentPet, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py new file mode 100644 index 000000000000..6b6f8d99279d --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/child_lizard_all_of.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class ChildLizardAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'loves_rocks': (bool,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'loves_rocks': 'lovesRocks', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """child_lizard_all_of.ChildLizardAllOf - a model defined in OpenAPI + + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + loves_rocks (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/class_model.py b/samples/client/petstore/python-experimental/petstore_api/models/class_model.py index b44cdb80aae0..4f6fd3bca5e5 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/class_model.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/class_model.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class ClassModel(ModelNormal): allowed_values = { } - attribute_map = { - '_class': '_class' # noqa: E501 - } - openapi_types = { '_class': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class ClassModel(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + '_class': '_class', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """ClassModel - a model defined in OpenAPI + """class_model.ClassModel - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. _class (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def _class(self): - """Gets the _class of this ClassModel. # noqa: E501 - - Returns: - (str): The _class of this ClassModel. # noqa: E501 - """ - return self.__get_item('_class') - - @_class.setter - def _class(self, value): - """Sets the _class of this ClassModel. # noqa: E501 - """ - return self.__set_item('_class', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ClassModel): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/client.py b/samples/client/petstore/python-experimental/petstore_api/models/client.py index 5e1699a2196b..398d1b7ce0d6 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/client.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/client.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class Client(ModelNormal): allowed_values = { } - attribute_map = { - 'client': 'client' # noqa: E501 - } - openapi_types = { 'client': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class Client(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'client': 'client', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Client - a model defined in OpenAPI + """client.Client - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. client (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def client(self): - """Gets the client of this Client. # noqa: E501 - - Returns: - (str): The client of this Client. # noqa: E501 - """ - return self.__get_item('client') - - @client.setter - def client(self, value): - """Sets the client of this Client. # noqa: E501 - """ - return self.__set_item('client', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Client): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/dog.py b/samples/client/petstore/python-experimental/petstore_api/models/dog.py index bac013b867d9..f27e858b4c14 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/dog.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/dog.py @@ -10,35 +10,35 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) +try: + from petstore_api.models import animal +except ImportError: + animal = sys.modules['petstore_api.models.animal'] +try: + from petstore_api.models import dog_all_of +except ImportError: + dog_all_of = sys.modules['petstore_api.models.dog_all_of'] -class Dog(ModelNormal): +class Dog(ModelComposed): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -67,16 +67,10 @@ class Dog(ModelNormal): allowed_values = { } - attribute_map = { - 'class_name': 'className', # noqa: E501 - 'color': 'color', # noqa: E501 - 'breed': 'breed' # noqa: E501 - } - openapi_types = { 'class_name': (str,), # noqa: E501 - 'color': (str,), # noqa: E501 'breed': (str,), # noqa: E501 + 'color': (str,), # noqa: E501 } validations = { @@ -84,10 +78,29 @@ class Dog(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'class_name': 'className', # noqa: E501 + 'breed': 'breed', # noqa: E501 + 'color': 'color', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Dog - a model defined in OpenAPI + """dog.Dog - a model defined in OpenAPI Args: class_name (str): @@ -109,164 +122,49 @@ def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_it breed (str): [optional] # noqa: E501 color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('class_name', class_name) + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + 'class_name': class_name, + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + self.class_name = class_name for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def class_name(self): - """Gets the class_name of this Dog. # noqa: E501 - - Returns: - (str): The class_name of this Dog. # noqa: E501 - """ - return self.__get_item('class_name') - - @class_name.setter - def class_name(self, value): - """Sets the class_name of this Dog. # noqa: E501 - """ - return self.__set_item('class_name', value) - - @property - def color(self): - """Gets the color of this Dog. # noqa: E501 - - Returns: - (str): The color of this Dog. # noqa: E501 - """ - return self.__get_item('color') - - @color.setter - def color(self, value): - """Sets the color of this Dog. # noqa: E501 - """ - return self.__set_item('color', value) - - @property - def breed(self): - """Gets the breed of this Dog. # noqa: E501 - - Returns: - (str): The breed of this Dog. # noqa: E501 - """ - return self.__get_item('breed') - - @breed.setter - def breed(self, value): - """Sets the breed of this Dog. # noqa: E501 - """ - return self.__set_item('breed', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Dog): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + animal.Animal, + dog_all_of.DogAllOf, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py index 7d9a33bbe365..18e9270a4c6b 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/dog_all_of.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class DogAllOf(ModelNormal): allowed_values = { } - attribute_map = { - 'breed': 'breed' # noqa: E501 - } - openapi_types = { 'breed': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class DogAllOf(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'breed': 'breed', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """DogAllOf - a model defined in OpenAPI + """dog_all_of.DogAllOf - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. breed (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def breed(self): - """Gets the breed of this DogAllOf. # noqa: E501 - - Returns: - (str): The breed of this DogAllOf. # noqa: E501 - """ - return self.__get_item('breed') - - @breed.setter - def breed(self, value): - """Sets the breed of this DogAllOf. # noqa: E501 - """ - return self.__set_item('breed', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, DogAllOf): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py index 477193e858f4..167f573d4521 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_arrays.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -75,11 +67,6 @@ class EnumArrays(ModelNormal): }, } - attribute_map = { - 'just_symbol': 'just_symbol', # noqa: E501 - 'array_enum': 'array_enum' # noqa: E501 - } - openapi_types = { 'just_symbol': (str,), # noqa: E501 'array_enum': ([str],), # noqa: E501 @@ -90,10 +77,29 @@ class EnumArrays(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'just_symbol': 'just_symbol', # noqa: E501 + 'array_enum': 'array_enum', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """EnumArrays - a model defined in OpenAPI + """enum_arrays.EnumArrays - a model defined in OpenAPI Keyword Args: @@ -113,6 +119,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf just_symbol (str): [optional] # noqa: E501 array_enum ([str]): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -120,141 +127,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def just_symbol(self): - """Gets the just_symbol of this EnumArrays. # noqa: E501 - - Returns: - (str): The just_symbol of this EnumArrays. # noqa: E501 - """ - return self.__get_item('just_symbol') - - @just_symbol.setter - def just_symbol(self, value): - """Sets the just_symbol of this EnumArrays. # noqa: E501 - """ - return self.__set_item('just_symbol', value) - - @property - def array_enum(self): - """Gets the array_enum of this EnumArrays. # noqa: E501 - - Returns: - ([str]): The array_enum of this EnumArrays. # noqa: E501 - """ - return self.__get_item('array_enum') - - @array_enum.setter - def array_enum(self, value): - """Sets the array_enum of this EnumArrays. # noqa: E501 - """ - return self.__set_item('array_enum', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, EnumArrays): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py index 0b3bca10a53e..b80116abce16 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_class.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -77,10 +69,24 @@ class EnumClass(ModelSimple): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """EnumClass - a model defined in OpenAPI + """enum_class.EnumClass - a model defined in OpenAPI Args: @@ -100,127 +106,13 @@ def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_ If passed, type conversion is attempted If omitted no type conversion is done. """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('value', value) + self.value = value for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def value(self): - """Gets the value of this EnumClass. # noqa: E501 - - Returns: - (str): The value of this EnumClass. # noqa: E501 - """ - return self.__get_item('value') - - @value.setter - def value(self, value): - """Sets the value of this EnumClass. # noqa: E501 - """ - return self.__set_item('value', value) - - def to_str(self): - """Returns the string representation of the model""" - return str(self.value) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, EnumClass): - return False - - this_val = self._data_store['value'] - that_val = other._data_store['value'] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py b/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py index 83f6d78c3f8f..c7bef7cc3200 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/enum_test.py @@ -10,33 +10,28 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -from petstore_api.models.outer_enum import OuterEnum +try: + from petstore_api.models import outer_enum +except ImportError: + outer_enum = sys.modules['petstore_api.models.outer_enum'] class EnumTest(ModelNormal): @@ -66,12 +61,12 @@ class EnumTest(ModelNormal): """ allowed_values = { - ('enum_string',): { + ('enum_string_required',): { 'UPPER': "UPPER", 'LOWER': "lower", 'EMPTY': "", }, - ('enum_string_required',): { + ('enum_string',): { 'UPPER': "UPPER", 'LOWER': "lower", 'EMPTY': "", @@ -86,20 +81,12 @@ class EnumTest(ModelNormal): }, } - attribute_map = { - 'enum_string': 'enum_string', # noqa: E501 - 'enum_string_required': 'enum_string_required', # noqa: E501 - 'enum_integer': 'enum_integer', # noqa: E501 - 'enum_number': 'enum_number', # noqa: E501 - 'outer_enum': 'outerEnum' # noqa: E501 - } - openapi_types = { - 'enum_string': (str,), # noqa: E501 'enum_string_required': (str,), # noqa: E501 + 'enum_string': (str,), # noqa: E501 'enum_integer': (int,), # noqa: E501 'enum_number': (float,), # noqa: E501 - 'outer_enum': (OuterEnum,), # noqa: E501 + 'outer_enum': (outer_enum.OuterEnum,), # noqa: E501 } validations = { @@ -107,10 +94,32 @@ class EnumTest(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'enum_string_required': 'enum_string_required', # noqa: E501 + 'enum_string': 'enum_string', # noqa: E501 + 'enum_integer': 'enum_integer', # noqa: E501 + 'enum_number': 'enum_number', # noqa: E501 + 'outer_enum': 'outerEnum', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, enum_string_required, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """EnumTest - a model defined in OpenAPI + """enum_test.EnumTest - a model defined in OpenAPI Args: enum_string_required (str): @@ -132,196 +141,15 @@ def __init__(self, enum_string_required, _check_type=True, _from_server=False, _ enum_string (str): [optional] # noqa: E501 enum_integer (int): [optional] # noqa: E501 enum_number (float): [optional] # noqa: E501 - outer_enum (OuterEnum): [optional] # noqa: E501 + outer_enum (outer_enum.OuterEnum): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('enum_string_required', enum_string_required) + self.enum_string_required = enum_string_required for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def enum_string(self): - """Gets the enum_string of this EnumTest. # noqa: E501 - - Returns: - (str): The enum_string of this EnumTest. # noqa: E501 - """ - return self.__get_item('enum_string') - - @enum_string.setter - def enum_string(self, value): - """Sets the enum_string of this EnumTest. # noqa: E501 - """ - return self.__set_item('enum_string', value) - - @property - def enum_string_required(self): - """Gets the enum_string_required of this EnumTest. # noqa: E501 - - Returns: - (str): The enum_string_required of this EnumTest. # noqa: E501 - """ - return self.__get_item('enum_string_required') - - @enum_string_required.setter - def enum_string_required(self, value): - """Sets the enum_string_required of this EnumTest. # noqa: E501 - """ - return self.__set_item('enum_string_required', value) - - @property - def enum_integer(self): - """Gets the enum_integer of this EnumTest. # noqa: E501 - - Returns: - (int): The enum_integer of this EnumTest. # noqa: E501 - """ - return self.__get_item('enum_integer') - - @enum_integer.setter - def enum_integer(self, value): - """Sets the enum_integer of this EnumTest. # noqa: E501 - """ - return self.__set_item('enum_integer', value) - - @property - def enum_number(self): - """Gets the enum_number of this EnumTest. # noqa: E501 - - Returns: - (float): The enum_number of this EnumTest. # noqa: E501 - """ - return self.__get_item('enum_number') - - @enum_number.setter - def enum_number(self, value): - """Sets the enum_number of this EnumTest. # noqa: E501 - """ - return self.__set_item('enum_number', value) - - @property - def outer_enum(self): - """Gets the outer_enum of this EnumTest. # noqa: E501 - - Returns: - (OuterEnum): The outer_enum of this EnumTest. # noqa: E501 - """ - return self.__get_item('outer_enum') - - @outer_enum.setter - def outer_enum(self, value): - """Sets the outer_enum of this EnumTest. # noqa: E501 - """ - return self.__set_item('outer_enum', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, EnumTest): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/file.py b/samples/client/petstore/python-experimental/petstore_api/models/file.py index 7da4e025a205..eb71f20abb36 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/file.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/file.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class File(ModelNormal): allowed_values = { } - attribute_map = { - 'source_uri': 'sourceURI' # noqa: E501 - } - openapi_types = { 'source_uri': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class File(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'source_uri': 'sourceURI', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """File - a model defined in OpenAPI + """file.File - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. source_uri (str): Test capitalization. [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,128 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def source_uri(self): - """Gets the source_uri of this File. # noqa: E501 - Test capitalization # noqa: E501 - - Returns: - (str): The source_uri of this File. # noqa: E501 - """ - return self.__get_item('source_uri') - - @source_uri.setter - def source_uri(self, value): - """Sets the source_uri of this File. # noqa: E501 - Test capitalization # noqa: E501 - """ - return self.__set_item('source_uri', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, File): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py b/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py index 5e0ca0498d9a..b612ecf317c8 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/file_schema_test_class.py @@ -10,33 +10,28 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -from petstore_api.models.file import File +try: + from petstore_api.models import file +except ImportError: + file = sys.modules['petstore_api.models.file'] class FileSchemaTestClass(ModelNormal): @@ -68,14 +63,9 @@ class FileSchemaTestClass(ModelNormal): allowed_values = { } - attribute_map = { - 'file': 'file', # noqa: E501 - 'files': 'files' # noqa: E501 - } - openapi_types = { - 'file': (File,), # noqa: E501 - 'files': ([File],), # noqa: E501 + 'file': (file.File,), # noqa: E501 + 'files': ([file.File],), # noqa: E501 } validations = { @@ -83,10 +73,29 @@ class FileSchemaTestClass(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'file': 'file', # noqa: E501 + 'files': 'files', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """FileSchemaTestClass - a model defined in OpenAPI + """file_schema_test_class.FileSchemaTestClass - a model defined in OpenAPI Keyword Args: @@ -103,9 +112,10 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. - file (File): [optional] # noqa: E501 - files ([File]): [optional] # noqa: E501 + file (file.File): [optional] # noqa: E501 + files ([file.File]): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -113,141 +123,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def file(self): - """Gets the file of this FileSchemaTestClass. # noqa: E501 - - Returns: - (File): The file of this FileSchemaTestClass. # noqa: E501 - """ - return self.__get_item('file') - - @file.setter - def file(self, value): - """Sets the file of this FileSchemaTestClass. # noqa: E501 - """ - return self.__set_item('file', value) - - @property - def files(self): - """Gets the files of this FileSchemaTestClass. # noqa: E501 - - Returns: - ([File]): The files of this FileSchemaTestClass. # noqa: E501 - """ - return self.__get_item('files') - - @files.setter - def files(self, value): - """Sets the files of this FileSchemaTestClass. # noqa: E501 - """ - return self.__set_item('files', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, FileSchemaTestClass): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/format_test.py b/samples/client/petstore/python-experimental/petstore_api/models/format_test.py index de33c15695b6..7b455ece510c 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/format_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/format_test.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,39 +59,36 @@ class FormatTest(ModelNormal): allowed_values = { } - attribute_map = { - 'integer': 'integer', # noqa: E501 - 'int32': 'int32', # noqa: E501 - 'int64': 'int64', # noqa: E501 - 'number': 'number', # noqa: E501 - 'float': 'float', # noqa: E501 - 'double': 'double', # noqa: E501 - 'string': 'string', # noqa: E501 - 'byte': 'byte', # noqa: E501 - 'binary': 'binary', # noqa: E501 - 'date': 'date', # noqa: E501 - 'date_time': 'dateTime', # noqa: E501 - 'uuid': 'uuid', # noqa: E501 - 'password': 'password' # noqa: E501 - } - openapi_types = { + 'number': (float,), # noqa: E501 + 'byte': (str,), # noqa: E501 + 'date': (date,), # noqa: E501 + 'password': (str,), # noqa: E501 'integer': (int,), # noqa: E501 'int32': (int,), # noqa: E501 'int64': (int,), # noqa: E501 - 'number': (float,), # noqa: E501 'float': (float,), # noqa: E501 'double': (float,), # noqa: E501 'string': (str,), # noqa: E501 - 'byte': (str,), # noqa: E501 'binary': (file_type,), # noqa: E501 - 'date': (date,), # noqa: E501 'date_time': (datetime,), # noqa: E501 'uuid': (str,), # noqa: E501 - 'password': (str,), # noqa: E501 } validations = { + ('number',): { + 'inclusive_maximum': 543.2, + 'inclusive_minimum': 32.1, + }, + ('byte',): { + 'regex': { + 'pattern': r'^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$', # noqa: E501 + }, + }, + ('password',): { + 'max_length': 64, + 'min_length': 10, + }, ('integer',): { 'inclusive_maximum': 100, 'inclusive_minimum': 10, @@ -108,10 +97,6 @@ class FormatTest(ModelNormal): 'inclusive_maximum': 200, 'inclusive_minimum': 20, }, - ('number',): { - 'inclusive_maximum': 543.2, - 'inclusive_minimum': 32.1, - }, ('float',): { 'inclusive_maximum': 987.6, 'inclusive_minimum': 54.3, @@ -126,23 +111,44 @@ class FormatTest(ModelNormal): 'flags': (re.IGNORECASE) }, }, - ('byte',): { - 'regex': { - 'pattern': r'^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$', # noqa: E501 - }, - }, - ('password',): { - 'max_length': 64, - 'min_length': 10, - }, } additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'number': 'number', # noqa: E501 + 'byte': 'byte', # noqa: E501 + 'date': 'date', # noqa: E501 + 'password': 'password', # noqa: E501 + 'integer': 'integer', # noqa: E501 + 'int32': 'int32', # noqa: E501 + 'int64': 'int64', # noqa: E501 + 'float': 'float', # noqa: E501 + 'double': 'double', # noqa: E501 + 'string': 'string', # noqa: E501 + 'binary': 'binary', # noqa: E501 + 'date_time': 'dateTime', # noqa: E501 + 'uuid': 'uuid', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, number, byte, date, password, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """FormatTest - a model defined in OpenAPI + """format_test.FormatTest - a model defined in OpenAPI Args: number (float): @@ -174,317 +180,16 @@ def __init__(self, number, byte, date, password, _check_type=True, _from_server= date_time (datetime): [optional] # noqa: E501 uuid (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('number', number) - self.__set_item('byte', byte) - self.__set_item('date', date) - self.__set_item('password', password) + self.number = number + self.byte = byte + self.date = date + self.password = password for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def integer(self): - """Gets the integer of this FormatTest. # noqa: E501 - - Returns: - (int): The integer of this FormatTest. # noqa: E501 - """ - return self.__get_item('integer') - - @integer.setter - def integer(self, value): - """Sets the integer of this FormatTest. # noqa: E501 - """ - return self.__set_item('integer', value) - - @property - def int32(self): - """Gets the int32 of this FormatTest. # noqa: E501 - - Returns: - (int): The int32 of this FormatTest. # noqa: E501 - """ - return self.__get_item('int32') - - @int32.setter - def int32(self, value): - """Sets the int32 of this FormatTest. # noqa: E501 - """ - return self.__set_item('int32', value) - - @property - def int64(self): - """Gets the int64 of this FormatTest. # noqa: E501 - - Returns: - (int): The int64 of this FormatTest. # noqa: E501 - """ - return self.__get_item('int64') - - @int64.setter - def int64(self, value): - """Sets the int64 of this FormatTest. # noqa: E501 - """ - return self.__set_item('int64', value) - - @property - def number(self): - """Gets the number of this FormatTest. # noqa: E501 - - Returns: - (float): The number of this FormatTest. # noqa: E501 - """ - return self.__get_item('number') - - @number.setter - def number(self, value): - """Sets the number of this FormatTest. # noqa: E501 - """ - return self.__set_item('number', value) - - @property - def float(self): - """Gets the float of this FormatTest. # noqa: E501 - - Returns: - (float): The float of this FormatTest. # noqa: E501 - """ - return self.__get_item('float') - - @float.setter - def float(self, value): - """Sets the float of this FormatTest. # noqa: E501 - """ - return self.__set_item('float', value) - - @property - def double(self): - """Gets the double of this FormatTest. # noqa: E501 - - Returns: - (float): The double of this FormatTest. # noqa: E501 - """ - return self.__get_item('double') - - @double.setter - def double(self, value): - """Sets the double of this FormatTest. # noqa: E501 - """ - return self.__set_item('double', value) - - @property - def string(self): - """Gets the string of this FormatTest. # noqa: E501 - - Returns: - (str): The string of this FormatTest. # noqa: E501 - """ - return self.__get_item('string') - - @string.setter - def string(self, value): - """Sets the string of this FormatTest. # noqa: E501 - """ - return self.__set_item('string', value) - - @property - def byte(self): - """Gets the byte of this FormatTest. # noqa: E501 - - Returns: - (str): The byte of this FormatTest. # noqa: E501 - """ - return self.__get_item('byte') - - @byte.setter - def byte(self, value): - """Sets the byte of this FormatTest. # noqa: E501 - """ - return self.__set_item('byte', value) - - @property - def binary(self): - """Gets the binary of this FormatTest. # noqa: E501 - - Returns: - (file_type): The binary of this FormatTest. # noqa: E501 - """ - return self.__get_item('binary') - - @binary.setter - def binary(self, value): - """Sets the binary of this FormatTest. # noqa: E501 - """ - return self.__set_item('binary', value) - - @property - def date(self): - """Gets the date of this FormatTest. # noqa: E501 - - Returns: - (date): The date of this FormatTest. # noqa: E501 - """ - return self.__get_item('date') - - @date.setter - def date(self, value): - """Sets the date of this FormatTest. # noqa: E501 - """ - return self.__set_item('date', value) - - @property - def date_time(self): - """Gets the date_time of this FormatTest. # noqa: E501 - - Returns: - (datetime): The date_time of this FormatTest. # noqa: E501 - """ - return self.__get_item('date_time') - - @date_time.setter - def date_time(self, value): - """Sets the date_time of this FormatTest. # noqa: E501 - """ - return self.__set_item('date_time', value) - - @property - def uuid(self): - """Gets the uuid of this FormatTest. # noqa: E501 - - Returns: - (str): The uuid of this FormatTest. # noqa: E501 - """ - return self.__get_item('uuid') - - @uuid.setter - def uuid(self, value): - """Sets the uuid of this FormatTest. # noqa: E501 - """ - return self.__set_item('uuid', value) - - @property - def password(self): - """Gets the password of this FormatTest. # noqa: E501 - - Returns: - (str): The password of this FormatTest. # noqa: E501 - """ - return self.__get_item('password') - - @password.setter - def password(self, value): - """Sets the password of this FormatTest. # noqa: E501 - """ - return self.__set_item('password', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, FormatTest): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py b/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py new file mode 100644 index 000000000000..26bae108ad1e --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/grandparent.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class Grandparent(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'radio_waves': (bool,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'radio_waves': 'radioWaves', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """grandparent.Grandparent - a model defined in OpenAPI + + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + radio_waves (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py b/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py new file mode 100644 index 000000000000..5d99b80c162c --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/grandparent_animal.py @@ -0,0 +1,121 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class GrandparentAnimal(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'pet_type': (str,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """grandparent_animal.GrandparentAnimal - a model defined in OpenAPI + + Args: + pet_type (str): + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + self.pet_type = pet_type + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py b/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py index ecf201d21e81..593a6280d3db 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/has_only_read_only.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,11 +59,6 @@ class HasOnlyReadOnly(ModelNormal): allowed_values = { } - attribute_map = { - 'bar': 'bar', # noqa: E501 - 'foo': 'foo' # noqa: E501 - } - openapi_types = { 'bar': (str,), # noqa: E501 'foo': (str,), # noqa: E501 @@ -82,10 +69,29 @@ class HasOnlyReadOnly(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'bar': 'bar', # noqa: E501 + 'foo': 'foo', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """HasOnlyReadOnly - a model defined in OpenAPI + """has_only_read_only.HasOnlyReadOnly - a model defined in OpenAPI Keyword Args: @@ -105,6 +111,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf bar (str): [optional] # noqa: E501 foo (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -112,141 +119,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def bar(self): - """Gets the bar of this HasOnlyReadOnly. # noqa: E501 - - Returns: - (str): The bar of this HasOnlyReadOnly. # noqa: E501 - """ - return self.__get_item('bar') - - @bar.setter - def bar(self, value): - """Sets the bar of this HasOnlyReadOnly. # noqa: E501 - """ - return self.__set_item('bar', value) - - @property - def foo(self): - """Gets the foo of this HasOnlyReadOnly. # noqa: E501 - - Returns: - (str): The foo of this HasOnlyReadOnly. # noqa: E501 - """ - return self.__get_item('foo') - - @foo.setter - def foo(self, value): - """Sets the foo of this HasOnlyReadOnly. # noqa: E501 - """ - return self.__set_item('foo', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, HasOnlyReadOnly): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/list.py b/samples/client/petstore/python-experimental/petstore_api/models/list.py index 79ff6c81bede..362ac90e2c92 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/list.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/list.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class List(ModelNormal): allowed_values = { } - attribute_map = { - '_123_list': '123-list' # noqa: E501 - } - openapi_types = { '_123_list': (str,), # noqa: E501 } @@ -80,10 +68,28 @@ class List(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + '_123_list': '123-list', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """List - a model defined in OpenAPI + """list.List - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. _123_list (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def _123_list(self): - """Gets the _123_list of this List. # noqa: E501 - - Returns: - (str): The _123_list of this List. # noqa: E501 - """ - return self.__get_item('_123_list') - - @_123_list.setter - def _123_list(self, value): - """Sets the _123_list of this List. # noqa: E501 - """ - return self.__set_item('_123_list', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, List): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/map_test.py b/samples/client/petstore/python-experimental/petstore_api/models/map_test.py index 84b07abdcc8d..475332634ab2 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/map_test.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/map_test.py @@ -10,33 +10,28 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -from petstore_api.models.string_boolean_map import StringBooleanMap +try: + from petstore_api.models import string_boolean_map +except ImportError: + string_boolean_map = sys.modules['petstore_api.models.string_boolean_map'] class MapTest(ModelNormal): @@ -72,18 +67,11 @@ class MapTest(ModelNormal): }, } - attribute_map = { - 'map_map_of_string': 'map_map_of_string', # noqa: E501 - 'map_of_enum_string': 'map_of_enum_string', # noqa: E501 - 'direct_map': 'direct_map', # noqa: E501 - 'indirect_map': 'indirect_map' # noqa: E501 - } - openapi_types = { 'map_map_of_string': ({str: ({str: (str,)},)},), # noqa: E501 'map_of_enum_string': ({str: (str,)},), # noqa: E501 'direct_map': ({str: (bool,)},), # noqa: E501 - 'indirect_map': (StringBooleanMap,), # noqa: E501 + 'indirect_map': (string_boolean_map.StringBooleanMap,), # noqa: E501 } validations = { @@ -91,10 +79,31 @@ class MapTest(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'map_map_of_string': 'map_map_of_string', # noqa: E501 + 'map_of_enum_string': 'map_of_enum_string', # noqa: E501 + 'direct_map': 'direct_map', # noqa: E501 + 'indirect_map': 'indirect_map', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """MapTest - a model defined in OpenAPI + """map_test.MapTest - a model defined in OpenAPI Keyword Args: @@ -114,8 +123,9 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf map_map_of_string ({str: ({str: (str,)},)}): [optional] # noqa: E501 map_of_enum_string ({str: (str,)}): [optional] # noqa: E501 direct_map ({str: (bool,)}): [optional] # noqa: E501 - indirect_map (StringBooleanMap): [optional] # noqa: E501 + indirect_map (string_boolean_map.StringBooleanMap): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -123,171 +133,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def map_map_of_string(self): - """Gets the map_map_of_string of this MapTest. # noqa: E501 - - Returns: - ({str: ({str: (str,)},)}): The map_map_of_string of this MapTest. # noqa: E501 - """ - return self.__get_item('map_map_of_string') - - @map_map_of_string.setter - def map_map_of_string(self, value): - """Sets the map_map_of_string of this MapTest. # noqa: E501 - """ - return self.__set_item('map_map_of_string', value) - - @property - def map_of_enum_string(self): - """Gets the map_of_enum_string of this MapTest. # noqa: E501 - - Returns: - ({str: (str,)}): The map_of_enum_string of this MapTest. # noqa: E501 - """ - return self.__get_item('map_of_enum_string') - - @map_of_enum_string.setter - def map_of_enum_string(self, value): - """Sets the map_of_enum_string of this MapTest. # noqa: E501 - """ - return self.__set_item('map_of_enum_string', value) - - @property - def direct_map(self): - """Gets the direct_map of this MapTest. # noqa: E501 - - Returns: - ({str: (bool,)}): The direct_map of this MapTest. # noqa: E501 - """ - return self.__get_item('direct_map') - - @direct_map.setter - def direct_map(self, value): - """Sets the direct_map of this MapTest. # noqa: E501 - """ - return self.__set_item('direct_map', value) - - @property - def indirect_map(self): - """Gets the indirect_map of this MapTest. # noqa: E501 - - Returns: - (StringBooleanMap): The indirect_map of this MapTest. # noqa: E501 - """ - return self.__get_item('indirect_map') - - @indirect_map.setter - def indirect_map(self, value): - """Sets the indirect_map of this MapTest. # noqa: E501 - """ - return self.__set_item('indirect_map', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, MapTest): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py b/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py index a8f9efb42974..a88a56b5cf55 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/mixed_properties_and_additional_properties_class.py @@ -10,33 +10,28 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -from petstore_api.models.animal import Animal +try: + from petstore_api.models import animal +except ImportError: + animal = sys.modules['petstore_api.models.animal'] class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): @@ -68,16 +63,10 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): allowed_values = { } - attribute_map = { - 'uuid': 'uuid', # noqa: E501 - 'date_time': 'dateTime', # noqa: E501 - 'map': 'map' # noqa: E501 - } - openapi_types = { 'uuid': (str,), # noqa: E501 'date_time': (datetime,), # noqa: E501 - 'map': ({str: (Animal,)},), # noqa: E501 + 'map': ({str: (animal.Animal,)},), # noqa: E501 } validations = { @@ -85,10 +74,30 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'uuid': 'uuid', # noqa: E501 + 'date_time': 'dateTime', # noqa: E501 + 'map': 'map', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI + """mixed_properties_and_additional_properties_class.MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI Keyword Args: @@ -107,8 +116,9 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. uuid (str): [optional] # noqa: E501 date_time (datetime): [optional] # noqa: E501 - map ({str: (Animal,)}): [optional] # noqa: E501 + map ({str: (animal.Animal,)}): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -116,156 +126,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def uuid(self): - """Gets the uuid of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - - Returns: - (str): The uuid of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('uuid') - - @uuid.setter - def uuid(self, value): - """Sets the uuid of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('uuid', value) - - @property - def date_time(self): - """Gets the date_time of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - - Returns: - (datetime): The date_time of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('date_time') - - @date_time.setter - def date_time(self, value): - """Sets the date_time of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('date_time', value) - - @property - def map(self): - """Gets the map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - - Returns: - ({str: (Animal,)}): The map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - """ - return self.__get_item('map') - - @map.setter - def map(self, value): - """Sets the map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501 - """ - return self.__set_item('map', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, MixedPropertiesAndAdditionalPropertiesClass): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py b/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py index 4bb72561e846..1fabb5e9b50a 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/model200_response.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,11 +59,6 @@ class Model200Response(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name', # noqa: E501 - '_class': 'class' # noqa: E501 - } - openapi_types = { 'name': (int,), # noqa: E501 '_class': (str,), # noqa: E501 @@ -82,10 +69,29 @@ class Model200Response(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + '_class': 'class', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Model200Response - a model defined in OpenAPI + """model200_response.Model200Response - a model defined in OpenAPI Keyword Args: @@ -105,6 +111,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf name (int): [optional] # noqa: E501 _class (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -112,141 +119,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this Model200Response. # noqa: E501 - - Returns: - (int): The name of this Model200Response. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this Model200Response. # noqa: E501 - """ - return self.__set_item('name', value) - - @property - def _class(self): - """Gets the _class of this Model200Response. # noqa: E501 - - Returns: - (str): The _class of this Model200Response. # noqa: E501 - """ - return self.__get_item('_class') - - @_class.setter - def _class(self, value): - """Sets the _class of this Model200Response. # noqa: E501 - """ - return self.__set_item('_class', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Model200Response): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/model_return.py b/samples/client/petstore/python-experimental/petstore_api/models/model_return.py index 1ca322750bf4..3466f9d2e691 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/model_return.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/model_return.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class ModelReturn(ModelNormal): allowed_values = { } - attribute_map = { - '_return': 'return' # noqa: E501 - } - openapi_types = { '_return': (int,), # noqa: E501 } @@ -80,10 +68,28 @@ class ModelReturn(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + '_return': 'return', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """ModelReturn - a model defined in OpenAPI + """model_return.ModelReturn - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. _return (int): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def _return(self): - """Gets the _return of this ModelReturn. # noqa: E501 - - Returns: - (int): The _return of this ModelReturn. # noqa: E501 - """ - return self.__get_item('_return') - - @_return.setter - def _return(self, value): - """Sets the _return of this ModelReturn. # noqa: E501 - """ - return self.__set_item('_return', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ModelReturn): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/name.py b/samples/client/petstore/python-experimental/petstore_api/models/name.py index b4c205ae08c9..39f9a4719daf 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/name.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/name.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,13 +59,6 @@ class Name(ModelNormal): allowed_values = { } - attribute_map = { - 'name': 'name', # noqa: E501 - 'snake_case': 'snake_case', # noqa: E501 - '_property': 'property', # noqa: E501 - '_123_number': '123Number' # noqa: E501 - } - openapi_types = { 'name': (int,), # noqa: E501 'snake_case': (int,), # noqa: E501 @@ -86,10 +71,31 @@ class Name(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + 'snake_case': 'snake_case', # noqa: E501 + '_property': 'property', # noqa: E501 + '_123_number': '123Number', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Name - a model defined in OpenAPI + """name.Name - a model defined in OpenAPI Args: name (int): @@ -112,179 +118,13 @@ def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _property (str): [optional] # noqa: E501 _123_number (int): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('name', name) + self.name = name for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def name(self): - """Gets the name of this Name. # noqa: E501 - - Returns: - (int): The name of this Name. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this Name. # noqa: E501 - """ - return self.__set_item('name', value) - - @property - def snake_case(self): - """Gets the snake_case of this Name. # noqa: E501 - - Returns: - (int): The snake_case of this Name. # noqa: E501 - """ - return self.__get_item('snake_case') - - @snake_case.setter - def snake_case(self, value): - """Sets the snake_case of this Name. # noqa: E501 - """ - return self.__set_item('snake_case', value) - - @property - def _property(self): - """Gets the _property of this Name. # noqa: E501 - - Returns: - (str): The _property of this Name. # noqa: E501 - """ - return self.__get_item('_property') - - @_property.setter - def _property(self, value): - """Sets the _property of this Name. # noqa: E501 - """ - return self.__set_item('_property', value) - - @property - def _123_number(self): - """Gets the _123_number of this Name. # noqa: E501 - - Returns: - (int): The _123_number of this Name. # noqa: E501 - """ - return self.__get_item('_123_number') - - @_123_number.setter - def _123_number(self, value): - """Sets the _123_number of this Name. # noqa: E501 - """ - return self.__set_item('_123_number', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Name): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/number_only.py b/samples/client/petstore/python-experimental/petstore_api/models/number_only.py index 0761b3d3e323..96c03cef11dc 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/number_only.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/number_only.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class NumberOnly(ModelNormal): allowed_values = { } - attribute_map = { - 'just_number': 'JustNumber' # noqa: E501 - } - openapi_types = { 'just_number': (float,), # noqa: E501 } @@ -80,10 +68,28 @@ class NumberOnly(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'just_number': 'JustNumber', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """NumberOnly - a model defined in OpenAPI + """number_only.NumberOnly - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. just_number (float): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def just_number(self): - """Gets the just_number of this NumberOnly. # noqa: E501 - - Returns: - (float): The just_number of this NumberOnly. # noqa: E501 - """ - return self.__get_item('just_number') - - @just_number.setter - def just_number(self, value): - """Sets the just_number of this NumberOnly. # noqa: E501 - """ - return self.__set_item('just_number', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, NumberOnly): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/order.py b/samples/client/petstore/python-experimental/petstore_api/models/order.py index 64c84902aba5..ad4e10f0b042 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/order.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/order.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -72,15 +64,6 @@ class Order(ModelNormal): }, } - attribute_map = { - 'id': 'id', # noqa: E501 - 'pet_id': 'petId', # noqa: E501 - 'quantity': 'quantity', # noqa: E501 - 'ship_date': 'shipDate', # noqa: E501 - 'status': 'status', # noqa: E501 - 'complete': 'complete' # noqa: E501 - } - openapi_types = { 'id': (int,), # noqa: E501 'pet_id': (int,), # noqa: E501 @@ -95,10 +78,33 @@ class Order(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'id': 'id', # noqa: E501 + 'pet_id': 'petId', # noqa: E501 + 'quantity': 'quantity', # noqa: E501 + 'ship_date': 'shipDate', # noqa: E501 + 'status': 'status', # noqa: E501 + 'complete': 'complete', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Order - a model defined in OpenAPI + """order.Order - a model defined in OpenAPI Keyword Args: @@ -122,6 +128,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf status (str): Order Status. [optional] # noqa: E501 complete (bool): [optional] if omitted the server will use the default value of False # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -129,203 +136,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def id(self): - """Gets the id of this Order. # noqa: E501 - - Returns: - (int): The id of this Order. # noqa: E501 - """ - return self.__get_item('id') - - @id.setter - def id(self, value): - """Sets the id of this Order. # noqa: E501 - """ - return self.__set_item('id', value) - - @property - def pet_id(self): - """Gets the pet_id of this Order. # noqa: E501 - - Returns: - (int): The pet_id of this Order. # noqa: E501 - """ - return self.__get_item('pet_id') - - @pet_id.setter - def pet_id(self, value): - """Sets the pet_id of this Order. # noqa: E501 - """ - return self.__set_item('pet_id', value) - - @property - def quantity(self): - """Gets the quantity of this Order. # noqa: E501 - - Returns: - (int): The quantity of this Order. # noqa: E501 - """ - return self.__get_item('quantity') - - @quantity.setter - def quantity(self, value): - """Sets the quantity of this Order. # noqa: E501 - """ - return self.__set_item('quantity', value) - - @property - def ship_date(self): - """Gets the ship_date of this Order. # noqa: E501 - - Returns: - (datetime): The ship_date of this Order. # noqa: E501 - """ - return self.__get_item('ship_date') - - @ship_date.setter - def ship_date(self, value): - """Sets the ship_date of this Order. # noqa: E501 - """ - return self.__set_item('ship_date', value) - - @property - def status(self): - """Gets the status of this Order. # noqa: E501 - Order Status # noqa: E501 - - Returns: - (str): The status of this Order. # noqa: E501 - """ - return self.__get_item('status') - - @status.setter - def status(self, value): - """Sets the status of this Order. # noqa: E501 - Order Status # noqa: E501 - """ - return self.__set_item('status', value) - - @property - def complete(self): - """Gets the complete of this Order. # noqa: E501 - - Returns: - (bool): The complete of this Order. # noqa: E501 - """ - return self.__get_item('complete') - - @complete.setter - def complete(self, value): - """Sets the complete of this Order. # noqa: E501 - """ - return self.__set_item('complete', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Order): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py index 61bc50545758..6ad00966eae6 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_composite.py @@ -10,33 +10,28 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -from petstore_api.models.outer_number import OuterNumber +try: + from petstore_api.models import outer_number +except ImportError: + outer_number = sys.modules['petstore_api.models.outer_number'] class OuterComposite(ModelNormal): @@ -68,14 +63,8 @@ class OuterComposite(ModelNormal): allowed_values = { } - attribute_map = { - 'my_number': 'my_number', # noqa: E501 - 'my_string': 'my_string', # noqa: E501 - 'my_boolean': 'my_boolean' # noqa: E501 - } - openapi_types = { - 'my_number': (OuterNumber,), # noqa: E501 + 'my_number': (outer_number.OuterNumber,), # noqa: E501 'my_string': (str,), # noqa: E501 'my_boolean': (bool,), # noqa: E501 } @@ -85,10 +74,30 @@ class OuterComposite(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'my_number': 'my_number', # noqa: E501 + 'my_string': 'my_string', # noqa: E501 + 'my_boolean': 'my_boolean', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """OuterComposite - a model defined in OpenAPI + """outer_composite.OuterComposite - a model defined in OpenAPI Keyword Args: @@ -105,10 +114,11 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf deserializing a file_type parameter. If passed, type conversion is attempted If omitted no type conversion is done. - my_number (OuterNumber): [optional] # noqa: E501 + my_number (outer_number.OuterNumber): [optional] # noqa: E501 my_string (str): [optional] # noqa: E501 my_boolean (bool): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -116,156 +126,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def my_number(self): - """Gets the my_number of this OuterComposite. # noqa: E501 - - Returns: - (OuterNumber): The my_number of this OuterComposite. # noqa: E501 - """ - return self.__get_item('my_number') - - @my_number.setter - def my_number(self, value): - """Sets the my_number of this OuterComposite. # noqa: E501 - """ - return self.__set_item('my_number', value) - - @property - def my_string(self): - """Gets the my_string of this OuterComposite. # noqa: E501 - - Returns: - (str): The my_string of this OuterComposite. # noqa: E501 - """ - return self.__get_item('my_string') - - @my_string.setter - def my_string(self, value): - """Sets the my_string of this OuterComposite. # noqa: E501 - """ - return self.__set_item('my_string', value) - - @property - def my_boolean(self): - """Gets the my_boolean of this OuterComposite. # noqa: E501 - - Returns: - (bool): The my_boolean of this OuterComposite. # noqa: E501 - """ - return self.__get_item('my_boolean') - - @my_boolean.setter - def my_boolean(self, value): - """Sets the my_boolean of this OuterComposite. # noqa: E501 - """ - return self.__set_item('my_boolean', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, OuterComposite): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py index e10dfc65118f..39b104f64271 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_enum.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -77,10 +69,24 @@ class OuterEnum(ModelSimple): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """OuterEnum - a model defined in OpenAPI + """outer_enum.OuterEnum - a model defined in OpenAPI Args: value (str): @@ -100,127 +106,13 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() If passed, type conversion is attempted If omitted no type conversion is done. """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('value', value) + self.value = value for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def value(self): - """Gets the value of this OuterEnum. # noqa: E501 - - Returns: - (str): The value of this OuterEnum. # noqa: E501 - """ - return self.__get_item('value') - - @value.setter - def value(self, value): - """Sets the value of this OuterEnum. # noqa: E501 - """ - return self.__set_item('value', value) - - def to_str(self): - """Returns the string representation of the model""" - return str(self.value) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, OuterEnum): - return False - - this_val = self._data_store['value'] - that_val = other._data_store['value'] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py b/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py index ca2be68a97ec..362a3cf1fc51 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -76,10 +68,24 @@ class OuterNumber(ModelSimple): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """OuterNumber - a model defined in OpenAPI + """outer_number.OuterNumber - a model defined in OpenAPI Args: value (float): @@ -99,127 +105,13 @@ def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=() If passed, type conversion is attempted If omitted no type conversion is done. """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('value', value) + self.value = value for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def value(self): - """Gets the value of this OuterNumber. # noqa: E501 - - Returns: - (float): The value of this OuterNumber. # noqa: E501 - """ - return self.__get_item('value') - - @value.setter - def value(self, value): - """Sets the value of this OuterNumber. # noqa: E501 - """ - return self.__set_item('value', value) - - def to_str(self): - """Returns the string representation of the model""" - return str(self.value) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, OuterNumber): - return False - - this_val = self._data_store['value'] - that_val = other._data_store['value'] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent.py b/samples/client/petstore/python-experimental/petstore_api/models/parent.py new file mode 100644 index 000000000000..d07ca49d4de1 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent.py @@ -0,0 +1,164 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import grandparent +except ImportError: + grandparent = sys.modules['petstore_api.models.grandparent'] +try: + from petstore_api.models import parent_all_of +except ImportError: + parent_all_of = sys.modules['petstore_api.models.parent_all_of'] + + +class Parent(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'radio_waves': (bool,), # noqa: E501 + 'tele_vision': (bool,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'radio_waves': 'radioWaves', # noqa: E501 + 'tele_vision': 'teleVision', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """parent.Parent - a model defined in OpenAPI + + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + radio_waves (bool): [optional] # noqa: E501 + tele_vision (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + grandparent.Grandparent, + parent_all_of.ParentAllOf, + ], + 'oneOf': [ + ], + } diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py b/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py new file mode 100644 index 000000000000..0cfcbda855d5 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent_all_of.py @@ -0,0 +1,119 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) + + +class ParentAllOf(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'tele_vision': (bool,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'tele_vision': 'teleVision', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) + + def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """parent_all_of.ParentAllOf - a model defined in OpenAPI + + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + tele_vision (bool): [optional] # noqa: E501 + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py b/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py new file mode 100644 index 000000000000..59b890e89142 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/parent_pet.py @@ -0,0 +1,190 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import +import re # noqa: F401 +import sys # noqa: F401 + +import six # noqa: F401 + +from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, + ModelNormal, + ModelSimple, + date, + datetime, + file_type, + int, + none_type, + str, + validate_get_composed_info, +) +try: + from petstore_api.models import child_cat +except ImportError: + child_cat = sys.modules['petstore_api.models.child_cat'] +try: + from petstore_api.models import child_dog +except ImportError: + child_dog = sys.modules['petstore_api.models.child_dog'] +try: + from petstore_api.models import child_lizard +except ImportError: + child_lizard = sys.modules['petstore_api.models.child_lizard'] +try: + from petstore_api.models import grandparent_animal +except ImportError: + grandparent_animal = sys.modules['petstore_api.models.grandparent_animal'] + + +class ParentPet(ModelComposed): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + openapi_types (dict): The key is attribute name + and the value is attribute type. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + openapi_types = { + 'pet_type': (str,), # noqa: E501 + } + + validations = { + } + + additional_properties_type = None + + @staticmethod + def discriminator(): + return { + 'pet_type': { + 'ChildCat': child_cat.ChildCat, + 'ChildDog': child_dog.ChildDog, + 'ChildLizard': child_lizard.ChildLizard, + }, + } + + attribute_map = { + 'pet_type': 'pet_type', # noqa: E501 + } + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + '_composed_instances', + '_var_name_to_model_instances', + '_additional_properties_model_instances', + ]) + + def __init__(self, pet_type, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 + """parent_pet.ParentPet - a model defined in OpenAPI + + Args: + pet_type (str): + + Keyword Args: + _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. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _from_server (bool): True if the data is from the server + False if the data is from the client (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + """ + + self._data_store = {} + self._check_type = _check_type + self._from_server = _from_server + self._path_to_item = _path_to_item + self._configuration = _configuration + + constant_args = { + '_check_type': _check_type, + '_path_to_item': _path_to_item, + '_from_server': _from_server, + '_configuration': _configuration, + } + model_args = { + 'pet_type': pet_type, + } + model_args.update(kwargs) + composed_info = validate_get_composed_info( + constant_args, model_args, self) + self._composed_instances = composed_info[0] + self._var_name_to_model_instances = composed_info[1] + self._additional_properties_model_instances = composed_info[2] + + self.pet_type = pet_type + for var_name, var_value in six.iteritems(kwargs): + setattr(self, var_name, var_value) + + @staticmethod + def _composed_schemas(): + # we need this here to make our import statements work + # we must store _composed_schemas in here so the code is only run + # when we invoke this method. If we kept this at the class + # level we would get an error beause the class level + # code would be run when this module is imported, and these composed + # classes don't exist yet because their module has not finished + # loading + return { + 'anyOf': [ + ], + 'allOf': [ + grandparent_animal.GrandparentAnimal, + ], + 'oneOf': [ + ], + } + + @classmethod + def get_discriminator_class(cls, from_server, data): + """Returns the child class specified by the discriminator""" + discriminator = cls.discriminator() + discr_propertyname_py = list(discriminator.keys())[0] + discr_propertyname_js = cls.attribute_map[discr_propertyname_py] + if from_server: + class_name = data[discr_propertyname_js] + else: + class_name = data[discr_propertyname_py] + class_name_to_discr_class = discriminator[discr_propertyname_py] + return class_name_to_discr_class.get(class_name) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/pet.py b/samples/client/petstore/python-experimental/petstore_api/models/pet.py index 3abfdfba760c..081be0210e60 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/pet.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/pet.py @@ -10,34 +10,32 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) -from petstore_api.models.category import Category -from petstore_api.models.tag import Tag +try: + from petstore_api.models import category +except ImportError: + category = sys.modules['petstore_api.models.category'] +try: + from petstore_api.models import tag +except ImportError: + tag = sys.modules['petstore_api.models.tag'] class Pet(ModelNormal): @@ -74,21 +72,12 @@ class Pet(ModelNormal): }, } - attribute_map = { - 'id': 'id', # noqa: E501 - 'category': 'category', # noqa: E501 - 'name': 'name', # noqa: E501 - 'photo_urls': 'photoUrls', # noqa: E501 - 'tags': 'tags', # noqa: E501 - 'status': 'status' # noqa: E501 - } - openapi_types = { - 'id': (int,), # noqa: E501 - 'category': (Category,), # noqa: E501 'name': (str,), # noqa: E501 'photo_urls': ([str],), # noqa: E501 - 'tags': ([Tag],), # noqa: E501 + 'id': (int,), # noqa: E501 + 'category': (category.Category,), # noqa: E501 + 'tags': ([tag.Tag],), # noqa: E501 'status': (str,), # noqa: E501 } @@ -97,10 +86,33 @@ class Pet(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'name': 'name', # noqa: E501 + 'photo_urls': 'photoUrls', # noqa: E501 + 'id': 'id', # noqa: E501 + 'category': 'category', # noqa: E501 + 'tags': 'tags', # noqa: E501 + 'status': 'status', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Pet - a model defined in OpenAPI + """pet.Pet - a model defined in OpenAPI Args: name (str): @@ -121,216 +133,18 @@ def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path If passed, type conversion is attempted If omitted no type conversion is done. id (int): [optional] # noqa: E501 - category (Category): [optional] # noqa: E501 - tags ([Tag]): [optional] # noqa: E501 + category (category.Category): [optional] # noqa: E501 + tags ([tag.Tag]): [optional] # noqa: E501 status (str): pet status in the store. [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('name', name) - self.__set_item('photo_urls', photo_urls) + self.name = name + self.photo_urls = photo_urls for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def id(self): - """Gets the id of this Pet. # noqa: E501 - - Returns: - (int): The id of this Pet. # noqa: E501 - """ - return self.__get_item('id') - - @id.setter - def id(self, value): - """Sets the id of this Pet. # noqa: E501 - """ - return self.__set_item('id', value) - - @property - def category(self): - """Gets the category of this Pet. # noqa: E501 - - Returns: - (Category): The category of this Pet. # noqa: E501 - """ - return self.__get_item('category') - - @category.setter - def category(self, value): - """Sets the category of this Pet. # noqa: E501 - """ - return self.__set_item('category', value) - - @property - def name(self): - """Gets the name of this Pet. # noqa: E501 - - Returns: - (str): The name of this Pet. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this Pet. # noqa: E501 - """ - return self.__set_item('name', value) - - @property - def photo_urls(self): - """Gets the photo_urls of this Pet. # noqa: E501 - - Returns: - ([str]): The photo_urls of this Pet. # noqa: E501 - """ - return self.__get_item('photo_urls') - - @photo_urls.setter - def photo_urls(self, value): - """Sets the photo_urls of this Pet. # noqa: E501 - """ - return self.__set_item('photo_urls', value) - - @property - def tags(self): - """Gets the tags of this Pet. # noqa: E501 - - Returns: - ([Tag]): The tags of this Pet. # noqa: E501 - """ - return self.__get_item('tags') - - @tags.setter - def tags(self, value): - """Sets the tags of this Pet. # noqa: E501 - """ - return self.__set_item('tags', value) - - @property - def status(self): - """Gets the status of this Pet. # noqa: E501 - pet status in the store # noqa: E501 - - Returns: - (str): The status of this Pet. # noqa: E501 - """ - return self.__get_item('status') - - @status.setter - def status(self, value): - """Sets the status of this Pet. # noqa: E501 - pet status in the store # noqa: E501 - """ - return self.__set_item('status', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Pet): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py b/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py index 848fbccfa913..71ca20529129 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/read_only_first.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,11 +59,6 @@ class ReadOnlyFirst(ModelNormal): allowed_values = { } - attribute_map = { - 'bar': 'bar', # noqa: E501 - 'baz': 'baz' # noqa: E501 - } - openapi_types = { 'bar': (str,), # noqa: E501 'baz': (str,), # noqa: E501 @@ -82,10 +69,29 @@ class ReadOnlyFirst(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'bar': 'bar', # noqa: E501 + 'baz': 'baz', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """ReadOnlyFirst - a model defined in OpenAPI + """read_only_first.ReadOnlyFirst - a model defined in OpenAPI Keyword Args: @@ -105,6 +111,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf bar (str): [optional] # noqa: E501 baz (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -112,141 +119,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def bar(self): - """Gets the bar of this ReadOnlyFirst. # noqa: E501 - - Returns: - (str): The bar of this ReadOnlyFirst. # noqa: E501 - """ - return self.__get_item('bar') - - @bar.setter - def bar(self, value): - """Sets the bar of this ReadOnlyFirst. # noqa: E501 - """ - return self.__set_item('bar', value) - - @property - def baz(self): - """Gets the baz of this ReadOnlyFirst. # noqa: E501 - - Returns: - (str): The baz of this ReadOnlyFirst. # noqa: E501 - """ - return self.__get_item('baz') - - @baz.setter - def baz(self, value): - """Sets the baz of this ReadOnlyFirst. # noqa: E501 - """ - return self.__set_item('baz', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, ReadOnlyFirst): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py b/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py index 83810bdb8941..574c3817d786 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/special_model_name.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,10 +59,6 @@ class SpecialModelName(ModelNormal): allowed_values = { } - attribute_map = { - 'special_property_name': '$special[property.name]' # noqa: E501 - } - openapi_types = { 'special_property_name': (int,), # noqa: E501 } @@ -80,10 +68,28 @@ class SpecialModelName(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'special_property_name': '$special[property.name]', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """SpecialModelName - a model defined in OpenAPI + """special_model_name.SpecialModelName - a model defined in OpenAPI Keyword Args: @@ -102,6 +108,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. special_property_name (int): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -109,126 +116,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def special_property_name(self): - """Gets the special_property_name of this SpecialModelName. # noqa: E501 - - Returns: - (int): The special_property_name of this SpecialModelName. # noqa: E501 - """ - return self.__get_item('special_property_name') - - @special_property_name.setter - def special_property_name(self, value): - """Sets the special_property_name of this SpecialModelName. # noqa: E501 - """ - return self.__set_item('special_property_name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, SpecialModelName): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py b/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py index 1d10f9a8d7ed..19b3cd131c08 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,9 +59,6 @@ class StringBooleanMap(ModelNormal): allowed_values = { } - attribute_map = { - } - openapi_types = { } @@ -78,10 +67,27 @@ class StringBooleanMap(ModelNormal): additional_properties_type = (bool,) # noqa: E501 - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """StringBooleanMap - a model defined in OpenAPI + """string_boolean_map.StringBooleanMap - a model defined in OpenAPI Keyword Args: @@ -99,6 +105,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If passed, type conversion is attempted If omitted no type conversion is done. """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -106,111 +113,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, StringBooleanMap): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/tag.py b/samples/client/petstore/python-experimental/petstore_api/models/tag.py index 4e1fd5ef077e..590b234d4d42 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/tag.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/tag.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,14 +59,10 @@ class Tag(ModelNormal): allowed_values = { } - attribute_map = { - 'id': 'id', # noqa: E501 - 'name': 'name' # noqa: E501 - } - openapi_types = { 'id': (int,), # noqa: E501 'name': (str,), # noqa: E501 + 'full_name': (str,), # noqa: E501 } validations = { @@ -82,10 +70,30 @@ class Tag(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'id': 'id', # noqa: E501 + 'name': 'name', # noqa: E501 + 'full_name': 'fullName', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """Tag - a model defined in OpenAPI + """tag.Tag - a model defined in OpenAPI Keyword Args: @@ -104,7 +112,9 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf If omitted no type conversion is done. id (int): [optional] # noqa: E501 name (str): [optional] # noqa: E501 + full_name (str): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -112,141 +122,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def id(self): - """Gets the id of this Tag. # noqa: E501 - - Returns: - (int): The id of this Tag. # noqa: E501 - """ - return self.__get_item('id') - - @id.setter - def id(self, value): - """Sets the id of this Tag. # noqa: E501 - """ - return self.__set_item('id', value) - - @property - def name(self): - """Gets the name of this Tag. # noqa: E501 - - Returns: - (str): The name of this Tag. # noqa: E501 - """ - return self.__get_item('name') - - @name.setter - def name(self, value): - """Sets the name of this Tag. # noqa: E501 - """ - return self.__set_item('name', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Tag): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py index 26f1d9044524..71b4719f5dd0 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_default.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,24 +59,14 @@ class TypeHolderDefault(ModelNormal): allowed_values = { } - attribute_map = { - 'string_item': 'string_item', # noqa: E501 - 'number_item': 'number_item', # noqa: E501 - 'integer_item': 'integer_item', # noqa: E501 - 'bool_item': 'bool_item', # noqa: E501 - 'date_item': 'date_item', # noqa: E501 - 'datetime_item': 'datetime_item', # noqa: E501 - 'array_item': 'array_item' # noqa: E501 - } - openapi_types = { 'string_item': (str,), # noqa: E501 'number_item': (float,), # noqa: E501 'integer_item': (int,), # noqa: E501 'bool_item': (bool,), # noqa: E501 + 'array_item': ([int],), # noqa: E501 'date_item': (date,), # noqa: E501 'datetime_item': (datetime,), # noqa: E501 - 'array_item': ([int],), # noqa: E501 } validations = { @@ -92,10 +74,34 @@ class TypeHolderDefault(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'string_item': 'string_item', # noqa: E501 + 'number_item': 'number_item', # noqa: E501 + 'integer_item': 'integer_item', # noqa: E501 + 'bool_item': 'bool_item', # noqa: E501 + 'array_item': 'array_item', # noqa: E501 + 'date_item': 'date_item', # noqa: E501 + 'datetime_item': 'datetime_item', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, array_item, string_item='what', number_item=1.234, integer_item=-2, bool_item=True, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """TypeHolderDefault - a model defined in OpenAPI + """type_holder_default.TypeHolderDefault - a model defined in OpenAPI Args: array_item ([int]): @@ -121,228 +127,17 @@ def __init__(self, array_item, string_item='what', number_item=1.234, integer_it date_item (date): [optional] # noqa: E501 datetime_item (datetime): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('string_item', string_item) - self.__set_item('number_item', number_item) - self.__set_item('integer_item', integer_item) - self.__set_item('bool_item', bool_item) - self.__set_item('array_item', array_item) + self.string_item = string_item + self.number_item = number_item + self.integer_item = integer_item + self.bool_item = bool_item + self.array_item = array_item for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def string_item(self): - """Gets the string_item of this TypeHolderDefault. # noqa: E501 - - Returns: - (str): The string_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__get_item('string_item') - - @string_item.setter - def string_item(self, value): - """Sets the string_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__set_item('string_item', value) - - @property - def number_item(self): - """Gets the number_item of this TypeHolderDefault. # noqa: E501 - - Returns: - (float): The number_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__get_item('number_item') - - @number_item.setter - def number_item(self, value): - """Sets the number_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__set_item('number_item', value) - - @property - def integer_item(self): - """Gets the integer_item of this TypeHolderDefault. # noqa: E501 - - Returns: - (int): The integer_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__get_item('integer_item') - - @integer_item.setter - def integer_item(self, value): - """Sets the integer_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__set_item('integer_item', value) - - @property - def bool_item(self): - """Gets the bool_item of this TypeHolderDefault. # noqa: E501 - - Returns: - (bool): The bool_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__get_item('bool_item') - - @bool_item.setter - def bool_item(self, value): - """Sets the bool_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__set_item('bool_item', value) - - @property - def date_item(self): - """Gets the date_item of this TypeHolderDefault. # noqa: E501 - - Returns: - (date): The date_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__get_item('date_item') - - @date_item.setter - def date_item(self, value): - """Sets the date_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__set_item('date_item', value) - - @property - def datetime_item(self): - """Gets the datetime_item of this TypeHolderDefault. # noqa: E501 - - Returns: - (datetime): The datetime_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__get_item('datetime_item') - - @datetime_item.setter - def datetime_item(self, value): - """Sets the datetime_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__set_item('datetime_item', value) - - @property - def array_item(self): - """Gets the array_item of this TypeHolderDefault. # noqa: E501 - - Returns: - ([int]): The array_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__get_item('array_item') - - @array_item.setter - def array_item(self, value): - """Sets the array_item of this TypeHolderDefault. # noqa: E501 - """ - return self.__set_item('array_item', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, TypeHolderDefault): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py index b4fb4770d1e7..96b8551dd1a5 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/type_holder_example.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -76,14 +68,6 @@ class TypeHolderExample(ModelNormal): }, } - attribute_map = { - 'string_item': 'string_item', # noqa: E501 - 'number_item': 'number_item', # noqa: E501 - 'integer_item': 'integer_item', # noqa: E501 - 'bool_item': 'bool_item', # noqa: E501 - 'array_item': 'array_item' # noqa: E501 - } - openapi_types = { 'string_item': (str,), # noqa: E501 'number_item': (float,), # noqa: E501 @@ -97,10 +81,32 @@ class TypeHolderExample(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'string_item': 'string_item', # noqa: E501 + 'number_item': 'number_item', # noqa: E501 + 'integer_item': 'integer_item', # noqa: E501 + 'bool_item': 'bool_item', # noqa: E501 + 'array_item': 'array_item', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, bool_item, array_item, string_item='what', number_item=1.234, integer_item=-2, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """TypeHolderExample - a model defined in OpenAPI + """type_holder_example.TypeHolderExample - a model defined in OpenAPI Args: bool_item (bool): @@ -124,198 +130,17 @@ def __init__(self, bool_item, array_item, string_item='what', number_item=1.234, If passed, type conversion is attempted If omitted no type conversion is done. """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server self._path_to_item = _path_to_item self._configuration = _configuration - self.__set_item('string_item', string_item) - self.__set_item('number_item', number_item) - self.__set_item('integer_item', integer_item) - self.__set_item('bool_item', bool_item) - self.__set_item('array_item', array_item) + self.string_item = string_item + self.number_item = number_item + self.integer_item = integer_item + self.bool_item = bool_item + self.array_item = array_item for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def string_item(self): - """Gets the string_item of this TypeHolderExample. # noqa: E501 - - Returns: - (str): The string_item of this TypeHolderExample. # noqa: E501 - """ - return self.__get_item('string_item') - - @string_item.setter - def string_item(self, value): - """Sets the string_item of this TypeHolderExample. # noqa: E501 - """ - return self.__set_item('string_item', value) - - @property - def number_item(self): - """Gets the number_item of this TypeHolderExample. # noqa: E501 - - Returns: - (float): The number_item of this TypeHolderExample. # noqa: E501 - """ - return self.__get_item('number_item') - - @number_item.setter - def number_item(self, value): - """Sets the number_item of this TypeHolderExample. # noqa: E501 - """ - return self.__set_item('number_item', value) - - @property - def integer_item(self): - """Gets the integer_item of this TypeHolderExample. # noqa: E501 - - Returns: - (int): The integer_item of this TypeHolderExample. # noqa: E501 - """ - return self.__get_item('integer_item') - - @integer_item.setter - def integer_item(self, value): - """Sets the integer_item of this TypeHolderExample. # noqa: E501 - """ - return self.__set_item('integer_item', value) - - @property - def bool_item(self): - """Gets the bool_item of this TypeHolderExample. # noqa: E501 - - Returns: - (bool): The bool_item of this TypeHolderExample. # noqa: E501 - """ - return self.__get_item('bool_item') - - @bool_item.setter - def bool_item(self, value): - """Sets the bool_item of this TypeHolderExample. # noqa: E501 - """ - return self.__set_item('bool_item', value) - - @property - def array_item(self): - """Gets the array_item of this TypeHolderExample. # noqa: E501 - - Returns: - ([int]): The array_item of this TypeHolderExample. # noqa: E501 - """ - return self.__get_item('array_item') - - @array_item.setter - def array_item(self, value): - """Sets the array_item of this TypeHolderExample. # noqa: E501 - """ - return self.__set_item('array_item', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, TypeHolderExample): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/user.py b/samples/client/petstore/python-experimental/petstore_api/models/user.py index 6d4d4539a849..03b3ef6a5e69 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/user.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/user.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,17 +59,6 @@ class User(ModelNormal): allowed_values = { } - attribute_map = { - 'id': 'id', # noqa: E501 - 'username': 'username', # noqa: E501 - 'first_name': 'firstName', # noqa: E501 - 'last_name': 'lastName', # noqa: E501 - 'email': 'email', # noqa: E501 - 'password': 'password', # noqa: E501 - 'phone': 'phone', # noqa: E501 - 'user_status': 'userStatus' # noqa: E501 - } - openapi_types = { 'id': (int,), # noqa: E501 'username': (str,), # noqa: E501 @@ -94,10 +75,35 @@ class User(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'id': 'id', # noqa: E501 + 'username': 'username', # noqa: E501 + 'first_name': 'firstName', # noqa: E501 + 'last_name': 'lastName', # noqa: E501 + 'email': 'email', # noqa: E501 + 'password': 'password', # noqa: E501 + 'phone': 'phone', # noqa: E501 + 'user_status': 'userStatus', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """User - a model defined in OpenAPI + """user.User - a model defined in OpenAPI Keyword Args: @@ -123,6 +129,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf phone (str): [optional] # noqa: E501 user_status (int): User Status. [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -130,233 +137,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def id(self): - """Gets the id of this User. # noqa: E501 - - Returns: - (int): The id of this User. # noqa: E501 - """ - return self.__get_item('id') - - @id.setter - def id(self, value): - """Sets the id of this User. # noqa: E501 - """ - return self.__set_item('id', value) - - @property - def username(self): - """Gets the username of this User. # noqa: E501 - - Returns: - (str): The username of this User. # noqa: E501 - """ - return self.__get_item('username') - - @username.setter - def username(self, value): - """Sets the username of this User. # noqa: E501 - """ - return self.__set_item('username', value) - - @property - def first_name(self): - """Gets the first_name of this User. # noqa: E501 - - Returns: - (str): The first_name of this User. # noqa: E501 - """ - return self.__get_item('first_name') - - @first_name.setter - def first_name(self, value): - """Sets the first_name of this User. # noqa: E501 - """ - return self.__set_item('first_name', value) - - @property - def last_name(self): - """Gets the last_name of this User. # noqa: E501 - - Returns: - (str): The last_name of this User. # noqa: E501 - """ - return self.__get_item('last_name') - - @last_name.setter - def last_name(self, value): - """Sets the last_name of this User. # noqa: E501 - """ - return self.__set_item('last_name', value) - - @property - def email(self): - """Gets the email of this User. # noqa: E501 - - Returns: - (str): The email of this User. # noqa: E501 - """ - return self.__get_item('email') - - @email.setter - def email(self, value): - """Sets the email of this User. # noqa: E501 - """ - return self.__set_item('email', value) - - @property - def password(self): - """Gets the password of this User. # noqa: E501 - - Returns: - (str): The password of this User. # noqa: E501 - """ - return self.__get_item('password') - - @password.setter - def password(self, value): - """Sets the password of this User. # noqa: E501 - """ - return self.__set_item('password', value) - - @property - def phone(self): - """Gets the phone of this User. # noqa: E501 - - Returns: - (str): The phone of this User. # noqa: E501 - """ - return self.__get_item('phone') - - @phone.setter - def phone(self, value): - """Sets the phone of this User. # noqa: E501 - """ - return self.__set_item('phone', value) - - @property - def user_status(self): - """Gets the user_status of this User. # noqa: E501 - User Status # noqa: E501 - - Returns: - (int): The user_status of this User. # noqa: E501 - """ - return self.__get_item('user_status') - - @user_status.setter - def user_status(self, value): - """Sets the user_status of this User. # noqa: E501 - User Status # noqa: E501 - """ - return self.__set_item('user_status', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, User): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py b/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py index f7ded778c292..a38afa9cfbec 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/xml_item.py @@ -10,31 +10,23 @@ """ -import pprint # noqa: F401 +from __future__ import absolute_import import re # noqa: F401 +import sys # noqa: F401 import six # noqa: F401 -from petstore_api.exceptions import ( # noqa: F401 - ApiKeyError, - ApiTypeError, - ApiValueError, -) from petstore_api.model_utils import ( # noqa: F401 + ModelComposed, ModelNormal, ModelSimple, - check_allowed_values, - check_validations, date, datetime, file_type, - get_simple_class, int, - model_to_dict, none_type, str, - type_error_message, - validate_and_convert_types + validate_get_composed_info, ) @@ -67,38 +59,6 @@ class XmlItem(ModelNormal): allowed_values = { } - attribute_map = { - 'attribute_string': 'attribute_string', # noqa: E501 - 'attribute_number': 'attribute_number', # noqa: E501 - 'attribute_integer': 'attribute_integer', # noqa: E501 - 'attribute_boolean': 'attribute_boolean', # noqa: E501 - 'wrapped_array': 'wrapped_array', # noqa: E501 - 'name_string': 'name_string', # noqa: E501 - 'name_number': 'name_number', # noqa: E501 - 'name_integer': 'name_integer', # noqa: E501 - 'name_boolean': 'name_boolean', # noqa: E501 - 'name_array': 'name_array', # noqa: E501 - 'name_wrapped_array': 'name_wrapped_array', # noqa: E501 - 'prefix_string': 'prefix_string', # noqa: E501 - 'prefix_number': 'prefix_number', # noqa: E501 - 'prefix_integer': 'prefix_integer', # noqa: E501 - 'prefix_boolean': 'prefix_boolean', # noqa: E501 - 'prefix_array': 'prefix_array', # noqa: E501 - 'prefix_wrapped_array': 'prefix_wrapped_array', # noqa: E501 - 'namespace_string': 'namespace_string', # noqa: E501 - 'namespace_number': 'namespace_number', # noqa: E501 - 'namespace_integer': 'namespace_integer', # noqa: E501 - 'namespace_boolean': 'namespace_boolean', # noqa: E501 - 'namespace_array': 'namespace_array', # noqa: E501 - 'namespace_wrapped_array': 'namespace_wrapped_array', # noqa: E501 - 'prefix_ns_string': 'prefix_ns_string', # noqa: E501 - 'prefix_ns_number': 'prefix_ns_number', # noqa: E501 - 'prefix_ns_integer': 'prefix_ns_integer', # noqa: E501 - 'prefix_ns_boolean': 'prefix_ns_boolean', # noqa: E501 - 'prefix_ns_array': 'prefix_ns_array', # noqa: E501 - 'prefix_ns_wrapped_array': 'prefix_ns_wrapped_array' # noqa: E501 - } - openapi_types = { 'attribute_string': (str,), # noqa: E501 'attribute_number': (float,), # noqa: E501 @@ -136,10 +96,56 @@ class XmlItem(ModelNormal): additional_properties_type = None - discriminator = None + @staticmethod + def discriminator(): + return None + + attribute_map = { + 'attribute_string': 'attribute_string', # noqa: E501 + 'attribute_number': 'attribute_number', # noqa: E501 + 'attribute_integer': 'attribute_integer', # noqa: E501 + 'attribute_boolean': 'attribute_boolean', # noqa: E501 + 'wrapped_array': 'wrapped_array', # noqa: E501 + 'name_string': 'name_string', # noqa: E501 + 'name_number': 'name_number', # noqa: E501 + 'name_integer': 'name_integer', # noqa: E501 + 'name_boolean': 'name_boolean', # noqa: E501 + 'name_array': 'name_array', # noqa: E501 + 'name_wrapped_array': 'name_wrapped_array', # noqa: E501 + 'prefix_string': 'prefix_string', # noqa: E501 + 'prefix_number': 'prefix_number', # noqa: E501 + 'prefix_integer': 'prefix_integer', # noqa: E501 + 'prefix_boolean': 'prefix_boolean', # noqa: E501 + 'prefix_array': 'prefix_array', # noqa: E501 + 'prefix_wrapped_array': 'prefix_wrapped_array', # noqa: E501 + 'namespace_string': 'namespace_string', # noqa: E501 + 'namespace_number': 'namespace_number', # noqa: E501 + 'namespace_integer': 'namespace_integer', # noqa: E501 + 'namespace_boolean': 'namespace_boolean', # noqa: E501 + 'namespace_array': 'namespace_array', # noqa: E501 + 'namespace_wrapped_array': 'namespace_wrapped_array', # noqa: E501 + 'prefix_ns_string': 'prefix_ns_string', # noqa: E501 + 'prefix_ns_number': 'prefix_ns_number', # noqa: E501 + 'prefix_ns_integer': 'prefix_ns_integer', # noqa: E501 + 'prefix_ns_boolean': 'prefix_ns_boolean', # noqa: E501 + 'prefix_ns_array': 'prefix_ns_array', # noqa: E501 + 'prefix_ns_wrapped_array': 'prefix_ns_wrapped_array', # noqa: E501 + } + + @staticmethod + def _composed_schemas(): + return None + + required_properties = set([ + '_data_store', + '_check_type', + '_from_server', + '_path_to_item', + '_configuration', + ]) def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501 - """XmlItem - a model defined in OpenAPI + """xml_item.XmlItem - a model defined in OpenAPI Keyword Args: @@ -186,6 +192,7 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf prefix_ns_array ([int]): [optional] # noqa: E501 prefix_ns_wrapped_array ([int]): [optional] # noqa: E501 """ + self._data_store = {} self._check_type = _check_type self._from_server = _from_server @@ -193,546 +200,4 @@ def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _conf self._configuration = _configuration for var_name, var_value in six.iteritems(kwargs): - self.__set_item(var_name, var_value) - - def __set_item(self, name, value): - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - - if name in self.openapi_types: - required_types_mixed = self.openapi_types[name] - elif self.additional_properties_type is None: - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - path_to_item - ) - elif self.additional_properties_type is not None: - required_types_mixed = self.additional_properties_type - - if get_simple_class(name) != str: - error_msg = type_error_message( - var_name=name, - var_value=name, - valid_classes=(str,), - key_type=True - ) - raise ApiTypeError( - error_msg, - path_to_item=path_to_item, - valid_classes=(str,), - key_type=True - ) - - if self._check_type: - value = validate_and_convert_types( - value, required_types_mixed, path_to_item, self._from_server, - self._check_type, configuration=self._configuration) - if (name,) in self.allowed_values: - check_allowed_values( - self.allowed_values, - (name,), - value - ) - if (name,) in self.validations: - check_validations( - self.validations, - (name,), - value - ) - self._data_store[name] = value - - def __get_item(self, name): - if name in self._data_store: - return self._data_store[name] - - path_to_item = [] - if self._path_to_item: - path_to_item.extend(self._path_to_item) - path_to_item.append(name) - raise ApiKeyError( - "{0} has no key '{1}'".format(type(self).__name__, name), - [name] - ) - - def __setitem__(self, name, value): - """this allows us to set values with instance[field_name] = val""" - self.__set_item(name, value) - - def __getitem__(self, name): - """this allows us to get a value with val = instance[field_name]""" - return self.__get_item(name) - - @property - def attribute_string(self): - """Gets the attribute_string of this XmlItem. # noqa: E501 - - Returns: - (str): The attribute_string of this XmlItem. # noqa: E501 - """ - return self.__get_item('attribute_string') - - @attribute_string.setter - def attribute_string(self, value): - """Sets the attribute_string of this XmlItem. # noqa: E501 - """ - return self.__set_item('attribute_string', value) - - @property - def attribute_number(self): - """Gets the attribute_number of this XmlItem. # noqa: E501 - - Returns: - (float): The attribute_number of this XmlItem. # noqa: E501 - """ - return self.__get_item('attribute_number') - - @attribute_number.setter - def attribute_number(self, value): - """Sets the attribute_number of this XmlItem. # noqa: E501 - """ - return self.__set_item('attribute_number', value) - - @property - def attribute_integer(self): - """Gets the attribute_integer of this XmlItem. # noqa: E501 - - Returns: - (int): The attribute_integer of this XmlItem. # noqa: E501 - """ - return self.__get_item('attribute_integer') - - @attribute_integer.setter - def attribute_integer(self, value): - """Sets the attribute_integer of this XmlItem. # noqa: E501 - """ - return self.__set_item('attribute_integer', value) - - @property - def attribute_boolean(self): - """Gets the attribute_boolean of this XmlItem. # noqa: E501 - - Returns: - (bool): The attribute_boolean of this XmlItem. # noqa: E501 - """ - return self.__get_item('attribute_boolean') - - @attribute_boolean.setter - def attribute_boolean(self, value): - """Sets the attribute_boolean of this XmlItem. # noqa: E501 - """ - return self.__set_item('attribute_boolean', value) - - @property - def wrapped_array(self): - """Gets the wrapped_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('wrapped_array') - - @wrapped_array.setter - def wrapped_array(self, value): - """Sets the wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('wrapped_array', value) - - @property - def name_string(self): - """Gets the name_string of this XmlItem. # noqa: E501 - - Returns: - (str): The name_string of this XmlItem. # noqa: E501 - """ - return self.__get_item('name_string') - - @name_string.setter - def name_string(self, value): - """Sets the name_string of this XmlItem. # noqa: E501 - """ - return self.__set_item('name_string', value) - - @property - def name_number(self): - """Gets the name_number of this XmlItem. # noqa: E501 - - Returns: - (float): The name_number of this XmlItem. # noqa: E501 - """ - return self.__get_item('name_number') - - @name_number.setter - def name_number(self, value): - """Sets the name_number of this XmlItem. # noqa: E501 - """ - return self.__set_item('name_number', value) - - @property - def name_integer(self): - """Gets the name_integer of this XmlItem. # noqa: E501 - - Returns: - (int): The name_integer of this XmlItem. # noqa: E501 - """ - return self.__get_item('name_integer') - - @name_integer.setter - def name_integer(self, value): - """Sets the name_integer of this XmlItem. # noqa: E501 - """ - return self.__set_item('name_integer', value) - - @property - def name_boolean(self): - """Gets the name_boolean of this XmlItem. # noqa: E501 - - Returns: - (bool): The name_boolean of this XmlItem. # noqa: E501 - """ - return self.__get_item('name_boolean') - - @name_boolean.setter - def name_boolean(self, value): - """Sets the name_boolean of this XmlItem. # noqa: E501 - """ - return self.__set_item('name_boolean', value) - - @property - def name_array(self): - """Gets the name_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The name_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('name_array') - - @name_array.setter - def name_array(self, value): - """Sets the name_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('name_array', value) - - @property - def name_wrapped_array(self): - """Gets the name_wrapped_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The name_wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('name_wrapped_array') - - @name_wrapped_array.setter - def name_wrapped_array(self, value): - """Sets the name_wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('name_wrapped_array', value) - - @property - def prefix_string(self): - """Gets the prefix_string of this XmlItem. # noqa: E501 - - Returns: - (str): The prefix_string of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_string') - - @prefix_string.setter - def prefix_string(self, value): - """Sets the prefix_string of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_string', value) - - @property - def prefix_number(self): - """Gets the prefix_number of this XmlItem. # noqa: E501 - - Returns: - (float): The prefix_number of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_number') - - @prefix_number.setter - def prefix_number(self, value): - """Sets the prefix_number of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_number', value) - - @property - def prefix_integer(self): - """Gets the prefix_integer of this XmlItem. # noqa: E501 - - Returns: - (int): The prefix_integer of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_integer') - - @prefix_integer.setter - def prefix_integer(self, value): - """Sets the prefix_integer of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_integer', value) - - @property - def prefix_boolean(self): - """Gets the prefix_boolean of this XmlItem. # noqa: E501 - - Returns: - (bool): The prefix_boolean of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_boolean') - - @prefix_boolean.setter - def prefix_boolean(self, value): - """Sets the prefix_boolean of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_boolean', value) - - @property - def prefix_array(self): - """Gets the prefix_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The prefix_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_array') - - @prefix_array.setter - def prefix_array(self, value): - """Sets the prefix_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_array', value) - - @property - def prefix_wrapped_array(self): - """Gets the prefix_wrapped_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The prefix_wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_wrapped_array') - - @prefix_wrapped_array.setter - def prefix_wrapped_array(self, value): - """Sets the prefix_wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_wrapped_array', value) - - @property - def namespace_string(self): - """Gets the namespace_string of this XmlItem. # noqa: E501 - - Returns: - (str): The namespace_string of this XmlItem. # noqa: E501 - """ - return self.__get_item('namespace_string') - - @namespace_string.setter - def namespace_string(self, value): - """Sets the namespace_string of this XmlItem. # noqa: E501 - """ - return self.__set_item('namespace_string', value) - - @property - def namespace_number(self): - """Gets the namespace_number of this XmlItem. # noqa: E501 - - Returns: - (float): The namespace_number of this XmlItem. # noqa: E501 - """ - return self.__get_item('namespace_number') - - @namespace_number.setter - def namespace_number(self, value): - """Sets the namespace_number of this XmlItem. # noqa: E501 - """ - return self.__set_item('namespace_number', value) - - @property - def namespace_integer(self): - """Gets the namespace_integer of this XmlItem. # noqa: E501 - - Returns: - (int): The namespace_integer of this XmlItem. # noqa: E501 - """ - return self.__get_item('namespace_integer') - - @namespace_integer.setter - def namespace_integer(self, value): - """Sets the namespace_integer of this XmlItem. # noqa: E501 - """ - return self.__set_item('namespace_integer', value) - - @property - def namespace_boolean(self): - """Gets the namespace_boolean of this XmlItem. # noqa: E501 - - Returns: - (bool): The namespace_boolean of this XmlItem. # noqa: E501 - """ - return self.__get_item('namespace_boolean') - - @namespace_boolean.setter - def namespace_boolean(self, value): - """Sets the namespace_boolean of this XmlItem. # noqa: E501 - """ - return self.__set_item('namespace_boolean', value) - - @property - def namespace_array(self): - """Gets the namespace_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The namespace_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('namespace_array') - - @namespace_array.setter - def namespace_array(self, value): - """Sets the namespace_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('namespace_array', value) - - @property - def namespace_wrapped_array(self): - """Gets the namespace_wrapped_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The namespace_wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('namespace_wrapped_array') - - @namespace_wrapped_array.setter - def namespace_wrapped_array(self, value): - """Sets the namespace_wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('namespace_wrapped_array', value) - - @property - def prefix_ns_string(self): - """Gets the prefix_ns_string of this XmlItem. # noqa: E501 - - Returns: - (str): The prefix_ns_string of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_ns_string') - - @prefix_ns_string.setter - def prefix_ns_string(self, value): - """Sets the prefix_ns_string of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_ns_string', value) - - @property - def prefix_ns_number(self): - """Gets the prefix_ns_number of this XmlItem. # noqa: E501 - - Returns: - (float): The prefix_ns_number of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_ns_number') - - @prefix_ns_number.setter - def prefix_ns_number(self, value): - """Sets the prefix_ns_number of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_ns_number', value) - - @property - def prefix_ns_integer(self): - """Gets the prefix_ns_integer of this XmlItem. # noqa: E501 - - Returns: - (int): The prefix_ns_integer of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_ns_integer') - - @prefix_ns_integer.setter - def prefix_ns_integer(self, value): - """Sets the prefix_ns_integer of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_ns_integer', value) - - @property - def prefix_ns_boolean(self): - """Gets the prefix_ns_boolean of this XmlItem. # noqa: E501 - - Returns: - (bool): The prefix_ns_boolean of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_ns_boolean') - - @prefix_ns_boolean.setter - def prefix_ns_boolean(self, value): - """Sets the prefix_ns_boolean of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_ns_boolean', value) - - @property - def prefix_ns_array(self): - """Gets the prefix_ns_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The prefix_ns_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_ns_array') - - @prefix_ns_array.setter - def prefix_ns_array(self, value): - """Sets the prefix_ns_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_ns_array', value) - - @property - def prefix_ns_wrapped_array(self): - """Gets the prefix_ns_wrapped_array of this XmlItem. # noqa: E501 - - Returns: - ([int]): The prefix_ns_wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__get_item('prefix_ns_wrapped_array') - - @prefix_ns_wrapped_array.setter - def prefix_ns_wrapped_array(self, value): - """Sets the prefix_ns_wrapped_array of this XmlItem. # noqa: E501 - """ - return self.__set_item('prefix_ns_wrapped_array', value) - - def to_dict(self): - """Returns the model properties as a dict""" - return model_to_dict(self, serialize=False) - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, XmlItem): - return False - - if not set(self._data_store.keys()) == set(other._data_store.keys()): - return False - for _var_name, this_val in six.iteritems(self._data_store): - that_val = other._data_store[_var_name] - types = set() - types.add(this_val.__class__) - types.add(that_val.__class__) - vals_equal = this_val == that_val - if (not six.PY3 and - len(types) == 2 and unicode in types): # noqa: F821 - vals_equal = ( - this_val.encode('utf-8') == that_val.encode('utf-8') - ) - if not vals_equal: - return False - return True - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other + setattr(self, var_name, var_value) diff --git a/samples/client/petstore/python-experimental/test/test_child.py b/samples/client/petstore/python-experimental/test/test_child.py new file mode 100644 index 000000000000..96023582c4fd --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_child.py @@ -0,0 +1,138 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestChild(unittest.TestCase): + """Child unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChild(self): + """Test Child""" + + # make an instance of Child, a composed schema model + radio_waves = True + tele_vision = True + inter_net = True + child = petstore_api.Child( + radio_waves=radio_waves, + tele_vision=tele_vision, + inter_net=inter_net + ) + + # check its properties + self.assertEqual(child.radio_waves, radio_waves) + self.assertEqual(child.tele_vision, tele_vision) + self.assertEqual(child.inter_net, inter_net) + # access them with keys + self.assertEqual(child['radio_waves'], radio_waves) + self.assertEqual(child['tele_vision'], tele_vision) + self.assertEqual(child['inter_net'], inter_net) + # access them with getattr + self.assertEqual(getattr(child, 'radio_waves'), radio_waves) + self.assertEqual(getattr(child, 'tele_vision'), tele_vision) + self.assertEqual(getattr(child, 'inter_net'), inter_net) + + # check the model's to_dict result + self.assertEqual( + child.to_dict(), + { + 'radio_waves': radio_waves, + 'tele_vision': tele_vision, + 'inter_net': inter_net, + } + ) + + # setting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + child['invalid_variable'] = 'some value' + # with setattr + with self.assertRaises(petstore_api.ApiKeyError): + setattr(child, 'invalid_variable', 'some value') + + # getting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = child['invalid_variable'] + # with getattr + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = getattr(child, 'invalid_variable', 'some value') + + # make sure that the ModelComposed class properties are correct + # model.composed_schemas() stores the anyOf/allOf/oneOf info + self.assertEqual( + child._composed_schemas(), + { + 'anyOf': [], + 'allOf': [ + petstore_api.ChildAllOf, + petstore_api.Parent, + ], + 'oneOf': [], + } + ) + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in child._composed_instances: + if composed_instance.__class__ == petstore_api.Parent: + parent_instance = composed_instance + elif composed_instance.__class__ == petstore_api.ChildAllOf: + child_allof_instance = composed_instance + self.assertEqual( + child._composed_instances, + [child_allof_instance, parent_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + child._var_name_to_model_instances, + { + 'radio_waves': [child, parent_instance], + 'tele_vision': [child, parent_instance], + 'inter_net': [child, child_allof_instance] + } + ) + # model._additional_properties_model_instances stores a list of + # models which have the property additional_properties_type != None + self.assertEqual( + child._additional_properties_model_instances, [] + ) + + # if we modify one of the properties owned by multiple + # model_instances we get an exception when we try to access that + # property because the retrieved values are not all the same + child_allof_instance.inter_net = False + with self.assertRaises(petstore_api.ApiValueError): + inter_net = child.inter_net + + # including extra parameters raises an exception + with self.assertRaises(petstore_api.ApiValueError): + child = petstore_api.Child( + radio_waves=radio_waves, + tele_vision=tele_vision, + inter_net=inter_net, + unknown_property='some value' + ) + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_child_all_of.py b/samples/client/petstore/python-experimental/test/test_child_all_of.py new file mode 100644 index 000000000000..e3f14035f625 --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_child_all_of.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestChildAllOf(unittest.TestCase): + """ChildAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildAllOf(self): + """Test ChildAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ChildAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_child_cat.py b/samples/client/petstore/python-experimental/test/test_child_cat.py new file mode 100644 index 000000000000..c42c3b583aae --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_child_cat.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestChildCat(unittest.TestCase): + """ChildCat unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildCat(self): + """Test ChildCat""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ChildCat() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_child_cat_all_of.py b/samples/client/petstore/python-experimental/test/test_child_cat_all_of.py new file mode 100644 index 000000000000..3304a81a2321 --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_child_cat_all_of.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestChildCatAllOf(unittest.TestCase): + """ChildCatAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildCatAllOf(self): + """Test ChildCatAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ChildCatAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_child_dog.py b/samples/client/petstore/python-experimental/test/test_child_dog.py new file mode 100644 index 000000000000..9c56f27bbc49 --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_child_dog.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestChildDog(unittest.TestCase): + """ChildDog unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildDog(self): + """Test ChildDog""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ChildDog() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_child_dog_all_of.py b/samples/client/petstore/python-experimental/test/test_child_dog_all_of.py new file mode 100644 index 000000000000..a9124db412b7 --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_child_dog_all_of.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestChildDogAllOf(unittest.TestCase): + """ChildDogAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildDogAllOf(self): + """Test ChildDogAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ChildDogAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_child_lizard.py b/samples/client/petstore/python-experimental/test/test_child_lizard.py new file mode 100644 index 000000000000..21ba88480aad --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_child_lizard.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestChildLizard(unittest.TestCase): + """ChildLizard unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildLizard(self): + """Test ChildLizard""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ChildLizard() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_child_lizard_all_of.py b/samples/client/petstore/python-experimental/test/test_child_lizard_all_of.py new file mode 100644 index 000000000000..824e376f855b --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_child_lizard_all_of.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestChildLizardAllOf(unittest.TestCase): + """ChildLizardAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testChildLizardAllOf(self): + """Test ChildLizardAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ChildLizardAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_dog.py b/samples/client/petstore/python-experimental/test/test_dog.py index dc151f998ddd..cb1f3230a067 100644 --- a/samples/client/petstore/python-experimental/test/test_dog.py +++ b/samples/client/petstore/python-experimental/test/test_dog.py @@ -5,7 +5,7 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 - OpenAPI spec version: 1.0.0 + The version of the OpenAPI document: 1.0.0 Generated by: https://openapi-generator.tech """ @@ -15,8 +15,6 @@ import unittest import petstore_api -from petstore_api.models.dog import Dog # noqa: E501 -from petstore_api.rest import ApiException class TestDog(unittest.TestCase): @@ -30,9 +28,111 @@ def tearDown(self): def testDog(self): """Test Dog""" - # FIXME: construct object with mandatory attributes with example values - # model = petstore_api.models.dog.Dog() # noqa: E501 - pass + + # make an instance of dog, a composed schema model + class_name = 'Dog' + color = 'white' + breed = 'Jack Russel Terrier' + dog = petstore_api.Dog( + class_name=class_name, + color=color, + breed=breed + ) + + # check its properties + self.assertEqual(dog.class_name, class_name) + self.assertEqual(dog.color, color) + self.assertEqual(dog.breed, breed) + # access them with keys + self.assertEqual(dog['class_name'], class_name) + self.assertEqual(dog['color'], color) + self.assertEqual(dog['breed'], breed) + # access them with getattr + self.assertEqual(getattr(dog, 'class_name'), class_name) + self.assertEqual(getattr(dog, 'color'), color) + self.assertEqual(getattr(dog, 'breed'), breed) + + # check the model's to_dict result + self.assertEqual( + dog.to_dict(), + { + 'class_name': class_name, + 'color': color, + 'breed': breed, + } + ) + + # setting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + dog['invalid_variable'] = 'some value' + # with setattr + with self.assertRaises(petstore_api.ApiKeyError): + setattr(dog, 'invalid_variable', 'some value') + + # getting a value that doesn't exist raises an exception + # with a key + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = dog['invalid_variable'] + # with getattr + with self.assertRaises(petstore_api.ApiKeyError): + invalid_variable = getattr(dog, 'invalid_variable', 'some value') + + # make sure that the ModelComposed class properties are correct + # model.composed_schemas() stores the anyOf/allOf/oneOf info + self.assertEqual( + dog._composed_schemas(), + { + 'anyOf': [], + 'allOf': [ + petstore_api.Animal, + petstore_api.DogAllOf, + ], + 'oneOf': [], + } + ) + # model._composed_instances is a list of the instances that were + # made from the anyOf/allOf/OneOf classes in model._composed_schemas() + for composed_instance in dog._composed_instances: + if composed_instance.__class__ == petstore_api.Animal: + animal_instance = composed_instance + elif composed_instance.__class__ == petstore_api.DogAllOf: + dog_allof_instance = composed_instance + self.assertEqual( + dog._composed_instances, + [animal_instance, dog_allof_instance] + ) + # model._var_name_to_model_instances maps the variable name to the + # model instances which store that variable + self.assertEqual( + dog._var_name_to_model_instances, + { + 'breed': [dog, dog_allof_instance], + 'class_name': [dog, animal_instance], + 'color': [dog, animal_instance] + } + ) + # model._additional_properties_model_instances stores a list of + # models which have the property additional_properties_type != None + self.assertEqual( + dog._additional_properties_model_instances, [] + ) + + # if we modify one of the properties owned by multiple + # model_instances we get an exception when we try to access that + # property because the retrieved values are not all the same + dog_allof_instance.breed = 'Golden Retriever' + with self.assertRaises(petstore_api.ApiValueError): + breed = dog.breed + + # including extra parameters raises an exception + with self.assertRaises(petstore_api.ApiValueError): + dog = petstore_api.Dog( + class_name=class_name, + color=color, + breed=breed, + unknown_property='some value' + ) if __name__ == '__main__': diff --git a/samples/client/petstore/python-experimental/test/test_grandparent.py b/samples/client/petstore/python-experimental/test/test_grandparent.py new file mode 100644 index 000000000000..44f594c086e4 --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_grandparent.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestGrandparent(unittest.TestCase): + """Grandparent unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testGrandparent(self): + """Test Grandparent""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.Grandparent() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_grandparent_animal.py b/samples/client/petstore/python-experimental/test/test_grandparent_animal.py new file mode 100644 index 000000000000..dc0d300cdaea --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_grandparent_animal.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestGrandparentAnimal(unittest.TestCase): + """GrandparentAnimal unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testGrandparentAnimal(self): + """Test GrandparentAnimal""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.GrandparentAnimal() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_parent.py b/samples/client/petstore/python-experimental/test/test_parent.py new file mode 100644 index 000000000000..f719771bdcfb --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_parent.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestParent(unittest.TestCase): + """Parent unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testParent(self): + """Test Parent""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.Parent() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_parent_all_of.py b/samples/client/petstore/python-experimental/test/test_parent_all_of.py new file mode 100644 index 000000000000..c1c152afe18a --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_parent_all_of.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestParentAllOf(unittest.TestCase): + """ParentAllOf unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testParentAllOf(self): + """Test ParentAllOf""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ParentAllOf() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_parent_pet.py b/samples/client/petstore/python-experimental/test/test_parent_pet.py new file mode 100644 index 000000000000..b3ec1a94532c --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_parent_pet.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" + OpenAPI Petstore + + This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Generated by: https://openapi-generator.tech +""" + + +from __future__ import absolute_import + +import unittest + +import petstore_api + + +class TestParentPet(unittest.TestCase): + """ParentPet unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testParentPet(self): + """Test ParentPet""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.ParentPet() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test_python2.sh b/samples/client/petstore/python-experimental/test_python2.sh index b68d0bd20a73..35de07deec71 100644 --- a/samples/client/petstore/python-experimental/test_python2.sh +++ b/samples/client/petstore/python-experimental/test_python2.sh @@ -8,16 +8,18 @@ DEACTIVE=false export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 +PYTHONPATH="$(which python)" ### set virtualenv if [ -z "$VIRTUAL_ENV" ]; then - virtualenv $VENV --no-site-packages --always-copy + virtualenv $VENV --python=$PYTHONPATH --no-site-packages --always-copy source $VENV/bin/activate DEACTIVE=true fi ### install dependencies pip install -r $REQUIREMENTS_FILE | tee -a $REQUIREMENTS_OUT +pip install -r test-requirements.txt python setup.py develop ### run tests diff --git a/samples/client/petstore/python-experimental/tests/test_api_client.py b/samples/client/petstore/python-experimental/tests/test_api_client.py index ad50f1862014..62d7b9859541 100644 --- a/samples/client/petstore/python-experimental/tests/test_api_client.py +++ b/samples/client/petstore/python-experimental/tests/test_api_client.py @@ -141,8 +141,8 @@ def test_sanitize_for_serialization(self): # model pet_dict = {"id": 1, "name": "monkey", "category": {"id": 1, "name": "test category"}, - "tags": [{"id": 1, "name": "test tag1"}, - {"id": 2, "name": "test tag2"}], + "tags": [{"id": 1, "fullName": "test tag1"}, + {"id": 2, "fullName": "test tag2"}], "status": "available", "photoUrls": ["http://foo.bar.com/3", "http://foo.bar.com/4"]} @@ -154,10 +154,10 @@ def test_sanitize_for_serialization(self): pet.category = cate tag1 = petstore_api.Tag() tag1.id = pet_dict["tags"][0]["id"] - tag1.name = pet_dict["tags"][0]["name"] + tag1.full_name = pet_dict["tags"][0]["fullName"] tag2 = petstore_api.Tag() tag2.id = pet_dict["tags"][1]["id"] - tag2.name = pet_dict["tags"][1]["name"] + tag2.full_name = pet_dict["tags"][1]["fullName"] pet.tags = [tag1, tag2] pet.status = pet_dict["status"] diff --git a/samples/client/petstore/python-experimental/tests/test_api_exception.py b/samples/client/petstore/python-experimental/tests/test_api_exception.py index a05c3e902c58..026ba5bd79c1 100644 --- a/samples/client/petstore/python-experimental/tests/test_api_exception.py +++ b/samples/client/petstore/python-experimental/tests/test_api_exception.py @@ -31,7 +31,7 @@ def setUpModels(self): self.category.name = "dog" self.tag = petstore_api.Tag() self.tag.id = id_gen() - self.tag.name = "blank" + self.tag.full_name = "blank" self.pet = petstore_api.Pet(name="hello kity", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"]) self.pet.id = id_gen() self.pet.status = "sold" diff --git a/samples/client/petstore/python-experimental/tests/test_deserialization.py b/samples/client/petstore/python-experimental/tests/test_deserialization.py index 9ab64b04bba3..8ebeb1751ce6 100644 --- a/samples/client/petstore/python-experimental/tests/test_deserialization.py +++ b/samples/client/petstore/python-experimental/tests/test_deserialization.py @@ -28,6 +28,7 @@ from petstore_api.model_utils import ( file_type, int, + model_to_dict, str, ) @@ -87,7 +88,7 @@ def test_deserialize_dict_str_pet(self): "tags": [ { "id": 0, - "name": "string" + "fullName": "string" } ], "status": "available" @@ -114,7 +115,25 @@ def test_deserialize_dict_str_dog(self): deserialized = self.deserialize(response, ({str: (petstore_api.Animal,)},), True) self.assertTrue(isinstance(deserialized, dict)) - self.assertTrue(isinstance(deserialized['dog'], petstore_api.Dog)) + dog = deserialized['dog'] + self.assertTrue(isinstance(dog, petstore_api.Dog)) + self.assertEqual(dog.class_name, "Dog") + self.assertEqual(dog.color, "white") + self.assertEqual(dog.breed, "Jack Russel Terrier") + + def test_deserialize_lizard(self): + """ deserialize ChildLizard, use discriminator""" + data = { + "pet_type": "ChildLizard", + "lovesRocks": True + } + response = MockResponse(data=json.dumps(data)) + + lizard = self.deserialize(response, + (petstore_api.ParentPet,), True) + self.assertTrue(isinstance(lizard, petstore_api.ChildLizard)) + self.assertEqual(lizard.pet_type, "ChildLizard") + self.assertEqual(lizard.loves_rocks, True) def test_deserialize_dict_str_int(self): """ deserialize dict(str, int) """ @@ -166,7 +185,7 @@ def test_deserialize_pet(self): "tags": [ { "id": 0, - "name": "string" + "fullName": "string" } ], "status": "available" @@ -180,7 +199,7 @@ def test_deserialize_pet(self): self.assertTrue(isinstance(deserialized.category, petstore_api.Category)) self.assertEqual(deserialized.category.name, "string") self.assertTrue(isinstance(deserialized.tags, list)) - self.assertEqual(deserialized.tags[0].name, "string") + self.assertEqual(deserialized.tags[0].full_name, "string") def test_deserialize_list_of_pet(self): """ deserialize list[Pet] """ @@ -198,7 +217,7 @@ def test_deserialize_list_of_pet(self): "tags": [ { "id": 0, - "name": "string" + "fullName": "string" } ], "status": "available" @@ -216,7 +235,7 @@ def test_deserialize_list_of_pet(self): "tags": [ { "id": 0, - "name": "string" + "fullName": "string" } ], "status": "available" diff --git a/samples/client/petstore/python-tornado/README.md b/samples/client/petstore/python-tornado/README.md index 8534592c1506..b92f4eecf8d4 100644 --- a/samples/client/petstore/python-tornado/README.md +++ b/samples/client/petstore/python-tornado/README.md @@ -23,7 +23,7 @@ pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git Then import the package: ```python -import petstore_api +import petstore_api ``` ### Setuptools diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 8534592c1506..b92f4eecf8d4 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -23,7 +23,7 @@ pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git Then import the package: ```python -import petstore_api +import petstore_api ``` ### Setuptools diff --git a/samples/openapi3/client/petstore/python/README.md b/samples/openapi3/client/petstore/python/README.md index 907737d8b0ec..45ff3402d25a 100644 --- a/samples/openapi3/client/petstore/python/README.md +++ b/samples/openapi3/client/petstore/python/README.md @@ -23,7 +23,7 @@ pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git Then import the package: ```python -import petstore_api +import petstore_api ``` ### Setuptools