diff --git a/bin/python-experimental-petstore.sh b/bin/python-experimental-petstore.sh index ab01d44cc539..531cf295d64e 100755 --- a/bin/python-experimental-petstore.sh +++ b/bin/python-experimental-petstore.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples/client/petstore/python-experimental -DpackageName=petstore_api $@" +ags="generate -t modules/openapi-generator/src/main/resources/python -i modules/openapi-generator/src/test/resources/2_0/python-client-experimental/petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples/client/petstore/python-experimental --additional-properties packageName=petstore_api $@" java $JAVA_OPTS -jar $executable $ags 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 682ca581355a..51831befb01d 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 @@ -2493,6 +2493,76 @@ protected ApiResponse findMethodResponse(ApiResponses responses) { return responses.get(code); } + /** + * Set op's returnBaseType, returnType, examples etc. + * + * @param operation endpoint Operation + * @param schemas a map of the schemas in the openapi spec + * @param op endpoint CodegenOperation + * @param methodResponse the default ApiResponse for the endpoint + */ + protected void handleMethodResponse(Operation operation, + Map schemas, + CodegenOperation op, + ApiResponse methodResponse) { + Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse)); + + if (responseSchema != null) { + CodegenProperty cm = fromProperty("response", responseSchema); + + if (ModelUtils.isArraySchema(responseSchema)) { + ArraySchema as = (ArraySchema) responseSchema; + CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as)); + op.returnBaseType = innerProperty.baseType; + } else if (ModelUtils.isMapSchema(responseSchema)) { + CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema)); + op.returnBaseType = innerProperty.baseType; + } else { + if (cm.complexType != null) { + op.returnBaseType = cm.complexType; + } else { + op.returnBaseType = cm.baseType; + } + } + + // generate examples + String exampleStatusCode = "200"; + for (String key : operation.getResponses().keySet()) { + if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) { + exampleStatusCode = key; + } + } + op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation)); + op.defaultResponse = toDefaultValue(responseSchema); + op.returnType = cm.dataType; + op.hasReference = schemas.containsKey(op.returnBaseType); + + // lookup discriminator + Schema schema = schemas.get(op.returnBaseType); + if (schema != null) { + CodegenModel cmod = fromModel(op.returnBaseType, schema); + op.discriminator = cmod.discriminator; + } + + if (cm.isContainer) { + op.returnContainer = cm.containerType; + if ("map".equals(cm.containerType)) { + op.isMapContainer = true; + } else if ("list".equalsIgnoreCase(cm.containerType)) { + op.isListContainer = true; + } else if ("array".equalsIgnoreCase(cm.containerType)) { + op.isListContainer = true; + } + } else { + op.returnSimpleType = true; + } + if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) { + op.returnTypeIsPrimitive = true; + } + } + addHeaders(methodResponse, op.responseHeaders); + } + /** * Convert OAS Operation object to Codegen Operation object * @@ -2585,62 +2655,7 @@ public CodegenOperation fromOperation(String path, op.responses.get(op.responses.size() - 1).hasMore = false; if (methodResponse != null) { - Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse)); - - if (responseSchema != null) { - CodegenProperty cm = fromProperty("response", responseSchema); - - if (ModelUtils.isArraySchema(responseSchema)) { - ArraySchema as = (ArraySchema) responseSchema; - CodegenProperty innerProperty = fromProperty("response", getSchemaItems(as)); - op.returnBaseType = innerProperty.baseType; - } else if (ModelUtils.isMapSchema(responseSchema)) { - CodegenProperty innerProperty = fromProperty("response", ModelUtils.getAdditionalProperties(responseSchema)); - op.returnBaseType = innerProperty.baseType; - } else { - if (cm.complexType != null) { - op.returnBaseType = cm.complexType; - } else { - op.returnBaseType = cm.baseType; - } - } - - // generate examples - String exampleStatusCode = "200"; - for (String key : operation.getResponses().keySet()) { - if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) { - exampleStatusCode = key; - } - } - op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation)); - op.defaultResponse = toDefaultValue(responseSchema); - op.returnType = cm.dataType; - op.hasReference = schemas.containsKey(op.returnBaseType); - - // lookup discriminator - Schema schema = schemas.get(op.returnBaseType); - if (schema != null) { - CodegenModel cmod = fromModel(op.returnBaseType, schema); - op.discriminator = cmod.discriminator; - } - - if (cm.isContainer) { - op.returnContainer = cm.containerType; - if ("map".equals(cm.containerType)) { - op.isMapContainer = true; - } else if ("list".equalsIgnoreCase(cm.containerType)) { - op.isListContainer = true; - } else if ("array".equalsIgnoreCase(cm.containerType)) { - op.isListContainer = true; - } - } else { - op.returnSimpleType = true; - } - if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) { - op.returnTypeIsPrimitive = true; - } - } - addHeaders(methodResponse, op.responseHeaders); + handleMethodResponse(operation, schemas, op, methodResponse); } } @@ -3511,7 +3526,7 @@ protected List> toExamples(Map examples) { * @param response API response * @param properties list of codegen property */ - private void addHeaders(ApiResponse response, List properties) { + protected void addHeaders(ApiResponse response, List properties) { if (response.getHeaders() != null) { for (Map.Entry headerEntry : response.getHeaders().entrySet()) { String description = headerEntry.getValue().getDescription(); @@ -4316,7 +4331,7 @@ public void updateCodegenPropertyEnum(CodegenProperty var) { } } - private void updateEnumVarsWithExtensions(List> enumVars, Map vendorExtensions) { + protected void updateEnumVarsWithExtensions(List> enumVars, Map vendorExtensions) { if (vendorExtensions != null) { updateEnumVarsWithExtensions(enumVars, vendorExtensions, "x-enum-varnames", "name"); updateEnumVarsWithExtensions(enumVars, vendorExtensions, "x-enum-descriptions", "enumDescription"); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 623d6c5dbb45..515b34dc1dfc 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -490,10 +490,9 @@ private Model getParent(Model model) { // TODO revise below as we've already performed unaliasing so that the isAlias check may be removed Map modelTemplate = (Map) ((List) models.get("models")).get(0); - // Special handling of aliases only applies to Java if (modelTemplate != null && modelTemplate.containsKey("model")) { CodegenModel m = (CodegenModel) modelTemplate.get("model"); - if (m.isAlias) { + if (m.isAlias && !ModelUtils.isGenerateAliasAsModel()) { continue; // Don't create user-defined classes for aliases } } 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 4f5d3c3af59c..d19b7b83f953 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 @@ -16,31 +16,50 @@ package org.openapitools.codegen.languages; -import java.text.DateFormat; -import java.text.SimpleDateFormat; - +import io.swagger.v3.oas.models.Operation; +import io.swagger.v3.oas.models.examples.Example; +import io.swagger.v3.oas.models.media.*; +import io.swagger.v3.oas.models.media.ArraySchema; +import io.swagger.v3.oas.models.media.MediaType; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.parameters.RequestBody; +import io.swagger.v3.oas.models.responses.ApiResponse; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang3.StringUtils; +import org.openapitools.codegen.*; +import org.openapitools.codegen.examples.ExampleGenerator; +import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.meta.GeneratorMetadata; import org.openapitools.codegen.meta.Stability; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.swagger.v3.oas.models.media.Schema; -import org.openapitools.codegen.*; -import org.openapitools.codegen.utils.ModelUtils; - +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.io.File; import java.util.*; import java.util.regex.Pattern; +import static org.openapitools.codegen.utils.StringUtils.camelize; +import static org.openapitools.codegen.utils.StringUtils.underscore; + public class PythonClientExperimentalCodegen extends PythonClientCodegen { private static final Logger LOGGER = LoggerFactory.getLogger(PythonClientExperimentalCodegen.class); public PythonClientExperimentalCodegen() { super(); - supportingFiles.add(new SupportingFile("python-experimental/api_client.mustache", packagePath(), "api_client.py")); - apiDocTemplateFiles.put("python-experimental/api_doc.mustache", ".md"); + apiTemplateFiles.remove("api.mustache"); apiTemplateFiles.put("python-experimental/api.mustache", ".py"); + + apiDocTemplateFiles.remove("api_doc.mustache"); + apiDocTemplateFiles.put("python-experimental/api_doc.mustache", ".md"); + + modelDocTemplateFiles.remove("model_doc.mustache"); modelDocTemplateFiles.put("python-experimental/model_doc.mustache", ".md"); + + modelTemplateFiles.remove("model.mustache"); modelTemplateFiles.put("python-experimental/model.mustache", ".py"); generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata) @@ -48,6 +67,23 @@ public PythonClientExperimentalCodegen() { .build(); } + @Override + public void processOpts() { + super.processOpts(); + + supportingFiles.remove(new SupportingFile("api_client.mustache", packagePath(), "api_client.py")); + supportingFiles.add(new SupportingFile("python-experimental/api_client.mustache", packagePath(), "api_client.py")); + + supportingFiles.add(new SupportingFile("python-experimental/model_utils.mustache", packagePath(), "model_utils.py")); + + // default this to true so the python ModelSimple models will be generated + ModelUtils.setGenerateAliasAsModel(true); + if (additionalProperties.containsKey(CodegenConstants.GENERATE_ALIAS_AS_MODEL)) { + LOGGER.info(CodegenConstants.GENERATE_ALIAS_AS_MODEL + " is hard coded to true in this generator. Alias models will only be generated if they contain validations or enums"); + } + + } + /** * Configures a friendly name for the generator. This will be used by the * generator to select the library with the -g flag. @@ -162,4 +198,397 @@ public String toDefaultValue(Schema p) { } } + @Override + public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { + // add regex information to property + postProcessPattern(property.pattern, property.vendorExtensions); + } + + // override with any special post-processing for all models + @SuppressWarnings({"static-method", "unchecked"}) + public Map postProcessAllModels(Map objs) { + // loop through all models and delete ones where type!=object and the model has no validations and enums + // we will remove them because they are not needed + Map modelSchemasToRemove = new HashMap(); + for (Map.Entry entry : objs.entrySet()) { + Map inner = (Map) entry.getValue(); + List> models = (List>) inner.get("models"); + for (Map mo : models) { + CodegenModel cm = (CodegenModel) mo.get("model"); + Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name); + CodegenProperty modelProperty = fromProperty("value", modelSchema); + if (cm.isEnum || cm.isAlias) { + if (!modelProperty.isEnum && !modelProperty.hasValidation) { + // remove these models because they are aliases and do not have any enums or validations + modelSchemasToRemove.put(cm.name, modelSchema); + } + } else if (cm.isArrayModel && !modelProperty.isEnum && !modelProperty.hasValidation) { + // remove any ArrayModels which lack validation and enums + modelSchemasToRemove.put(cm.name, modelSchema); + } + } + } + + // Remove modelSchemasToRemove models from objs + for (String modelName : modelSchemasToRemove.keySet()) { + objs.remove(modelName); + } + return objs; + } + + /** + * Convert OAS Property object to Codegen Property object + * + * @param name name of the property + * @param p OAS property object + * @return Codegen Property object + */ + @Override + public CodegenProperty fromProperty(String name, Schema p) { + // we have a custom version of this function to always set allowableValues.enumVars on all enum variables + CodegenProperty result = super.fromProperty(name, p); + if (result.isEnum) { + updateCodegenPropertyEnum(result); + } + return result; + } + + /** + * Update codegen property's enum by adding "enumVars" (with name and value) + * + * @param var list of CodegenProperty + */ + @Override + public void updateCodegenPropertyEnum(CodegenProperty var) { + // we have a custom version of this method to omit overwriting the defaultValue + Map allowableValues = var.allowableValues; + + // handle array + if (var.mostInnerItems != null) { + allowableValues = var.mostInnerItems.allowableValues; + } + + if (allowableValues == null) { + return; + } + + List values = (List) allowableValues.get("values"); + if (values == null) { + return; + } + + String varDataType = var.mostInnerItems != null ? var.mostInnerItems.dataType : var.dataType; + Optional referencedSchema = ModelUtils.getSchemas(openAPI).entrySet().stream() + .filter(entry -> Objects.equals(varDataType, toModelName(entry.getKey()))) + .map(Map.Entry::getValue) + .findFirst(); + String dataType = (referencedSchema.isPresent()) ? getTypeDeclaration(referencedSchema.get()) : varDataType; + + // put "enumVars" map into `allowableValues", including `name` and `value` + List> enumVars = new ArrayList<>(); + String commonPrefix = findCommonPrefixOfVars(values); + int truncateIdx = commonPrefix.length(); + for (Object value : values) { + Map enumVar = new HashMap<>(); + String enumName; + if (truncateIdx == 0) { + enumName = value.toString(); + } else { + enumName = value.toString().substring(truncateIdx); + if ("".equals(enumName)) { + enumName = value.toString(); + } + } + + enumVar.put("name", toEnumVarName(enumName, dataType)); + enumVar.put("value", toEnumValue(value.toString(), dataType)); + enumVar.put("isString", isDataTypeString(dataType)); + enumVars.add(enumVar); + } + // if "x-enum-varnames" or "x-enum-descriptions" defined, update varnames + Map extensions = var.mostInnerItems != null ? var.mostInnerItems.getVendorExtensions() : var.getVendorExtensions(); + if (referencedSchema.isPresent()) { + extensions = referencedSchema.get().getExtensions(); + } + updateEnumVarsWithExtensions(enumVars, extensions); + allowableValues.put("enumVars", enumVars); + // overwriting defaultValue omitted from here + } + + @Override + public CodegenParameter fromRequestBody(RequestBody body, Set imports, String bodyParameterName) { + CodegenParameter result = super.fromRequestBody(body, imports, bodyParameterName); + // if we generated a model with a non-object type because it has validations or enums, + // make sure that the datatype of that body parameter refers to our model class + Content content = body.getContent(); + Set keySet = content.keySet(); + Object[] keyArray = (Object[]) keySet.toArray(); + MediaType mediaType = content.get(keyArray[0]); + Schema schema = mediaType.getSchema(); + String ref = schema.get$ref(); + if (ref == null) { + return result; + } + String modelName = ModelUtils.getSimpleRef(ref); + // the result lacks validation info so we need to make a CodegenProperty from the schema to check + // if we have validation and enum info exists + Schema realSchema = ModelUtils.getSchema(this.openAPI, modelName); + 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); + // set the example value + if (modelProp.isEnum) { + String value = modelProp._enum.get(0).toString(); + result.example = modelName + "(" + toEnumValue(value, simpleDataType) + ")"; + } else { + result.example = modelName + "(" + result.example + ")"; + } + } + return result; + } + + /** + * Convert OAS Response object to Codegen Response object + * + * @param responseCode HTTP response code + * @param response OAS Response object + * @return Codegen Response object + */ + @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 + // 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; + if (this.openAPI != null && this.openAPI.getComponents() != null) { + responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(response)); + } else { // no model/alias defined + responseSchema = ModelUtils.getSchemaFromResponse(response); + } + + String newBaseType = null; + 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); + 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; + } + } + } else { + if (cp.isEnum == true || cp.hasValidation == true) { + // this model has validations and/or enums so we will generate it + Schema sc = ModelUtils.getSchemaFromResponse(response); + newBaseType = ModelUtils.getSimpleRef(sc.get$ref()); + } + } + } + + CodegenResponse result = super.fromResponse(responseCode, response); + if (newBaseType != null) { + result.isModel = true; + result.baseType = newBaseType; + result.dataType = newBaseType; + } + + return result; + } + + /** + * Set op's returnBaseType, returnType, examples etc. + * + * @param operation endpoint Operation + * @param schemas a map of the schemas in the openapi spec + * @param op endpoint CodegenOperation + * @param methodResponse the default ApiResponse for the endpoint + */ + @Override + public void handleMethodResponse(Operation operation, + Map schemas, + CodegenOperation op, + ApiResponse methodResponse) { + // we have a custom version of this method to handle endpoints that return models where + // type != object the model has validations and/or enums + // we do this by invoking our custom fromResponse method to create defaultResponse + // which we then use to set op.returnType and op.returnBaseType + CodegenResponse defaultResponse = fromResponse("defaultResponse", methodResponse); + Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse)); + + if (responseSchema != null) { + op.returnBaseType = defaultResponse.baseType; + + // generate examples + String exampleStatusCode = "200"; + for (String key : operation.getResponses().keySet()) { + if (operation.getResponses().get(key) == methodResponse && !key.equals("default")) { + exampleStatusCode = key; + } + } + op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation)); + op.defaultResponse = toDefaultValue(responseSchema); + op.returnType = defaultResponse.dataType; + op.hasReference = schemas.containsKey(op.returnBaseType); + + // lookup discriminator + Schema schema = schemas.get(op.returnBaseType); + if (schema != null) { + CodegenModel cmod = fromModel(op.returnBaseType, schema); + op.discriminator = cmod.discriminator; + } + + if (defaultResponse.isListContainer) { + op.isListContainer = true; + } else if (defaultResponse.isMapContainer) { + op.isMapContainer = true; + } else { + op.returnSimpleType = true; + } + if (languageSpecificPrimitives().contains(op.returnBaseType) || op.returnBaseType == null) { + op.returnTypeIsPrimitive = true; + } + } + addHeaders(methodResponse, op.responseHeaders); + } + + + /** + * Return the sanitized variable name for enum + * + * @param value enum variable name + * @param datatype data type + * @return the sanitized variable name for enum + */ + public String toEnumVarName(String value, String datatype) { + // our enum var names are keys in a python dict, so change spaces to underscores + if (value.length() == 0) { + return "EMPTY"; + } + + String var = value.replaceAll("\\s+", "_").toUpperCase(Locale.ROOT); + return var; + } + + /** + * Return the enum value in the language specified format + * e.g. status becomes "status" + * + * @param value enum variable name + * @param datatype data type + * @return the sanitized value for enum + */ + public String toEnumValue(String value, String datatype) { + if (datatype.equals("int") || datatype.equals("float")) { + return value; + } else { + return "\"" + escapeText(value) + "\""; + } + } + + @Override + public void postProcessParameter(CodegenParameter parameter) { + postProcessPattern(parameter.pattern, parameter.vendorExtensions); + } + + /** + * Convert OAS Model object to Codegen Model object + * + * @param name the name of the model + * @param schema OAS Model object + * @return Codegen Model object + */ + @Override + public CodegenModel fromModel(String name, Schema schema) { + // we have a custom version of this function so we can produce + // models for components whose type != object and which have validations and enums + // this ensures that endpoint (operation) responses with validations and enums + // will generate models, and when those endpoint responses are received in python + // the response is cast as a model, and the model will validate the response using the enums and validations + Map propertyToModelName = new HashMap(); + Map propertiesMap = schema.getProperties(); + if (propertiesMap != null) { + for (Map.Entry entry : propertiesMap.entrySet()) { + String schemaPropertyName = entry.getKey(); + String pythonPropertyName = toVarName(schemaPropertyName); + Schema propertySchema = entry.getValue(); + String ref = propertySchema.get$ref(); + if (ref == null) { + continue; + } + Schema refSchema = ModelUtils.getReferencedSchema(this.openAPI, propertySchema); + String refType = refSchema.getType(); + if (refType == null || refType.equals("object")) { + continue; + } + CodegenProperty modelProperty = fromProperty("_fake_name", refSchema); + if (modelProperty.isEnum == false && modelProperty.hasValidation == false) { + continue; + } + String modelName = ModelUtils.getSimpleRef(ref); + propertyToModelName.put(pythonPropertyName, modelName); + } + } + CodegenModel result = super.fromModel(name, schema); + + // make non-object type models have one property so we can use it to store enums and validations + if (result.isAlias || result.isEnum) { + Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name); + CodegenProperty modelProperty = fromProperty("value", modelSchema); + if (modelProperty.isEnum == true || modelProperty.hasValidation == true) { + // these models are non-object models with enums and/or validations + // add a single property to the model so we can have a way to access validations + result.isAlias = true; + modelProperty.required = true; + List theProperties = Arrays.asList(modelProperty); + result.setAllVars(theProperties); + result.setVars(theProperties); + result.setRequiredVars(theProperties); + // post process model properties + if (result.vars != null) { + for (CodegenProperty prop : result.vars) { + postProcessModelProperty(result, prop); + } + } + + } + } + + // return all models which don't need their properties connected to non-object models + if (propertyToModelName.isEmpty()) { + return result; + } + + // fix all property references to non-object models, make those properties non-primitive and + // set their dataType and complexType to the model name, so documentation will refer to the correct model + ArrayList> listOfLists= new ArrayList>(); + listOfLists.add(result.vars); + listOfLists.add(result.allVars); + listOfLists.add(result.requiredVars); + listOfLists.add(result.optionalVars); + listOfLists.add(result.readOnlyVars); + listOfLists.add(result.readWriteVars); + for (List cpList : listOfLists) { + for (CodegenProperty cp : cpList) { + if (!propertyToModelName.containsKey(cp.name)) { + continue; + } + cp.isPrimitiveType = false; + String modelName = propertyToModelName.get(cp.name); + cp.complexType = modelName; + cp.dataType = modelName; + cp.isEnum = false; + cp.hasValidation = false; + } + } + return result; + } + } 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 edf76be03bba..dd650b37d7f2 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 @@ -10,10 +10,14 @@ import re # noqa: F401 import six from {{packageName}}.api_client import ApiClient -from {{packageName}}.exceptions import ( # noqa: F401 +from {{packageName}}.exceptions import ( ApiTypeError, ApiValueError ) +from {{packageName}}.model_utils import ( + check_allowed_values, + check_validations +) {{#operations}} @@ -30,265 +34,384 @@ class {{classname}}(object): self.api_client = api_client {{#operation}} - def {{operationId}}(self{{#requiredParams}}{{^defaultValue}}, {{paramName}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}, {{paramName}}={{{defaultValue}}}{{/defaultValue}}{{/requiredParams}}, **kwargs): # noqa: E501 - """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 + def __{{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): # noqa: E501 + """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 {{#notes}} - {{{notes}}} # noqa: E501 + {{{notes}}} # noqa: E501 {{/notes}} - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.{{operationId}}({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{{defaultValue}}}, {{/defaultValue}}{{/requiredParams}}async_req=True) - >>> result = thread.get() - -{{#requiredParams}} -{{^hasMore}} - Args: -{{/hasMore}} -{{/requiredParams}} -{{#requiredParams}} -{{^defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}}{{/requiredParams}} + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True +{{#sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}async_req=True) +{{/sortParamsByRequiredFlag}} +{{^sortParamsByRequiredFlag}} + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}async_req=True) +{{/sortParamsByRequiredFlag}} + >>> result = thread.get() - Keyword Args:{{#optionalParams}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param async_req bool: execute request asynchronously +{{#allParams}} + :param {{dataType}} {{paramName}}:{{#description}} {{{description}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} +{{/allParams}} + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{paramName}}, {{/defaultValue}}{{/requiredParams}}**kwargs) # noqa: E501 - else: - (data) = self.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}{{paramName}}={{paramName}}, {{/defaultValue}}{{/requiredParams}}**kwargs) # noqa: E501 - return data - - def {{operationId}}_with_http_info(self{{#requiredParams}}{{^defaultValue}}, {{paramName}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}}, {{paramName}}=None{{/defaultValue}}{{/requiredParams}}, **kwargs): # noqa: E501 - """{{#summary}}{{{.}}}{{/summary}}{{^summary}}{{operationId}}{{/summary}} # noqa: E501 - -{{#notes}} - {{{notes}}} # noqa: E501 -{{/notes}} - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.{{operationId}}_with_http_info({{#requiredParams}}{{^defaultValue}}{{paramName}}, {{/defaultValue}}{{/requiredParams}}async_req=True) - >>> result = thread.get() - + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}} + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) {{#requiredParams}} -{{^hasMore}} - Args: -{{/hasMore}} + kwargs['{{paramName}}'] = {{paramName}} {{/requiredParams}} -{{#requiredParams}} -{{^defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredParams}}{{#requiredParams}}{{#defaultValue}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}}{{/requiredParams}} - - Keyword Args:{{#optionalParams}} - {{paramName}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}}{{/optionalParams}} - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}: - """ + return self.call_with_http_info(**kwargs) - {{#servers.0}} - local_var_hosts = [{{#servers}} - '{{{url}}}'{{^-last}},{{/-last}}{{/servers}} - ] - local_var_host = local_var_hosts[0] - if kwargs.get('_host_index'): - if (int(kwargs.get('_host_index')) < 0 or - int(kwargs.get('_host_index')) >= len(local_var_hosts)): - raise ApiValueError( - "Invalid host index. Must be 0 <= index < %s" % - len(local_var_host) - ) - local_var_host = local_var_hosts[int(kwargs.get('_host_index'))] - {{/servers.0}} - local_var_params = locals() - - all_params = [{{#allParams}}'{{paramName}}'{{#hasMore}}, {{/hasMore}}{{/allParams}}] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params{{#servers.0}} and key != "_host_index"{{/servers.0}}: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method {{operationId}}" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] + self.{{operationId}} = Endpoint( + settings={ + 'response_type': {{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, +{{#authMethods}} +{{#-first}} + 'auth': [ +{{/-first}} + '{{name}}'{{#hasMore}}, {{/hasMore}} +{{#-last}} + ], +{{/-last}} +{{/authMethods}} +{{^authMethods}} + 'auth': [], +{{/authMethods}} + 'endpoint_path': '{{{path}}}', + 'operation_id': '{{operationId}}', + 'http_method': '{{httpMethod}}', +{{#servers}} +{{#-first}} + 'servers': [ +{{/-first}} + '{{{url}}}'{{^-last}},{{/-last}} +{{#-last}} + ] +{{/-last}} +{{/servers}} +{{^servers}} + 'servers': [], +{{/servers}} + }, + params_map={ + 'all': [ {{#allParams}} -{{^isNullable}} -{{#required}} - # verify the required parameter '{{paramName}}' is set - if ('{{paramName}}' not in local_var_params or - local_var_params['{{paramName}}'] is None): - raise ApiValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") # noqa: E501 -{{/required}} -{{/isNullable}} + '{{paramName}}', +{{/allParams}} + ], +{{#requiredParams}} +{{#-first}} + 'required': [ +{{/-first}} + '{{paramName}}', {{#-last}} + ], {{/-last}} +{{/requiredParams}} +{{^requiredParams}} + 'required': [], +{{/requiredParams}} + 'nullable': [ +{{#allParams}} +{{#isNullable}} + '{{paramName}}', +{{/isNullable}} {{/allParams}} + ], + 'enum': [ {{#allParams}} {{#isEnum}} -{{#isContainer}} - allowed_values = [{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 -{{#isListContainer}} - if ('{{{paramName}}}' in local_var_params and - not set(local_var_params['{{{paramName}}}']).issubset(set(allowed_values))): # noqa: E501 - raise ValueError( - "Invalid values for `{{{paramName}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(local_var_params['{{{paramName}}}']) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isListContainer}} -{{#isMapContainer}} - if ('{{{paramName}}}' in local_var_params and - not set(local_var_params['{{{paramName}}}'].keys()).issubset(set(allowed_values))): - raise ValueError( - "Invalid keys in `{{{paramName}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(local_var_params['{{{paramName}}}'].keys()) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isMapContainer}} -{{/isContainer}} -{{^isContainer}} - allowed_values = [{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 - if ('{{{paramName}}}' in local_var_params and - local_var_params['{{{paramName}}}'] not in allowed_values): - raise ValueError( - "Invalid value for `{{{paramName}}}` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['{{{paramName}}}'], allowed_values) - ) -{{/isContainer}} + '{{paramName}}', {{/isEnum}} {{/allParams}} + ], + 'validation': [ {{#allParams}} {{#hasValidation}} - {{#maxLength}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) > {{maxLength}}): - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 - {{/maxLength}} - {{#minLength}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) < {{minLength}}): - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 - {{/minLength}} - {{#maximum}} - if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 - {{/maximum}} - {{#minimum}} - if '{{paramName}}' in local_var_params and local_var_params['{{paramName}}'] <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 - {{/minimum}} - {{#pattern}} - if '{{paramName}}' in local_var_params and not re.search(r'{{{vendorExtensions.x-regex}}}', local_var_params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{{pattern}}}`") # noqa: E501 - {{/pattern}} - {{#maxItems}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) > {{maxItems}}): - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 - {{/maxItems}} - {{#minItems}} - if ('{{paramName}}' in local_var_params and - len(local_var_params['{{paramName}}']) < {{minItems}}): - raise ApiValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 - {{/minItems}} + '{{paramName}}', {{/hasValidation}} {{/allParams}} + ] + }, + root_map={ + 'validations': { +{{#allParams}} +{{#hasValidation}} + ('{{paramName}}',): { +{{#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}} +{{/allParams}} + }, + 'allowed_values': { +{{#allParams}} +{{#isEnum}} + ('{{paramName}}',): { +{{#isNullable}} + 'None': None,{{/isNullable}}{{#allowableValues}}{{#enumVars}} + "{{name}}": {{{value}}}{{^-last}},{{/-last}}{{/enumVars}}{{/allowableValues}} + }, +{{/isEnum}} +{{/allParams}} + }, + 'openapi_types': { +{{#allParams}} + '{{paramName}}': '{{dataType}}', +{{/allParams}} + }, + 'attribute_map': { +{{#allParams}} +{{^isBodyParam}} + '{{paramName}}': '{{baseName}}', +{{/isBodyParam}} +{{/allParams}} + }, + 'location_map': { +{{#allParams}} + '{{paramName}}': '{{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isCookieParam}}cookie{{/isCookieParam}}{{#isBodyParam}}body{{/isBodyParam}}', +{{/allParams}} + }, + 'collection_format_map': { +{{#allParams}} +{{#collectionFormat}} + '{{paramName}}': '{{collectionFormat}}', +{{/collectionFormat}} +{{/allParams}} + } + }, + headers_map={ +{{#hasProduces}} + 'accept': [ +{{#produces}} + '{{{mediaType}}}'{{#hasMore}},{{/hasMore}} +{{/produces}} + ], +{{/hasProduces}} +{{^hasProduces}} + 'accept': [], +{{/hasProduces}} +{{#hasConsumes}} + 'content_type': [ +{{#consumes}} + '{{{mediaType}}}'{{#hasMore}},{{/hasMore}} +{{/consumes}} + ] +{{/hasConsumes}} +{{^hasConsumes}} + 'content_type': [], +{{/hasConsumes}} + }, + api_client=api_client, + callable=__{{operationId}} + ) +{{/operation}} +{{/operations}} + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint + + Args: + settings (dict): see below key value pairs + 'response_type' (str): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called + """ + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only' + ]) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param], + self.validations + ) + + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param] + ) + + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } - collection_formats = {} + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == 'file'): + param_location = 'file' + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format - path_params = {} -{{#pathParams}} - if '{{paramName}}' in local_var_params: - path_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 -{{/pathParams}} + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class + """ + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + if kwargs.get('_host_index') and self.settings['servers']: + _host_index = kwargs.get('_host_index') + try: + _host = self.settings['servers'][_host_index] + except IndexError: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) + else: + try: + _host = self.settings['servers'][0] + except IndexError: + _host = None - query_params = [] -{{#queryParams}} - if '{{paramName}}' in local_var_params: - query_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 -{{/queryParams}} + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: + raise ApiTypeError( + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + if key not in self.params_map['nullable'] and value is None: + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) + ) - header_params = {} -{{#headerParams}} - if '{{paramName}}' in local_var_params: - header_params['{{baseName}}'] = local_var_params['{{paramName}}']{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 -{{/headerParams}} + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - form_params = [] - local_var_files = {} -{{#formParams}} - if '{{paramName}}' in local_var_params: - {{^isFile}}form_params.append(('{{baseName}}', local_var_params['{{paramName}}'])){{/isFile}}{{#isFile}}local_var_files['{{baseName}}'] = local_var_params['{{paramName}}']{{/isFile}}{{#isListContainer}} # noqa: E501 - collection_formats['{{baseName}}'] = '{{collectionFormat}}'{{/isListContainer}} # noqa: E501 -{{/formParams}} + self.__validate_inputs(kwargs) - body_params = None -{{#bodyParam}} - if '{{paramName}}' in local_var_params: - body_params = local_var_params['{{paramName}}'] -{{/bodyParam}} - {{#hasProduces}} - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - [{{#produces}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]) # noqa: E501 + params = self.__gather_params(kwargs) - {{/hasProduces}} - {{#hasConsumes}} - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - [{{#consumes}}'{{{mediaType}}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]) # noqa: E501 + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - {{/hasConsumes}} - # Authentication setting - auth_settings = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] # noqa: E501 + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - '{{{path}}}', '{{httpMethod}}', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type={{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}}, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - {{#servers.0}} - _host=local_var_host, - {{/servers.0}} - collection_formats=collection_formats) -{{/operation}} -{{/operations}} + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs.get('async_req'), + _return_http_data_only=kwargs.get('_return_http_data_only'), + _preload_content=kwargs.get('_preload_content', True), + _request_timeout=kwargs.get('_request_timeout'), + _host=_host, + collection_formats=params['collection_format']) diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache index e955eb05707c..0f02b445dfba 100644 --- a/modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/api_client.mustache @@ -18,9 +18,13 @@ from six.moves.urllib.parse import quote import tornado.gen {{/tornado}} -from {{packageName}}.configuration import Configuration import {{modelPackage}} from {{packageName}} import rest +from {{packageName}}.configuration import Configuration +from {{packageName}}.model_utils import ( + ModelNormal, + ModelSimple +) from {{packageName}}.exceptions import ApiValueError @@ -224,7 +228,7 @@ class ApiClient(object): if isinstance(obj, dict): obj_dict = obj - else: + elif isinstance(obj, ModelNormal): # Convert model obj to dict except # attributes `openapi_types`, `attribute_map` # and attributes which value is not None. @@ -233,6 +237,8 @@ class ApiClient(object): obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) for attr, _ in six.iteritems(obj.openapi_types) if getattr(obj, attr) is not None} + elif isinstance(obj, ModelSimple): + return self.sanitize_for_serialization(obj.value) return {key: self.sanitize_for_serialization(val) for key, val in six.iteritems(obj_dict)} @@ -571,6 +577,8 @@ class ApiClient(object): return six.text_type(data) except TypeError: return data + except ValueError as exc: + raise ApiValueError(str(exc)) def __deserialize_object(self, value): """Return an original value. @@ -622,14 +630,15 @@ class ApiClient(object): """Deserializes list or dict to model. :param data: dict, list. - :param klass: class literal. + :param klass: class literal, ModelSimple or ModelNormal :return: model object. """ - if not klass.openapi_types and not hasattr(klass, - 'get_real_child_model'): - return data + if issubclass(klass, ModelSimple): + value = self.__deserialize(data, klass.openapi_types['value']) + return klass(value) + # code to handle ModelNormal used_data = data if not isinstance(data, (list, dict)): used_data = [data] @@ -641,13 +650,11 @@ class ApiClient(object): klass.attribute_map[attr] in used_data): value = used_data[klass.attribute_map[attr]] keyword_args[attr] = self.__deserialize(value, attr_type) - end_index = None argspec = inspect.getargspec(getattr(klass, '__init__')) if argspec.defaults: end_index = -len(argspec.defaults) required_positional_args = argspec.args[1:end_index] - for index, req_positional_arg in enumerate(required_positional_args): if keyword_args and req_positional_arg in keyword_args: positional_args.append(keyword_args[req_positional_arg]) @@ -655,9 +662,7 @@ class ApiClient(object): elif (not keyword_args and index < len(used_data) and isinstance(used_data, list)): positional_args.append(used_data[index]) - instance = klass(*positional_args, **keyword_args) - if hasattr(instance, 'get_real_child_model'): klass_name = instance.get_real_child_model(data) if klass_name: 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 7dc8e01fa620..082f4bddc432 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,240 +2,34 @@ {{>partial_header}} -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 + +from {{packageName}}.exceptions import ApiValueError # noqa: F401 +from {{packageName}}.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) {{#models}} {{#model}} -class {{classname}}(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """{{#allowableValues}} - - """ - allowed enum values - """ -{{#enumVars}} - {{name}} = {{{value}}}{{^-last}} +{{^interfaces}} +{{#isAlias}} +{{> python-experimental/model_templates/model_simple }} +{{/isAlias}} +{{^isAlias}} +{{> python-experimental/model_templates/model_normal }} +{{/isAlias}} +{{/interfaces}} +{{#interfaces}} +{{#-last}} +{{> python-experimental/model_templates/model_normal }} {{/-last}} -{{/enumVars}}{{/allowableValues}} - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { -{{#requiredVars}} - '{{name}}': '{{{dataType}}}', -{{/requiredVars}} -{{#optionalVars}} - '{{name}}': '{{{dataType}}}', -{{/optionalVars}} - } - - attribute_map = { -{{#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}} - - def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}{{#optionalVars}}, {{name}}=None{{/optionalVars}}): # noqa: E501 - """{{classname}} - a model defined in OpenAPI - -{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}} - {{name}} ({{dataType}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}} - - Keyword Args:{{#requiredVars}}{{#defaultValue}} - {{name}} ({{dataType}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}]{{/defaultValue}} # noqa: E501{{/requiredVars}}{{#optionalVars}} - {{name}} ({{dataType}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}} - """ -{{#vars}}{{#-first}} -{{/-first}} - self._{{name}} = None -{{/vars}} - self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} -{{#vars}}{{#-first}} -{{/-first}} -{{#required}} - self.{{name}} = {{name}} -{{/required}} -{{^required}} -{{#isNullable}} - self.{{name}} = {{name}} -{{/isNullable}} -{{^isNullable}} - if {{name}} is not None: - self.{{name}} = {{name}} # noqa: E501 -{{/isNullable}} -{{/required}} -{{/vars}} - -{{#vars}} - @property - def {{name}}(self): - """Gets the {{name}} of this {{classname}}. # noqa: E501 - -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - - :return: The {{name}} of this {{classname}}. # noqa: E501 - :rtype: {{dataType}} - """ - return self._{{name}} - - @{{name}}.setter - def {{name}}( - self, - {{name}}): - """Sets the {{name}} of this {{classname}}. - -{{#description}} - {{{description}}} # noqa: E501 -{{/description}} - - :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 - :type: {{dataType}} - """ -{{^isNullable}} -{{#required}} - if {{name}} is None: - raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 -{{/required}} -{{/isNullable}} -{{#isEnum}} -{{#isContainer}} - allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#items.isString}}"{{/items.isString}}{{{this}}}{{#items.isString}}"{{/items.isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 -{{#isListContainer}} - if not set({{{name}}}).issubset(set(allowed_values)): - raise ValueError( - "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set({{{name}}}) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isListContainer}} -{{#isMapContainer}} - if not set({{{name}}}.keys()).issubset(set(allowed_values)): - raise ValueError( - "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set({{{name}}}.keys()) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) -{{/isMapContainer}} -{{/isContainer}} -{{^isContainer}} - allowed_values = [{{#isNullable}}None,{{/isNullable}}{{#allowableValues}}{{#values}}{{#isString}}"{{/isString}}{{{this}}}{{#isString}}"{{/isString}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501 - if {{{name}}} not in allowed_values: - raise ValueError( - "Invalid value for `{{{name}}}` ({0}), must be one of {1}" # noqa: E501 - .format({{{name}}}, allowed_values) - ) -{{/isContainer}} -{{/isEnum}} -{{^isEnum}} -{{#hasValidation}} -{{#maxLength}} - if {{name}} is not None and len({{name}}) > {{maxLength}}: - raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501 -{{/maxLength}} -{{#minLength}} - if {{name}} is not None and len({{name}}) < {{minLength}}: - raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501 -{{/minLength}} -{{#maximum}} - if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501 -{{/maximum}} -{{#minimum}} - if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501 - raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501 -{{/minimum}} -{{#pattern}} - if {{name}} is not None and not re.search(r'{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501 - raise ValueError(r"Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501 -{{/pattern}} -{{#maxItems}} - if {{name}} is not None and len({{name}}) > {{maxItems}}: - raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501 -{{/maxItems}} -{{#minItems}} - if {{name}} is not None and len({{name}}) < {{minItems}}: - raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501 -{{/minItems}} -{{/hasValidation}} -{{/isEnum}} - - self._{{name}} = ( - {{name}}) - -{{/vars}} -{{#discriminator}} - def get_real_child_model(self, data): - """Returns the real base class specified by the discriminator""" - discriminator_key = self.attribute_map[self.discriminator] - discriminator_value = data[discriminator_key] - return self.discriminator_value_class_map.get(discriminator_value) - -{{/discriminator}} - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - 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 - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other +{{/interfaces}} {{/model}} {{/models}} 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 new file mode 100644 index 000000000000..6ed39521f66e --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvar_allowed.mustache @@ -0,0 +1,16 @@ + allowed_values = { +{{#vars}} +{{#isEnum}} + ('{{name}}',): { +{{#isNullable}} + 'None': None, +{{/isNullable}} +{{#allowableValues}} +{{#enumVars}} + '{{name}}': {{{value}}}{{^-last}},{{/-last}} +{{/enumVars}} +{{/allowableValues}} + }, +{{/isEnum}} +{{/vars}} + } \ 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 new file mode 100644 index 000000000000..7e89f83ef261 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/classvar_openapi_validations.mustache @@ -0,0 +1,25 @@ + openapi_types = { +{{#vars}} + '{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}} +{{/vars}} + } + + validations = { +{{#vars}} +{{#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}} +{{/vars}} + } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/docstring_allowed.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/docstring_allowed.mustache new file mode 100644 index 000000000000..ab20932b2892 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/docstring_allowed.mustache @@ -0,0 +1,4 @@ + 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. \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/docstring_openapi_validations.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/docstring_openapi_validations.mustache new file mode 100644 index 000000000000..46dc1afefc49 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/docstring_openapi_validations.mustache @@ -0,0 +1,7 @@ + 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. \ 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 new file mode 100644 index 000000000000..447aa22cacd0 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/methods_init_properties.mustache @@ -0,0 +1,76 @@ + def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 + """{{classname}} - a model defined in OpenAPI""" # noqa: E501 +{{#vars}}{{#-first}} +{{/-first}} + self._{{name}} = None +{{/vars}} + self.discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}} +{{#vars}}{{#-first}} +{{/-first}} +{{#required}} + self.{{name}} = {{name}} +{{/required}} +{{^required}} +{{#isNullable}} + self.{{name}} = {{name}} +{{/isNullable}} +{{^isNullable}} + if {{name}} is not None: + self.{{name}} = ( + {{name}} + ) +{{/isNullable}} +{{/required}} +{{/vars}} +{{#vars}} + + @property + def {{name}}(self): + """Gets the {{name}} of this {{classname}}. # noqa: E501 + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :return: The {{name}} of this {{classname}}. # noqa: E501 + :rtype: {{dataType}} + """ + return self._{{name}} + + @{{name}}.setter + def {{name}}(self, {{name}}): # noqa: E501 + """Sets the {{name}} of this {{classname}}. + +{{#description}} + {{{description}}} # noqa: E501 +{{/description}} + + :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501 + :type: {{dataType}} + """ +{{^isNullable}} +{{#required}} + if {{name}} is None: + raise ApiValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501 +{{/required}} +{{/isNullable}} +{{#isEnum}} + check_allowed_values( + self.allowed_values, + ('{{name}}',), + {{name}}, + self.validations + ) +{{/isEnum}} +{{#hasValidation}} + check_validations( + self.validations, + ('{{name}}',), + {{name}} + ) +{{/hasValidation}} + + self._{{name}} = ( + {{name}} + ) +{{/vars}} \ 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 new file mode 100644 index 000000000000..bd1eaddcb40b --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_normal.mustache @@ -0,0 +1,83 @@ +class {{classname}}(ModelNormal): + """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/classvar_allowed }} + + attribute_map = { +{{#vars}} + '{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} # noqa: E501 +{{/vars}} + } +{{#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}} + def get_real_child_model(self, data): + """Returns the real base class specified by the discriminator""" + discriminator_key = self.attribute_map[self.discriminator] + discriminator_value = data[discriminator_key] + return self.discriminator_value_class_map.get(discriminator_value) + +{{/discriminator}} + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + 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 + + return self.__dict__ == other.__dict__ + + 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/model_simple.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache new file mode 100644 index 000000000000..94ad6336f9c8 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_templates/model_simple.mustache @@ -0,0 +1,34 @@ +class {{classname}}(ModelSimple): + """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 }} +{{> python-experimental/model_templates/docstring_openapi_validations }} + """ + +{{> python-experimental/model_templates/classvar_allowed }} + +{{> python-experimental/model_templates/classvar_openapi_validations }} + +{{> 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 + + return self.__dict__ == other.__dict__ + + 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_utils.mustache b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache new file mode 100644 index 000000000000..c251879b1045 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache @@ -0,0 +1,175 @@ +# coding: utf-8 + +{{>partial_header}} +import re + +from {{packageName}}.exceptions import ApiValueError + + +def check_allowed_values(allowed_values, input_variable_path, input_values, + validations): + """Raises an exception if the input_values are not allowed + + Args: + allowed_values (dict): the allowed_values dict + input_variable_path (tuple): the path to the input variable + input_values (list/str/int/float/date/datetime): the values that we + are checking to see if they are in allowed_values + validations (dict): the validations dict + """ + min_collection_length = ( + validations.get(input_variable_path, {}).get('min_length') or + validations.get(input_variable_path, {}).get('min_items', 0)) + these_allowed_values = list(allowed_values[input_variable_path].values()) + if (isinstance(input_values, list) + and len(input_values) > min_collection_length + and not set(input_values).issubset( + set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values) - set(these_allowed_values))), + raise ApiValueError( + "Invalid values for `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (isinstance(input_values, dict) + and len(input_values) > min_collection_length + and not set( + input_values.keys()).issubset(set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values.keys()) - set(these_allowed_values))) + raise ApiValueError( + "Invalid keys in `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (not isinstance(input_values, (list, dict)) + and input_values not in these_allowed_values): + raise ApiValueError( + "Invalid value for `%s` (%s), must be one of %s" % + ( + input_variable_path[0], + input_values, + these_allowed_values + ) + ) + + +def check_validations(validations, input_variable_path, input_values): + """Raises an exception if the input_values are invalid + + Args: + validations (dict): the validation dictionary + input_variable_path (tuple): the path to the input variable + input_values (list/str/int/float/date/datetime): the values that we + are checking + """ + current_validations = validations[input_variable_path] + if ('max_length' in current_validations and + len(input_values) > current_validations['max_length']): + raise ApiValueError( + "Invalid value for `%s`, length must be less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['max_length'] + ) + ) + + if ('min_length' in current_validations and + len(input_values) < current_validations['min_length']): + raise ApiValueError( + "Invalid value for `%s`, length must be greater than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['min_length'] + ) + ) + + if ('max_items' in current_validations and + len(input_values) > current_validations['max_items']): + raise ApiValueError( + "Invalid value for `%s`, number of items must be less than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['max_items'] + ) + ) + + if ('min_items' in current_validations and + len(input_values) < current_validations['min_items']): + raise ValueError( + "Invalid value for `%s`, number of items must be greater than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['min_items'] + ) + ) + + if ('exclusive_maximum' in current_validations and + input_values >= current_validations['exclusive_maximum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value less than `%s`" % ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if ('inclusive_maximum' in current_validations and + input_values > current_validations['inclusive_maximum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['inclusive_maximum'] + ) + ) + + if ('exclusive_minimum' in current_validations and + input_values <= current_validations['exclusive_minimum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value greater than `%s`" % + ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if ('inclusive_minimum' in current_validations and + input_values < current_validations['inclusive_minimum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value greater than or equal " + "to `%s`" % ( + input_variable_path[0], + current_validations['inclusive_minimum'] + ) + ) + flags = current_validations.get('regex', {}).get('flags', 0) + if ('regex' in current_validations and + not re.search(current_validations['regex']['pattern'], + input_values, flags=flags)): + raise ApiValueError( + r"Invalid value for `%s`, must be a follow pattern or equal to " + r"`%s` with flags=`%s`" % ( + input_variable_path[0], + current_validations['regex']['pattern'], + flags + ) + ) + + +class ModelSimple(object): + # the parent class of models whose type != object in their swagger/openapi + # spec + pass + + +class ModelNormal(object): + # the parent class of models whose type == object in their swagger/openapi + # spec + pass 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 d424cd93e968..fea5233ee269 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 @@ -906,6 +906,23 @@ paths: description: Output composite schema: $ref: '#/definitions/OuterComposite' + /fake/outer/enum: + post: + tags: + - fake + description: Test serialization of outer enum + operationId: fakeOuterEnumSerialize + parameters: + - name: body + in: body + description: Input enum as post body + schema: + $ref: '#/definitions/OuterEnum' + responses: + '200': + description: Output enum + schema: + $ref: '#/definitions/OuterEnum' /fake/jsonFormData: get: tags: @@ -1378,7 +1395,7 @@ definitions: minimum: 67.8 string: type: string - pattern: /[a-z]/i + pattern: /^[a-z]+$/i byte: type: string format: byte @@ -1721,6 +1738,8 @@ definitions: $ref: '#/definitions/OuterBoolean' OuterNumber: type: number + minimum: 10 + maximum: 20 OuterString: type: string OuterBoolean: diff --git a/samples/client/petstore/python-experimental/.openapi-generator/VERSION b/samples/client/petstore/python-experimental/.openapi-generator/VERSION index 479c313e87b9..0e97bd19efbf 100644 --- a/samples/client/petstore/python-experimental/.openapi-generator/VERSION +++ b/samples/client/petstore/python-experimental/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.3-SNAPSHOT \ No newline at end of file +4.1.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/python-experimental/README.md b/samples/client/petstore/python-experimental/README.md index 8f84fade2fb5..2a5a1f6c149d 100644 --- a/samples/client/petstore/python-experimental/README.md +++ b/samples/client/petstore/python-experimental/README.md @@ -14,7 +14,7 @@ Python 2.7 and 3.4+ ## Installation & Usage ### pip install -If the python package is hosted on Github, you can install directly from Github +If the python package is hosted on a repository, you can install directly using: ```sh pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git @@ -77,6 +77,7 @@ Class | Method | HTTP request | Description *FakeApi* | [**create_xml_item**](docs/FakeApi.md#create_xml_item) | **POST** /fake/create_xml_item | creates an XmlItem *FakeApi* | [**fake_outer_boolean_serialize**](docs/FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | *FakeApi* | [**fake_outer_composite_serialize**](docs/FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | +*FakeApi* | [**fake_outer_enum_serialize**](docs/FakeApi.md#fake_outer_enum_serialize) | **POST** /fake/outer/enum | *FakeApi* | [**fake_outer_number_serialize**](docs/FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | *FakeApi* | [**fake_outer_string_serialize**](docs/FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | *FakeApi* | [**test_body_with_file_schema**](docs/FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | @@ -152,9 +153,11 @@ Class | Method | HTTP request | Description - [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) diff --git a/samples/client/petstore/python-experimental/docs/Animal.md b/samples/client/petstore/python-experimental/docs/Animal.md index 7ed4ba541fa3..e59166a62e83 100644 --- a/samples/client/petstore/python-experimental/docs/Animal.md +++ b/samples/client/petstore/python-experimental/docs/Animal.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **class_name** | **str** | | -**color** | **str** | | [optional] [default to 'red'] +**color** | **str** | | [optional] if omitted the server will use the default value of 'red' [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/Cat.md b/samples/client/petstore/python-experimental/docs/Cat.md index 8d30565d014e..8bdbf9b3bcca 100644 --- a/samples/client/petstore/python-experimental/docs/Cat.md +++ b/samples/client/petstore/python-experimental/docs/Cat.md @@ -3,7 +3,9 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | **declawed** | **bool** | | [optional] +**color** | **str** | | [optional] if omitted the server will use the default value of 'red' [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/Category.md b/samples/client/petstore/python-experimental/docs/Category.md index 7e5c1e316499..33b2242d703f 100644 --- a/samples/client/petstore/python-experimental/docs/Category.md +++ b/samples/client/petstore/python-experimental/docs/Category.md @@ -3,8 +3,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**name** | **str** | | defaults to 'default-name' **id** | **int** | | [optional] -**name** | **str** | | [default to 'default-name'] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/Dog.md b/samples/client/petstore/python-experimental/docs/Dog.md index f727487975c4..81de56780725 100644 --- a/samples/client/petstore/python-experimental/docs/Dog.md +++ b/samples/client/petstore/python-experimental/docs/Dog.md @@ -3,7 +3,9 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | **breed** | **str** | | [optional] +**color** | **str** | | [optional] if omitted the server will use the default value of 'red' [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/EnumClass.md b/samples/client/petstore/python-experimental/docs/EnumClass.md index 67f017becd0c..510dff4df0cf 100644 --- a/samples/client/petstore/python-experimental/docs/EnumClass.md +++ b/samples/client/petstore/python-experimental/docs/EnumClass.md @@ -3,6 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**value** | **str** | | defaults to '-efg' [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/python-experimental/docs/EnumTest.md b/samples/client/petstore/python-experimental/docs/EnumTest.md index c4c1630250ff..5fc28b6c1ce3 100644 --- a/samples/client/petstore/python-experimental/docs/EnumTest.md +++ b/samples/client/petstore/python-experimental/docs/EnumTest.md @@ -3,8 +3,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**enum_string** | **str** | | [optional] **enum_string_required** | **str** | | +**enum_string** | **str** | | [optional] **enum_integer** | **int** | | [optional] **enum_number** | **float** | | [optional] **outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional] diff --git a/samples/client/petstore/python-experimental/docs/FakeApi.md b/samples/client/petstore/python-experimental/docs/FakeApi.md index 5aa5443d06f8..94280a712344 100644 --- a/samples/client/petstore/python-experimental/docs/FakeApi.md +++ b/samples/client/petstore/python-experimental/docs/FakeApi.md @@ -7,6 +7,7 @@ Method | HTTP request | Description [**create_xml_item**](FakeApi.md#create_xml_item) | **POST** /fake/create_xml_item | creates an XmlItem [**fake_outer_boolean_serialize**](FakeApi.md#fake_outer_boolean_serialize) | **POST** /fake/outer/boolean | [**fake_outer_composite_serialize**](FakeApi.md#fake_outer_composite_serialize) | **POST** /fake/outer/composite | +[**fake_outer_enum_serialize**](FakeApi.md#fake_outer_enum_serialize) | **POST** /fake/outer/enum | [**fake_outer_number_serialize**](FakeApi.md#fake_outer_number_serialize) | **POST** /fake/outer/number | [**fake_outer_string_serialize**](FakeApi.md#fake_outer_string_serialize) | **POST** /fake/outer/string | [**test_body_with_file_schema**](FakeApi.md#test_body_with_file_schema) | **PUT** /fake/body-with-file-schema | @@ -179,8 +180,61 @@ 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() + + + +Test serialization of outer enum + +### Example + +```python +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) + +try: + api_response = api_instance.fake_outer_enum_serialize(body=body) + pprint(api_response) +except ApiException as e: + print("Exception when calling FakeApi->fake_outer_enum_serialize: %s\n" % e) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterEnum**](str.md)| Input enum as post body | [optional] + +### Return type + +[**OuterEnum**](OuterEnum.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: */* + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Output enum | - | + +[[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** -> float fake_outer_number_serialize() +> OuterNumber fake_outer_number_serialize() @@ -197,7 +251,7 @@ from pprint import pprint # Create an instance of the API class api_instance = petstore_api.FakeApi() -body = 3.4 # float | Input number as post body (optional) +body = OuterNumber(3.4) # OuterNumber | Input number as post body (optional) try: api_response = api_instance.fake_outer_number_serialize(body=body) @@ -210,11 +264,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | **float**| Input number as post body | [optional] + **body** | [**OuterNumber**](float.md)| Input number as post body | [optional] ### Return type -**float** +[**OuterNumber**](OuterNumber.md) ### Authorization diff --git a/samples/client/petstore/python-experimental/docs/FormatTest.md b/samples/client/petstore/python-experimental/docs/FormatTest.md index 31d92e2a750e..1bf152e6828b 100644 --- a/samples/client/petstore/python-experimental/docs/FormatTest.md +++ b/samples/client/petstore/python-experimental/docs/FormatTest.md @@ -3,19 +3,19 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**number** | **float** | | +**byte** | **str** | | +**date** | **date** | | +**password** | **str** | | **integer** | **int** | | [optional] **int32** | **int** | | [optional] **int64** | **int** | | [optional] -**number** | **float** | | **float** | **float** | | [optional] **double** | **float** | | [optional] **string** | **str** | | [optional] -**byte** | **str** | | **binary** | **file** | | [optional] -**date** | **date** | | **date_time** | **datetime** | | [optional] **uuid** | **str** | | [optional] -**password** | **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/MapTest.md b/samples/client/petstore/python-experimental/docs/MapTest.md index a5601691f885..ee6036eb2f42 100644 --- a/samples/client/petstore/python-experimental/docs/MapTest.md +++ b/samples/client/petstore/python-experimental/docs/MapTest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes **map_map_of_string** | **dict(str, dict(str, str))** | | [optional] **map_of_enum_string** | **dict(str, str)** | | [optional] **direct_map** | **dict(str, bool)** | | [optional] -**indirect_map** | **dict(str, bool)** | | [optional] +**indirect_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/Order.md b/samples/client/petstore/python-experimental/docs/Order.md index b5f7b22d34cf..c21210a3bd59 100644 --- a/samples/client/petstore/python-experimental/docs/Order.md +++ b/samples/client/petstore/python-experimental/docs/Order.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **quantity** | **int** | | [optional] **ship_date** | **datetime** | | [optional] **status** | **str** | Order Status | [optional] -**complete** | **bool** | | [optional] [default to False] +**complete** | **bool** | | [optional] if omitted the server will use the default value of False [[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/OuterComposite.md b/samples/client/petstore/python-experimental/docs/OuterComposite.md index bab07ad559eb..3df277a30fa5 100644 --- a/samples/client/petstore/python-experimental/docs/OuterComposite.md +++ b/samples/client/petstore/python-experimental/docs/OuterComposite.md @@ -3,7 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**my_number** | **float** | | [optional] +**my_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 06d413b01680..cba017068980 100644 --- a/samples/client/petstore/python-experimental/docs/OuterEnum.md +++ b/samples/client/petstore/python-experimental/docs/OuterEnum.md @@ -3,6 +3,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**value** | **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/OuterNumber.md b/samples/client/petstore/python-experimental/docs/OuterNumber.md new file mode 100644 index 000000000000..5d75342bd8e3 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/OuterNumber.md @@ -0,0 +1,10 @@ +# OuterNumber + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | **float** | | + +[[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 9e15090300f8..15185316feae 100644 --- a/samples/client/petstore/python-experimental/docs/Pet.md +++ b/samples/client/petstore/python-experimental/docs/Pet.md @@ -3,10 +3,10 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **int** | | [optional] -**category** | [**Category**](Category.md) | | [optional] **name** | **str** | | **photo_urls** | **list[str]** | | +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] **tags** | [**list[Tag]**](Tag.md) | | [optional] **status** | **str** | pet status in the store | [optional] diff --git a/samples/client/petstore/python-experimental/docs/StringBooleanMap.md b/samples/client/petstore/python-experimental/docs/StringBooleanMap.md new file mode 100644 index 000000000000..7abf11ec68b1 --- /dev/null +++ b/samples/client/petstore/python-experimental/docs/StringBooleanMap.md @@ -0,0 +1,9 @@ +# StringBooleanMap + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[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 fc82b9a827dd..7ec864de09df 100644 --- a/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md +++ b/samples/client/petstore/python-experimental/docs/TypeHolderDefault.md @@ -3,13 +3,13 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**string_item** | **str** | | [default to 'what'] -**number_item** | **float** | | [default to 1.234] -**integer_item** | **int** | | [default to -2] -**bool_item** | **bool** | | [default to True] +**array_item** | **list[int]** | | +**string_item** | **str** | | defaults to 'what' +**number_item** | **float** | | defaults to 1.234 +**integer_item** | **int** | | defaults to -2 +**bool_item** | **bool** | | defaults to True **date_item** | **date** | | [optional] **datetime_item** | **datetime** | | [optional] -**array_item** | **list[int]** | | [[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/TypeHolderExample.md b/samples/client/petstore/python-experimental/docs/TypeHolderExample.md index bb334f9925bc..71f302f8d9ff 100644 --- a/samples/client/petstore/python-experimental/docs/TypeHolderExample.md +++ b/samples/client/petstore/python-experimental/docs/TypeHolderExample.md @@ -3,11 +3,11 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**string_item** | **str** | | [default to 'what'] -**number_item** | **float** | | [default to 1.234] -**integer_item** | **int** | | [default to -2] **bool_item** | **bool** | | **array_item** | **list[int]** | | +**string_item** | **str** | | defaults to 'what' +**number_item** | **float** | | defaults to 1.234 +**integer_item** | **int** | | defaults to -2 [[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/git_push.sh b/samples/client/petstore/python-experimental/git_push.sh index 8442b80bb445..ced3be2b0c7b 100644 --- a/samples/client/petstore/python-experimental/git_push.sh +++ b/samples/client/petstore/python-experimental/git_push.sh @@ -1,11 +1,17 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -28,7 +34,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ fi git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/python-experimental/openapi_client/api_client.py b/samples/client/petstore/python-experimental/openapi_client/api_client.py deleted file mode 100644 index efe3e5c3789f..000000000000 --- a/samples/client/petstore/python-experimental/openapi_client/api_client.py +++ /dev/null @@ -1,658 +0,0 @@ -# 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 datetime -import inspect -import json -import mimetypes -from multiprocessing.pool import ThreadPool -import os -import re -import tempfile - -# python 2 and python 3 compatibility library -import six -from six.moves.urllib.parse import quote - -from petstore_api.configuration import Configuration -import petstore_api.models -from petstore_api import rest -from petstore_api.exceptions import ApiValueError - - -class ApiClient(object): - """Generic API client for OpenAPI client library builds. - - OpenAPI generic API client. This client handles the client- - server communication, and is invariant across implementations. Specifics of - the methods and models for each application are generated from the OpenAPI - templates. - - NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - Do not edit the class manually. - - :param configuration: .Configuration object for this client - :param header_name: a header to pass when making calls to the API. - :param header_value: a header value to pass when making calls to - the API. - :param cookie: a cookie to include in the header when making calls - to the API - :param pool_threads: The number of threads to use for async requests - to the API. More threads means more concurrent API requests. - """ - - PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types - NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int if six.PY3 else long, # noqa: F821 - 'float': float, - 'str': str, - 'bool': bool, - 'date': datetime.date, - 'datetime': datetime.datetime, - 'object': object, - } - _pool = None - - def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None, pool_threads=1): - if configuration is None: - configuration = Configuration() - self.configuration = configuration - self.pool_threads = pool_threads - - self.rest_client = rest.RESTClientObject(configuration) - self.default_headers = {} - if header_name is not None: - self.default_headers[header_name] = header_value - self.cookie = cookie - # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.0.0/python' - - def __del__(self): - if self._pool: - self._pool.close() - self._pool.join() - self._pool = None - - @property - def pool(self): - """Create thread pool on first request - avoids instantiating unused threadpool for blocking clients. - """ - if self._pool is None: - self._pool = ThreadPool(self.pool_threads) - return self._pool - - @property - def user_agent(self): - """User agent for this API client""" - return self.default_headers['User-Agent'] - - @user_agent.setter - def user_agent(self, value): - self.default_headers['User-Agent'] = value - - def set_default_header(self, header_name, header_value): - self.default_headers[header_name] = header_value - - def __call_api( - self, resource_path, method, path_params=None, - query_params=None, header_params=None, body=None, post_params=None, - files=None, response_type=None, auth_settings=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None): - - config = self.configuration - - # header parameters - header_params = header_params or {} - header_params.update(self.default_headers) - if self.cookie: - header_params['Cookie'] = self.cookie - if header_params: - header_params = self.sanitize_for_serialization(header_params) - header_params = dict(self.parameters_to_tuples(header_params, - collection_formats)) - - # path parameters - if path_params: - path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, - collection_formats) - for k, v in path_params: - # specified safe chars, encode everything - resource_path = resource_path.replace( - '{%s}' % k, - quote(str(v), safe=config.safe_chars_for_path_param) - ) - - # query parameters - if query_params: - query_params = self.sanitize_for_serialization(query_params) - query_params = self.parameters_to_tuples(query_params, - collection_formats) - - # post parameters - if post_params or files: - post_params = post_params if post_params else [] - post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, - collection_formats) - post_params.extend(self.files_parameters(files)) - - # auth setting - self.update_params_for_auth(header_params, query_params, auth_settings) - - # body - if body: - body = self.sanitize_for_serialization(body) - - # request url - if _host is None: - url = self.configuration.host + resource_path - else: - # use server/host defined in path or operation instead - url = _host + resource_path - - # perform request and return response - response_data = self.request( - method, url, query_params=query_params, headers=header_params, - post_params=post_params, body=body, - _preload_content=_preload_content, - _request_timeout=_request_timeout) - - self.last_response = response_data - - return_data = response_data - if _preload_content: - # deserialize response data - if response_type: - return_data = self.deserialize(response_data, response_type) - else: - return_data = None - - if _return_http_data_only: - return (return_data) - else: - return (return_data, response_data.status, - response_data.getheaders()) - - def sanitize_for_serialization(self, obj): - """Builds a JSON POST object. - - If obj is None, return None. - If obj is str, int, long, float, bool, return directly. - If obj is datetime.datetime, datetime.date - convert to string in iso8601 format. - If obj is list, sanitize each element in the list. - If obj is dict, return the dict. - If obj is OpenAPI model, return the properties dict. - - :param obj: The data to serialize. - :return: The serialized form of data. - """ - if obj is None: - return None - elif isinstance(obj, self.PRIMITIVE_TYPES): - return obj - elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] - elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) - elif isinstance(obj, (datetime.datetime, datetime.date)): - return obj.isoformat() - - if isinstance(obj, dict): - obj_dict = obj - else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in six.iteritems(obj.openapi_types) - if getattr(obj, attr) is not None} - - return {key: self.sanitize_for_serialization(val) - for key, val in six.iteritems(obj_dict)} - - def deserialize(self, response, response_type): - """Deserializes response into an object. - - :param response: RESTResponse object to be deserialized. - :param response_type: class literal for - deserialized object, or string of class name. - - :return: deserialized object. - """ - # handle file downloading - # save response body into a tmp file and return the instance - if response_type == "file": - return self.__deserialize_file(response) - - # fetch data from response object - try: - data = json.loads(response.data) - except ValueError: - data = response.data - - return self.__deserialize(data, response_type) - - def __deserialize(self, data, klass): - """Deserializes dict, list, str into an object. - - :param data: dict, list or str. - :param klass: class literal, or string of class name. - - :return: object. - """ - if data is None: - return None - - if type(klass) == str: - if klass.startswith('list['): - sub_kls = re.match(r'list\[(.*)\]', klass).group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] - - if klass.startswith('dict('): - sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in six.iteritems(data)} - - # convert str to class - if klass in self.NATIVE_TYPES_MAPPING: - klass = self.NATIVE_TYPES_MAPPING[klass] - else: - klass = getattr(petstore_api.models, klass) - - if klass in self.PRIMITIVE_TYPES: - return self.__deserialize_primitive(data, klass) - elif klass == object: - return self.__deserialize_object(data) - elif klass == datetime.date: - return self.__deserialize_date(data) - elif klass == datetime.datetime: - return self.__deserialize_datatime(data) - else: - return self.__deserialize_model(data, klass) - - def call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_type=None, auth_settings=None, async_req=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None): - """Makes the HTTP request (synchronous) and returns deserialized data. - - To make an async_req request, set the async_req parameter. - - :param resource_path: Path to method endpoint. - :param method: Method to call. - :param path_params: Path parameters in the url. - :param query_params: Query parameters in the url. - :param header_params: Header parameters to be - placed in the request header. - :param body: Request body. - :param post_params dict: Request post form parameters, - for `application/x-www-form-urlencoded`, `multipart/form-data`. - :param auth_settings list: Auth Settings names for the request. - :param response: Response data type. - :param files dict: key -> filename, value -> filepath, - for `multipart/form-data`. - :param async_req bool: execute request asynchronously - :param _return_http_data_only: response data without head status code - and headers - :param collection_formats: dict of collection formats for path, query, - header, and post parameters. - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: - If async_req parameter is True, - the request will be called asynchronously. - The method will return the request thread. - If parameter async_req is False or missing, - then the method will return the response directly. - """ - if not async_req: - return self.__call_api(resource_path, method, - path_params, query_params, header_params, - body, post_params, files, - response_type, auth_settings, - _return_http_data_only, collection_formats, - _preload_content, _request_timeout, _host) - else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host)) - return thread - - def request(self, method, url, query_params=None, headers=None, - post_params=None, body=None, _preload_content=True, - _request_timeout=None): - """Makes the HTTP request using RESTClient.""" - if method == "GET": - return self.rest_client.GET(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) - elif method == "HEAD": - return self.rest_client.HEAD(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) - elif method == "OPTIONS": - return self.rest_client.OPTIONS(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "POST": - return self.rest_client.POST(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "PUT": - return self.rest_client.PUT(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "PATCH": - return self.rest_client.PATCH(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "DELETE": - return self.rest_client.DELETE(url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - else: - raise ApiValueError( - "http method must be `GET`, `HEAD`, `OPTIONS`," - " `POST`, `PATCH`, `PUT` or `DELETE`." - ) - - def parameters_to_tuples(self, params, collection_formats): - """Get parameters as list of tuples, formatting collections. - - :param params: Parameters as dict or list of two-tuples - :param dict collection_formats: Parameter collection formats - :return: Parameters as list of tuples, collections formatted - """ - new_params = [] - if collection_formats is None: - collection_formats = {} - for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 - if k in collection_formats: - collection_format = collection_formats[k] - if collection_format == 'multi': - new_params.extend((k, value) for value in v) - else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' - else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(str(value) for value in v))) - else: - new_params.append((k, v)) - return new_params - - def files_parameters(self, files=None): - """Builds form parameters. - - :param files: File parameters. - :return: Form parameters with files. - """ - params = [] - - if files: - for k, v in six.iteritems(files): - if not v: - continue - file_names = v if type(v) is list else [v] - for n in file_names: - with open(n, 'rb') as f: - filename = os.path.basename(f.name) - filedata = f.read() - mimetype = (mimetypes.guess_type(filename)[0] or - 'application/octet-stream') - params.append( - tuple([k, tuple([filename, filedata, mimetype])])) - - return params - - def select_header_accept(self, accepts): - """Returns `Accept` based on an array of accepts provided. - - :param accepts: List of headers. - :return: Accept (e.g. application/json). - """ - if not accepts: - return - - accepts = [x.lower() for x in accepts] - - if 'application/json' in accepts: - return 'application/json' - else: - return ', '.join(accepts) - - def select_header_content_type(self, content_types): - """Returns `Content-Type` based on an array of content_types provided. - - :param content_types: List of content-types. - :return: Content-Type (e.g. application/json). - """ - if not content_types: - return 'application/json' - - content_types = [x.lower() for x in content_types] - - if 'application/json' in content_types or '*/*' in content_types: - return 'application/json' - else: - return content_types[0] - - def update_params_for_auth(self, headers, querys, auth_settings): - """Updates header and query params based on authentication setting. - - :param headers: Header parameters dict to be updated. - :param querys: Query parameters tuple list to be updated. - :param auth_settings: Authentication setting identifiers list. - """ - if not auth_settings: - return - - for auth in auth_settings: - auth_setting = self.configuration.auth_settings().get(auth) - if auth_setting: - if not auth_setting['value']: - continue - elif auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] - elif auth_setting['in'] == 'header': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - querys.append((auth_setting['key'], auth_setting['value'])) - else: - raise ApiValueError( - 'Authentication token must be in `query` or `header`' - ) - - def __deserialize_file(self, response): - """Deserializes body to file - - Saves response body into a file in a temporary folder, - using the filename from the `Content-Disposition` header if provided. - - :param response: RESTResponse. - :return: file path. - """ - fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) - os.close(fd) - os.remove(path) - - content_disposition = response.getheader("Content-Disposition") - if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) - path = os.path.join(os.path.dirname(path), filename) - - with open(path, "wb") as f: - f.write(response.data) - - return path - - def __deserialize_primitive(self, data, klass): - """Deserializes string to primitive type. - - :param data: str. - :param klass: class literal. - - :return: int, long, float, str, bool. - """ - try: - return klass(data) - except UnicodeEncodeError: - return six.text_type(data) - except TypeError: - return data - - def __deserialize_object(self, value): - """Return an original value. - - :return: object. - """ - return value - - def __deserialize_date(self, string): - """Deserializes string to date. - - :param string: str. - :return: date. - """ - try: - from dateutil.parser import parse - return parse(string).date() - except ImportError: - return string - except ValueError: - raise rest.ApiException( - status=0, - reason="Failed to parse `{0}` as date object".format(string) - ) - - def __deserialize_datatime(self, string): - """Deserializes string to datetime. - - The string should be in iso8601 datetime format. - - :param string: str. - :return: datetime. - """ - try: - from dateutil.parser import parse - return parse(string) - except ImportError: - return string - except ValueError: - raise rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as datetime object" - .format(string) - ) - ) - - def __deserialize_model(self, data, klass): - """Deserializes list or dict to model. - - :param data: dict, list. - :param klass: class literal. - :return: model object. - """ - - if not klass.openapi_types and not hasattr(klass, - 'get_real_child_model'): - return data - - used_data = data - if not isinstance(data, (list, dict)): - used_data = [data] - keyword_args = {} - positional_args = [] - if klass.openapi_types is not None: - for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in used_data): - value = used_data[klass.attribute_map[attr]] - keyword_args[attr] = self.__deserialize(value, attr_type) - - end_index = None - argspec = inspect.getargspec(getattr(klass, '__init__')) - if argspec.defaults: - end_index = -len(argspec.defaults) - required_positional_args = argspec.args[1:end_index] - - for index, req_positional_arg in enumerate(required_positional_args): - if keyword_args and req_positional_arg in keyword_args: - positional_args.append(keyword_args[req_positional_arg]) - del keyword_args[req_positional_arg] - elif (not keyword_args and index < len(used_data) and - isinstance(used_data, list)): - positional_args.append(used_data[index]) - - instance = klass(*positional_args, **keyword_args) - - if hasattr(instance, 'get_real_child_model'): - klass_name = instance.get_real_child_model(data) - if klass_name: - instance = self.__deserialize(data, klass_name) - return instance diff --git a/samples/client/petstore/python-experimental/petstore_api/__init__.py b/samples/client/petstore/python-experimental/petstore_api/__init__.py index 45d51fe90b8a..905c4d344909 100644 --- a/samples/client/petstore/python-experimental/petstore_api/__init__.py +++ b/samples/client/petstore/python-experimental/petstore_api/__init__.py @@ -71,9 +71,11 @@ 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 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 01d055616ebc..1c429821437f 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 @@ -18,10 +18,14 @@ import six from petstore_api.api_client import ApiClient -from petstore_api.exceptions import ( # noqa: F401 +from petstore_api.exceptions import ( ApiTypeError, ApiValueError ) +from petstore_api.model_utils import ( + check_allowed_values, + check_validations +) class AnotherFakeApi(object): @@ -36,122 +40,269 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def call_123_test_special_tags(self, body, **kwargs): # noqa: E501 - """To test special tags # noqa: E501 - - To test special tags and operation ID starting with number # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.call_123_test_special_tags(body, async_req=True) - >>> result = thread.get() - - Args: - body (Client): client model - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + def __call_123_test_special_tags(self, body, **kwargs): # noqa: E501 + """To test special tags # noqa: E501 + + To test special tags and operation ID starting with number # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.call_123_test_special_tags(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param Client body: client model (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Client: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.call_123_test_special_tags_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.call_123_test_special_tags_with_http_info(body, **kwargs) # noqa: E501 - return data - - def call_123_test_special_tags_with_http_info(self, body, **kwargs): # noqa: E501 - """To test special tags # noqa: E501 - - To test special tags and operation ID starting with number # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.call_123_test_special_tags_with_http_info(body, async_req=True) - >>> result = thread.get() + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: Client + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.call_123_test_special_tags = Endpoint( + settings={ + 'response_type': 'Client', + 'auth': [], + 'endpoint_path': '/another-fake/dummy', + 'operation_id': 'call_123_test_special_tags', + 'http_method': 'PATCH', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'Client', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__call_123_test_special_tags + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint Args: - body (Client): client model - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Client: + settings (dict): see below key value pairs + 'response_type' (str): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called """ + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only' + ]) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param], + self.validations + ) - local_var_params = locals() + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param] + ) - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == 'file'): + param_location = 'file' + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class + """ + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + if kwargs.get('_host_index') and self.settings['servers']: + _host_index = kwargs.get('_host_index') + try: + _host = self.settings['servers'][_host_index] + except IndexError: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) + else: + try: + _host = self.settings['servers'][0] + except IndexError: + _host = None - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method call_123_test_special_tags" % key + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + if key not in self.params_map['nullable'] and value is None: + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `call_123_test_special_tags`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - header_params = {} + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - form_params = [] - local_var_files = {} + self.__validate_inputs(kwargs) - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + params = self.__gather_params(kwargs) - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - # Authentication setting - auth_settings = [] # noqa: E501 + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - '/another-fake/dummy', 'PATCH', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='Client', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs.get('async_req'), + _return_http_data_only=kwargs.get('_return_http_data_only'), + _preload_content=kwargs.get('_preload_content', True), + _request_timeout=kwargs.get('_request_timeout'), + _host=_host, + collection_formats=params['collection_format']) 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 0f14ef6739d0..4b41defbc5a8 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 @@ -18,10 +18,14 @@ import six from petstore_api.api_client import ApiClient -from petstore_api.exceptions import ( # noqa: F401 +from petstore_api.exceptions import ( ApiTypeError, ApiValueError ) +from petstore_api.model_utils import ( + check_allowed_values, + check_validations +) class FakeApi(object): @@ -36,1877 +40,1653 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def create_xml_item(self, xml_item, **kwargs): # noqa: E501 - """creates an XmlItem # noqa: E501 - - this route creates an XmlItem # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_xml_item(xml_item, async_req=True) - >>> result = thread.get() - - Args: - xml_item (XmlItem): XmlItem Body - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_xml_item_with_http_info(xml_item, **kwargs) # noqa: E501 - else: - (data) = self.create_xml_item_with_http_info(xml_item, **kwargs) # noqa: E501 - return data - - def create_xml_item_with_http_info(self, xml_item, **kwargs): # noqa: E501 - """creates an XmlItem # noqa: E501 - - this route creates an XmlItem # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_xml_item_with_http_info(xml_item, async_req=True) - >>> result = thread.get() - - Args: - xml_item (XmlItem): XmlItem Body - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['xml_item'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_xml_item" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'xml_item' is set - if ('xml_item' not in local_var_params or - local_var_params['xml_item'] is None): - raise ApiValueError("Missing the required parameter `xml_item` when calling `create_xml_item`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'xml_item' in local_var_params: - body_params = local_var_params['xml_item'] - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/xml', 'application/xml; charset=utf-8', 'application/xml; charset=utf-16', 'text/xml', 'text/xml; charset=utf-8', 'text/xml; charset=utf-16']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/create_xml_item', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def fake_outer_boolean_serialize(self, **kwargs): # noqa: E501 - """fake_outer_boolean_serialize # noqa: E501 - - Test serialization of outer boolean types # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.fake_outer_boolean_serialize(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - body (bool): Input boolean as post body. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - bool: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.fake_outer_boolean_serialize_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.fake_outer_boolean_serialize_with_http_info(**kwargs) # noqa: E501 - return data - - def fake_outer_boolean_serialize_with_http_info(self, **kwargs): # noqa: E501 - """fake_outer_boolean_serialize # noqa: E501 - - Test serialization of outer boolean types # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.fake_outer_boolean_serialize_with_http_info(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - body (bool): Input boolean as post body. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - bool: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method fake_outer_boolean_serialize" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['*/*']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/outer/boolean', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='bool', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def fake_outer_composite_serialize(self, **kwargs): # noqa: E501 - """fake_outer_composite_serialize # noqa: E501 - - Test serialization of object with outer number type # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.fake_outer_composite_serialize(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - body (OuterComposite): Input composite as post body. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + def __create_xml_item(self, xml_item, **kwargs): # noqa: E501 + """creates an XmlItem # noqa: E501 + + this route creates an XmlItem # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_xml_item(xml_item, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param XmlItem xml_item: XmlItem Body (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - OuterComposite: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.fake_outer_composite_serialize_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.fake_outer_composite_serialize_with_http_info(**kwargs) # noqa: E501 - return data - - def fake_outer_composite_serialize_with_http_info(self, **kwargs): # noqa: E501 - """fake_outer_composite_serialize # noqa: E501 - - Test serialization of object with outer number type # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.fake_outer_composite_serialize_with_http_info(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - body (OuterComposite): Input composite as post body. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - OuterComposite: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method fake_outer_composite_serialize" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['*/*']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/outer/composite', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='OuterComposite', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def fake_outer_number_serialize(self, **kwargs): # noqa: E501 - """fake_outer_number_serialize # noqa: E501 - - Test serialization of outer number types # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.fake_outer_number_serialize(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - body (float): Input number as post body. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - float: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.fake_outer_number_serialize_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.fake_outer_number_serialize_with_http_info(**kwargs) # noqa: E501 - return data - - def fake_outer_number_serialize_with_http_info(self, **kwargs): # noqa: E501 - """fake_outer_number_serialize # noqa: E501 - - Test serialization of outer number types # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.fake_outer_number_serialize_with_http_info(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - body (float): Input number as post body. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - float: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method fake_outer_number_serialize" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['*/*']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/outer/number', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='float', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def fake_outer_string_serialize(self, **kwargs): # noqa: E501 - """fake_outer_string_serialize # noqa: E501 - - Test serialization of outer string types # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.fake_outer_string_serialize(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - body (str): Input string as post body. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - str: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.fake_outer_string_serialize_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.fake_outer_string_serialize_with_http_info(**kwargs) # noqa: E501 - return data - - def fake_outer_string_serialize_with_http_info(self, **kwargs): # noqa: E501 - """fake_outer_string_serialize # noqa: E501 - - Test serialization of outer string types # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.fake_outer_string_serialize_with_http_info(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - body (str): Input string as post body. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['xml_item'] = xml_item + return self.call_with_http_info(**kwargs) + + self.create_xml_item = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/create_xml_item', + 'operation_id': 'create_xml_item', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'xml_item', + ], + 'required': [ + 'xml_item', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'xml_item': 'XmlItem', + }, + 'attribute_map': { + }, + 'location_map': { + 'xml_item': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/xml', + 'application/xml; charset=utf-8', + 'application/xml; charset=utf-16', + 'text/xml', + 'text/xml; charset=utf-8', + 'text/xml; charset=utf-16' + ] + }, + api_client=api_client, + callable=__create_xml_item + ) + + def __fake_outer_boolean_serialize(self, **kwargs): # noqa: E501 + """fake_outer_boolean_serialize # noqa: E501 + + Test serialization of outer boolean types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.fake_outer_boolean_serialize(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param bool body: Input boolean as post body + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - str: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method fake_outer_string_serialize" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['*/*']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/outer/string', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='str', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_body_with_file_schema(self, body, **kwargs): # noqa: E501 - """test_body_with_file_schema # noqa: E501 - - For this test, the body for this request much reference a schema named `File`. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_body_with_file_schema(body, async_req=True) - >>> result = thread.get() - - Args: - body (FileSchemaTestClass): - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: bool + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + return self.call_with_http_info(**kwargs) + + self.fake_outer_boolean_serialize = Endpoint( + settings={ + 'response_type': 'bool', + 'auth': [], + 'endpoint_path': '/fake/outer/boolean', + 'operation_id': 'fake_outer_boolean_serialize', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'bool', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__fake_outer_boolean_serialize + ) + + def __fake_outer_composite_serialize(self, **kwargs): # noqa: E501 + """fake_outer_composite_serialize # noqa: E501 + + Test serialization of object with outer number type # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.fake_outer_composite_serialize(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param OuterComposite body: Input composite as post body + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_body_with_file_schema_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.test_body_with_file_schema_with_http_info(body, **kwargs) # noqa: E501 - return data - - def test_body_with_file_schema_with_http_info(self, body, **kwargs): # noqa: E501 - """test_body_with_file_schema # noqa: E501 - - For this test, the body for this request much reference a schema named `File`. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_body_with_file_schema_with_http_info(body, async_req=True) - >>> result = thread.get() - - Args: - body (FileSchemaTestClass): - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: OuterComposite + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + return self.call_with_http_info(**kwargs) + + self.fake_outer_composite_serialize = Endpoint( + settings={ + 'response_type': 'OuterComposite', + 'auth': [], + 'endpoint_path': '/fake/outer/composite', + 'operation_id': 'fake_outer_composite_serialize', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'OuterComposite', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__fake_outer_composite_serialize + ) + + def __fake_outer_enum_serialize(self, **kwargs): # noqa: E501 + """fake_outer_enum_serialize # noqa: E501 + + Test serialization of outer enum # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.fake_outer_enum_serialize(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param OuterEnum body: Input enum as post body + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_body_with_file_schema" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `test_body_with_file_schema`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/body-with-file-schema', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_body_with_query_params(self, query, body, **kwargs): # noqa: E501 - """test_body_with_query_params # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_body_with_query_params(query, body, async_req=True) - >>> result = thread.get() - - Args: - query (str): body (User): - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: OuterEnum + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + return self.call_with_http_info(**kwargs) + + self.fake_outer_enum_serialize = Endpoint( + settings={ + 'response_type': 'OuterEnum', + 'auth': [], + 'endpoint_path': '/fake/outer/enum', + 'operation_id': 'fake_outer_enum_serialize', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'OuterEnum', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__fake_outer_enum_serialize + ) + + def __fake_outer_number_serialize(self, **kwargs): # noqa: E501 + """fake_outer_number_serialize # noqa: E501 + + Test serialization of outer number types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.fake_outer_number_serialize(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param OuterNumber body: Input number as post body + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_body_with_query_params_with_http_info(query, body, **kwargs) # noqa: E501 - else: - (data) = self.test_body_with_query_params_with_http_info(query, body, **kwargs) # noqa: E501 - return data - - def test_body_with_query_params_with_http_info(self, query, body, **kwargs): # noqa: E501 - """test_body_with_query_params # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_body_with_query_params_with_http_info(query, body, async_req=True) - >>> result = thread.get() - - Args: - query (str): body (User): - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: OuterNumber + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + return self.call_with_http_info(**kwargs) + + self.fake_outer_number_serialize = Endpoint( + settings={ + 'response_type': 'OuterNumber', + 'auth': [], + 'endpoint_path': '/fake/outer/number', + 'operation_id': 'fake_outer_number_serialize', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'OuterNumber', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__fake_outer_number_serialize + ) + + def __fake_outer_string_serialize(self, **kwargs): # noqa: E501 + """fake_outer_string_serialize # noqa: E501 + + Test serialization of outer string types # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.fake_outer_string_serialize(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str body: Input string as post body + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['query', 'body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_body_with_query_params" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'query' is set - if ('query' not in local_var_params or - local_var_params['query'] is None): - raise ApiValueError("Missing the required parameter `query` when calling `test_body_with_query_params`") # noqa: E501 - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `test_body_with_query_params`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - if 'query' in local_var_params: - query_params.append(('query', local_var_params['query'])) # noqa: E501 - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/body-with-query-params', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_client_model(self, body, **kwargs): # noqa: E501 - """To test \"client\" model # noqa: E501 - - To test \"client\" model # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_client_model(body, async_req=True) - >>> result = thread.get() - - Args: - body (Client): client model - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: str + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + return self.call_with_http_info(**kwargs) + + self.fake_outer_string_serialize = Endpoint( + settings={ + 'response_type': 'str', + 'auth': [], + 'endpoint_path': '/fake/outer/string', + 'operation_id': 'fake_outer_string_serialize', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'str', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + '*/*' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__fake_outer_string_serialize + ) + + def __test_body_with_file_schema(self, body, **kwargs): # noqa: E501 + """test_body_with_file_schema # noqa: E501 + + For this test, the body for this request much reference a schema named `File`. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_body_with_file_schema(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param FileSchemaTestClass body: (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Client: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_client_model_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.test_client_model_with_http_info(body, **kwargs) # noqa: E501 - return data - - def test_client_model_with_http_info(self, body, **kwargs): # noqa: E501 - """To test \"client\" model # noqa: E501 - - To test \"client\" model # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_client_model_with_http_info(body, async_req=True) - >>> result = thread.get() - - Args: - body (Client): client model - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.test_body_with_file_schema = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/body-with-file-schema', + 'operation_id': 'test_body_with_file_schema', + 'http_method': 'PUT', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'FileSchemaTestClass', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_body_with_file_schema + ) + + def __test_body_with_query_params(self, query, body, **kwargs): # noqa: E501 + """test_body_with_query_params # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_body_with_query_params(query, body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str query: (required) + :param User body: (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Client: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_client_model" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `test_client_model`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake', 'PATCH', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='Client', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_endpoint_enums_length_one(self, query_integer=3, query_string='brillig', path_string='hello', path_integer=34, header_number=1.234, **kwargs): # noqa: E501 - """test_endpoint_enums_length_one # noqa: E501 - - This route has required values with enums of 1 # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_endpoint_enums_length_one(query_integer=3, query_string='brillig', path_string='hello', path_integer=34, header_number=1.234, async_req=True) - >>> result = thread.get() - - Args: - - query_integer (int): defaults to 3, must be one of [3] - query_string (str): defaults to 'brillig', must be one of ['brillig'] - path_string (str): defaults to 'hello', must be one of ['hello'] - path_integer (int): defaults to 34, must be one of [34] - header_number (float): defaults to 1.234, must be one of [1.234] - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['query'] = query + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.test_body_with_query_params = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/body-with-query-params', + 'operation_id': 'test_body_with_query_params', + 'http_method': 'PUT', + 'servers': [], + }, + params_map={ + 'all': [ + 'query', + 'body', + ], + 'required': [ + 'query', + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'query': 'str', + 'body': 'User', + }, + 'attribute_map': { + 'query': 'query', + }, + 'location_map': { + 'query': 'query', + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_body_with_query_params + ) + + def __test_client_model(self, body, **kwargs): # noqa: E501 + """To test \"client\" model # noqa: E501 + + To test \"client\" model # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_client_model(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param Client body: client model (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_endpoint_enums_length_one_with_http_info(query_integer=query_integer, query_string=query_string, path_string=path_string, path_integer=path_integer, header_number=header_number, **kwargs) # noqa: E501 - else: - (data) = self.test_endpoint_enums_length_one_with_http_info(query_integer=query_integer, query_string=query_string, path_string=path_string, path_integer=path_integer, header_number=header_number, **kwargs) # noqa: E501 - return data - - def test_endpoint_enums_length_one_with_http_info(self, query_integer=None, query_string=None, path_string=None, path_integer=None, header_number=None, **kwargs): # noqa: E501 - """test_endpoint_enums_length_one # noqa: E501 - - This route has required values with enums of 1 # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_endpoint_enums_length_one_with_http_info(async_req=True) - >>> result = thread.get() - - Args: - - query_integer (int): defaults to 3, must be one of [3] - query_string (str): defaults to 'brillig', must be one of ['brillig'] - path_string (str): defaults to 'hello', must be one of ['hello'] - path_integer (int): defaults to 34, must be one of [34] - header_number (float): defaults to 1.234, must be one of [1.234] - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: Client + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.test_client_model = Endpoint( + settings={ + 'response_type': 'Client', + 'auth': [], + 'endpoint_path': '/fake', + 'operation_id': 'test_client_model', + 'http_method': 'PATCH', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'Client', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_client_model + ) + + def __test_endpoint_enums_length_one(self, query_integer, query_string, path_string, path_integer, header_number, **kwargs): # noqa: E501 + """test_endpoint_enums_length_one # noqa: E501 + + This route has required values with enums of 1 # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_endpoint_enums_length_one(query_integer, query_string, path_string, path_integer, header_number, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param int query_integer: (required) + :param str query_string: (required) + :param str path_string: (required) + :param int path_integer: (required) + :param float header_number: (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['query_integer', 'query_string', 'path_string', 'path_integer', 'header_number'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_endpoint_enums_length_one" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'query_integer' is set - if ('query_integer' not in local_var_params or - local_var_params['query_integer'] is None): - raise ApiValueError("Missing the required parameter `query_integer` when calling `test_endpoint_enums_length_one`") # noqa: E501 - # verify the required parameter 'query_string' is set - if ('query_string' not in local_var_params or - local_var_params['query_string'] is None): - raise ApiValueError("Missing the required parameter `query_string` when calling `test_endpoint_enums_length_one`") # noqa: E501 - # verify the required parameter 'path_string' is set - if ('path_string' not in local_var_params or - local_var_params['path_string'] is None): - raise ApiValueError("Missing the required parameter `path_string` when calling `test_endpoint_enums_length_one`") # noqa: E501 - # verify the required parameter 'path_integer' is set - if ('path_integer' not in local_var_params or - local_var_params['path_integer'] is None): - raise ApiValueError("Missing the required parameter `path_integer` when calling `test_endpoint_enums_length_one`") # noqa: E501 - # verify the required parameter 'header_number' is set - if ('header_number' not in local_var_params or - local_var_params['header_number'] is None): - raise ApiValueError("Missing the required parameter `header_number` when calling `test_endpoint_enums_length_one`") # noqa: E501 - allowed_values = [3] # noqa: E501 - if ('query_integer' in local_var_params and - local_var_params['query_integer'] not in allowed_values): - raise ValueError( - "Invalid value for `query_integer` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['query_integer'], allowed_values) + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True ) - allowed_values = ["brillig"] # noqa: E501 - if ('query_string' in local_var_params and - local_var_params['query_string'] not in allowed_values): - raise ValueError( - "Invalid value for `query_string` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['query_string'], allowed_values) + kwargs['query_integer'] = query_integer + kwargs['query_string'] = query_string + kwargs['path_string'] = path_string + kwargs['path_integer'] = path_integer + kwargs['header_number'] = header_number + return self.call_with_http_info(**kwargs) + + self.test_endpoint_enums_length_one = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/enums-of-length-one/{path_string}/{path_integer}', + 'operation_id': 'test_endpoint_enums_length_one', + 'http_method': 'PUT', + 'servers': [], + }, + params_map={ + 'all': [ + 'query_integer', + 'query_string', + 'path_string', + 'path_integer', + 'header_number', + ], + 'required': [ + 'query_integer', + 'query_string', + 'path_string', + 'path_integer', + 'header_number', + ], + 'nullable': [ + ], + 'enum': [ + 'query_integer', + 'query_string', + 'path_string', + 'path_integer', + 'header_number', + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + ('query_integer',): { + + "3": 3 + }, + ('query_string',): { + + "BRILLIG": "brillig" + }, + ('path_string',): { + + "HELLO": "hello" + }, + ('path_integer',): { + + "34": 34 + }, + ('header_number',): { + + "1.234": 1.234 + }, + }, + 'openapi_types': { + 'query_integer': 'int', + 'query_string': 'str', + 'path_string': 'str', + 'path_integer': 'int', + 'header_number': 'float', + }, + 'attribute_map': { + 'query_integer': 'query_integer', + 'query_string': 'query_string', + 'path_string': 'path_string', + 'path_integer': 'path_integer', + 'header_number': 'header_number', + }, + 'location_map': { + 'query_integer': 'query', + 'query_string': 'query', + 'path_string': 'path', + 'path_integer': 'path', + 'header_number': 'header', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__test_endpoint_enums_length_one + ) + + def __test_endpoint_parameters(self, number, double, pattern_without_delimiter, byte, **kwargs): # noqa: E501 + """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + + Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param float number: None (required) + :param float double: None (required) + :param str pattern_without_delimiter: None (required) + :param str byte: None (required) + :param int integer: None + :param int int32: None + :param int int64: None + :param float float: None + :param str string: None + :param file binary: None + :param date date: None + :param datetime date_time: None + :param str password: None + :param str param_callback: None + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True ) - allowed_values = ["hello"] # noqa: E501 - if ('path_string' in local_var_params and - local_var_params['path_string'] not in allowed_values): - raise ValueError( - "Invalid value for `path_string` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['path_string'], allowed_values) + kwargs['number'] = number + kwargs['double'] = double + kwargs['pattern_without_delimiter'] = pattern_without_delimiter + kwargs['byte'] = byte + return self.call_with_http_info(**kwargs) + + self.test_endpoint_parameters = Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'http_basic_test' + ], + 'endpoint_path': '/fake', + 'operation_id': 'test_endpoint_parameters', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'number', + 'double', + 'pattern_without_delimiter', + 'byte', + 'integer', + 'int32', + 'int64', + 'float', + 'string', + 'binary', + 'date', + 'date_time', + 'password', + 'param_callback', + ], + 'required': [ + 'number', + 'double', + 'pattern_without_delimiter', + 'byte', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + 'number', + 'double', + 'pattern_without_delimiter', + 'integer', + 'int32', + 'float', + 'string', + 'password', + ] + }, + root_map={ + 'validations': { + ('number',): { + + 'inclusive_maximum': 543.2, + 'inclusive_minimum': 32.1, + }, + ('double',): { + + 'inclusive_maximum': 123.4, + 'inclusive_minimum': 67.8, + }, + ('pattern_without_delimiter',): { + + 'regex': { + 'pattern': r'^[A-Z].*', # noqa: E501 + }, + }, + ('integer',): { + + 'inclusive_maximum': 100, + 'inclusive_minimum': 10, + }, + ('int32',): { + + 'inclusive_maximum': 200, + 'inclusive_minimum': 20, + }, + ('float',): { + + 'inclusive_maximum': 987.6, + }, + ('string',): { + + 'regex': { + 'pattern': r'[a-z]', # noqa: E501 + 'flags': (re.IGNORECASE) + }, + }, + ('password',): { + 'max_length': 64, + 'min_length': 10, + }, + }, + 'allowed_values': { + }, + 'openapi_types': { + 'number': 'float', + 'double': 'float', + 'pattern_without_delimiter': 'str', + 'byte': 'str', + 'integer': 'int', + 'int32': 'int', + 'int64': 'int', + 'float': 'float', + 'string': 'str', + 'binary': 'file', + 'date': 'date', + 'date_time': 'datetime', + 'password': 'str', + 'param_callback': 'str', + }, + 'attribute_map': { + 'number': 'number', + 'double': 'double', + 'pattern_without_delimiter': 'pattern_without_delimiter', + 'byte': 'byte', + 'integer': 'integer', + 'int32': 'int32', + 'int64': 'int64', + 'float': 'float', + 'string': 'string', + 'binary': 'binary', + 'date': 'date', + 'date_time': 'dateTime', + 'password': 'password', + 'param_callback': 'callback', + }, + 'location_map': { + 'number': 'form', + 'double': 'form', + 'pattern_without_delimiter': 'form', + 'byte': 'form', + 'integer': 'form', + 'int32': 'form', + 'int64': 'form', + 'float': 'form', + 'string': 'form', + 'binary': 'form', + 'date': 'form', + 'date_time': 'form', + 'password': 'form', + 'param_callback': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/x-www-form-urlencoded' + ] + }, + api_client=api_client, + callable=__test_endpoint_parameters + ) + + def __test_enum_parameters(self, **kwargs): # noqa: E501 + """To test enum parameters # noqa: E501 + + To test enum parameters # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_enum_parameters(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param list[str] enum_header_string_array: Header parameter enum test (string array) + :param str enum_header_string: Header parameter enum test (string) + :param list[str] enum_query_string_array: Query parameter enum test (string array) + :param str enum_query_string: Query parameter enum test (string) + :param int enum_query_integer: Query parameter enum test (double) + :param float enum_query_double: Query parameter enum test (double) + :param list[str] enum_form_string_array: Form parameter enum test (string array) + :param str enum_form_string: Form parameter enum test (string) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True ) - allowed_values = [34] # noqa: E501 - if ('path_integer' in local_var_params and - local_var_params['path_integer'] not in allowed_values): - raise ValueError( - "Invalid value for `path_integer` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['path_integer'], allowed_values) + return self.call_with_http_info(**kwargs) + + self.test_enum_parameters = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake', + 'operation_id': 'test_enum_parameters', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + 'enum_header_string_array', + 'enum_header_string', + 'enum_query_string_array', + 'enum_query_string', + 'enum_query_integer', + 'enum_query_double', + 'enum_form_string_array', + 'enum_form_string', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + 'enum_header_string_array', + 'enum_header_string', + 'enum_query_string_array', + 'enum_query_string', + 'enum_query_integer', + 'enum_query_double', + 'enum_form_string_array', + 'enum_form_string', + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + ('enum_header_string_array',): { + + ">": ">", + "$": "$" + }, + ('enum_header_string',): { + + "_ABC": "_abc", + "-EFG": "-efg", + "(XYZ)": "(xyz)" + }, + ('enum_query_string_array',): { + + ">": ">", + "$": "$" + }, + ('enum_query_string',): { + + "_ABC": "_abc", + "-EFG": "-efg", + "(XYZ)": "(xyz)" + }, + ('enum_query_integer',): { + + "1": 1, + "-2": -2 + }, + ('enum_query_double',): { + + "1.1": 1.1, + "-1.2": -1.2 + }, + ('enum_form_string_array',): { + + ">": ">", + "$": "$" + }, + ('enum_form_string',): { + + "_ABC": "_abc", + "-EFG": "-efg", + "(XYZ)": "(xyz)" + }, + }, + 'openapi_types': { + 'enum_header_string_array': 'list[str]', + 'enum_header_string': 'str', + 'enum_query_string_array': 'list[str]', + 'enum_query_string': 'str', + 'enum_query_integer': 'int', + 'enum_query_double': 'float', + 'enum_form_string_array': 'list[str]', + 'enum_form_string': 'str', + }, + 'attribute_map': { + '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', + }, + 'location_map': { + 'enum_header_string_array': 'header', + 'enum_header_string': 'header', + 'enum_query_string_array': 'query', + 'enum_query_string': 'query', + 'enum_query_integer': 'query', + 'enum_query_double': 'query', + 'enum_form_string_array': 'form', + 'enum_form_string': 'form', + }, + 'collection_format_map': { + 'enum_header_string_array': 'csv', + 'enum_query_string_array': 'csv', + 'enum_form_string_array': 'csv', + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/x-www-form-urlencoded' + ] + }, + api_client=api_client, + callable=__test_enum_parameters + ) + + def __test_group_parameters(self, required_string_group, required_boolean_group, required_int64_group, **kwargs): # noqa: E501 + """Fake endpoint to test group parameters (optional) # noqa: E501 + + Fake endpoint to test group parameters (optional) # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param int required_string_group: Required String in group parameters (required) + :param bool required_boolean_group: Required Boolean in group parameters (required) + :param int required_int64_group: Required Integer in group parameters (required) + :param int string_group: String in group parameters + :param bool boolean_group: Boolean in group parameters + :param int int64_group: Integer in group parameters + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True ) - allowed_values = [1.234] # noqa: E501 - if ('header_number' in local_var_params and - local_var_params['header_number'] not in allowed_values): - raise ValueError( - "Invalid value for `header_number` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['header_number'], allowed_values) + kwargs['required_string_group'] = required_string_group + kwargs['required_boolean_group'] = required_boolean_group + kwargs['required_int64_group'] = required_int64_group + return self.call_with_http_info(**kwargs) + + self.test_group_parameters = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake', + 'operation_id': 'test_group_parameters', + 'http_method': 'DELETE', + 'servers': [], + }, + params_map={ + 'all': [ + 'required_string_group', + 'required_boolean_group', + 'required_int64_group', + 'string_group', + 'boolean_group', + 'int64_group', + ], + 'required': [ + 'required_string_group', + 'required_boolean_group', + 'required_int64_group', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'required_string_group': 'int', + 'required_boolean_group': 'bool', + 'required_int64_group': 'int', + 'string_group': 'int', + 'boolean_group': 'bool', + 'int64_group': 'int', + }, + 'attribute_map': { + 'required_string_group': 'required_string_group', + 'required_boolean_group': 'required_boolean_group', + 'required_int64_group': 'required_int64_group', + 'string_group': 'string_group', + 'boolean_group': 'boolean_group', + 'int64_group': 'int64_group', + }, + 'location_map': { + 'required_string_group': 'query', + 'required_boolean_group': 'header', + 'required_int64_group': 'query', + 'string_group': 'query', + 'boolean_group': 'header', + 'int64_group': 'query', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__test_group_parameters + ) + + def __test_inline_additional_properties(self, param, **kwargs): # noqa: E501 + """test inline additionalProperties # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_inline_additional_properties(param, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param dict(str, str) param: request body (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True ) - - collection_formats = {} - - path_params = {} - if 'path_string' in local_var_params: - path_params['path_string'] = local_var_params['path_string'] # noqa: E501 - if 'path_integer' in local_var_params: - path_params['path_integer'] = local_var_params['path_integer'] # noqa: E501 - - query_params = [] - if 'query_integer' in local_var_params: - query_params.append(('query_integer', local_var_params['query_integer'])) # noqa: E501 - if 'query_string' in local_var_params: - query_params.append(('query_string', local_var_params['query_string'])) # noqa: E501 - - header_params = {} - if 'header_number' in local_var_params: - header_params['header_number'] = local_var_params['header_number'] # noqa: E501 - - form_params = [] - local_var_files = {} - - body_params = None - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/enums-of-length-one/{path_string}/{path_integer}', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_endpoint_parameters(self, number, double, pattern_without_delimiter, byte, **kwargs): # noqa: E501 - """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 - - Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, async_req=True) - >>> result = thread.get() - - Args: - number (float): None double (float): None pattern_without_delimiter (str): None byte (str): None - - Keyword Args: - integer (int): None. [optional] - int32 (int): None. [optional] - int64 (int): None. [optional] - float (float): None. [optional] - string (str): None. [optional] - binary (file): None. [optional] - date (date): None. [optional] - date_time (datetime): None. [optional] - password (str): None. [optional] - param_callback (str): None. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + kwargs['param'] = param + return self.call_with_http_info(**kwargs) + + self.test_inline_additional_properties = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/inline-additionalProperties', + 'operation_id': 'test_inline_additional_properties', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'param', + ], + 'required': [ + 'param', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'param': 'dict(str, str)', + }, + 'attribute_map': { + }, + 'location_map': { + 'param': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_inline_additional_properties + ) + + def __test_json_form_data(self, param, param2, **kwargs): # noqa: E501 + """test json serialization of form data # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_json_form_data(param, param2, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str param: field1 (required) + :param str param2: field2 (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, **kwargs) # noqa: E501 - else: - (data) = self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, **kwargs) # noqa: E501 - return data - - def test_endpoint_parameters_with_http_info(self, number, double, pattern_without_delimiter, byte, **kwargs): # noqa: E501 - """Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 - - Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, async_req=True) - >>> result = thread.get() + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['param'] = param + kwargs['param2'] = param2 + return self.call_with_http_info(**kwargs) + + self.test_json_form_data = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/fake/jsonFormData', + 'operation_id': 'test_json_form_data', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + 'param', + 'param2', + ], + 'required': [ + 'param', + 'param2', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'param': 'str', + 'param2': 'str', + }, + 'attribute_map': { + 'param': 'param', + 'param2': 'param2', + }, + 'location_map': { + 'param': 'form', + 'param2': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/x-www-form-urlencoded' + ] + }, + api_client=api_client, + callable=__test_json_form_data + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint Args: - number (float): None double (float): None pattern_without_delimiter (str): None byte (str): None - - Keyword Args: - integer (int): None. [optional] - int32 (int): None. [optional] - int64 (int): None. [optional] - float (float): None. [optional] - string (str): None. [optional] - binary (file): None. [optional] - date (date): None. [optional] - date_time (datetime): None. [optional] - password (str): None. [optional] - param_callback (str): None. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: + settings (dict): see below key value pairs + 'response_type' (str): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called """ - - local_var_params = locals() - - all_params = ['number', 'double', 'pattern_without_delimiter', 'byte', 'integer', 'int32', 'int64', 'float', 'string', 'binary', 'date', 'date_time', 'password', 'param_callback'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_endpoint_parameters" % key + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only' + ]) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param], + self.validations ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'number' is set - if ('number' not in local_var_params or - local_var_params['number'] is None): - raise ApiValueError("Missing the required parameter `number` when calling `test_endpoint_parameters`") # noqa: E501 - # verify the required parameter 'double' is set - if ('double' not in local_var_params or - local_var_params['double'] is None): - raise ApiValueError("Missing the required parameter `double` when calling `test_endpoint_parameters`") # noqa: E501 - # verify the required parameter 'pattern_without_delimiter' is set - if ('pattern_without_delimiter' not in local_var_params or - local_var_params['pattern_without_delimiter'] is None): - raise ApiValueError("Missing the required parameter `pattern_without_delimiter` when calling `test_endpoint_parameters`") # noqa: E501 - # verify the required parameter 'byte' is set - if ('byte' not in local_var_params or - local_var_params['byte'] is None): - raise ApiValueError("Missing the required parameter `byte` when calling `test_endpoint_parameters`") # noqa: E501 - if 'number' in local_var_params and local_var_params['number'] > 543.2: # noqa: E501 - raise ApiValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value less than or equal to `543.2`") # noqa: E501 - if 'number' in local_var_params and local_var_params['number'] < 32.1: # noqa: E501 - raise ApiValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value greater than or equal to `32.1`") # noqa: E501 - if 'double' in local_var_params and local_var_params['double'] > 123.4: # noqa: E501 - raise ApiValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value less than or equal to `123.4`") # noqa: E501 - if 'double' in local_var_params and local_var_params['double'] < 67.8: # noqa: E501 - raise ApiValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value greater than or equal to `67.8`") # noqa: E501 - if 'pattern_without_delimiter' in local_var_params and not re.search(r'^[A-Z].*', local_var_params['pattern_without_delimiter']): # noqa: E501 - raise ApiValueError("Invalid value for parameter `pattern_without_delimiter` when calling `test_endpoint_parameters`, must conform to the pattern `/^[A-Z].*/`") # noqa: E501 - if 'integer' in local_var_params and local_var_params['integer'] > 100: # noqa: E501 - raise ApiValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value less than or equal to `100`") # noqa: E501 - if 'integer' in local_var_params and local_var_params['integer'] < 10: # noqa: E501 - raise ApiValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value greater than or equal to `10`") # noqa: E501 - if 'int32' in local_var_params and local_var_params['int32'] > 200: # noqa: E501 - raise ApiValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value less than or equal to `200`") # noqa: E501 - if 'int32' in local_var_params and local_var_params['int32'] < 20: # noqa: E501 - raise ApiValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value greater than or equal to `20`") # noqa: E501 - if 'float' in local_var_params and local_var_params['float'] > 987.6: # noqa: E501 - raise ApiValueError("Invalid value for parameter `float` when calling `test_endpoint_parameters`, must be a value less than or equal to `987.6`") # noqa: E501 - if 'string' in local_var_params and not re.search(r'[a-z]', local_var_params['string'], flags=re.IGNORECASE): # noqa: E501 - raise ApiValueError("Invalid value for parameter `string` when calling `test_endpoint_parameters`, must conform to the pattern `/[a-z]/i`") # noqa: E501 - if ('password' in local_var_params and - len(local_var_params['password']) > 64): - raise ApiValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be less than or equal to `64`") # noqa: E501 - if ('password' in local_var_params and - len(local_var_params['password']) < 10): - raise ApiValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be greater than or equal to `10`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - if 'integer' in local_var_params: - form_params.append(('integer', local_var_params['integer'])) # noqa: E501 - if 'int32' in local_var_params: - form_params.append(('int32', local_var_params['int32'])) # noqa: E501 - if 'int64' in local_var_params: - form_params.append(('int64', local_var_params['int64'])) # noqa: E501 - if 'number' in local_var_params: - form_params.append(('number', local_var_params['number'])) # noqa: E501 - if 'float' in local_var_params: - form_params.append(('float', local_var_params['float'])) # noqa: E501 - if 'double' in local_var_params: - form_params.append(('double', local_var_params['double'])) # noqa: E501 - if 'string' in local_var_params: - form_params.append(('string', local_var_params['string'])) # noqa: E501 - if 'pattern_without_delimiter' in local_var_params: - form_params.append(('pattern_without_delimiter', local_var_params['pattern_without_delimiter'])) # noqa: E501 - if 'byte' in local_var_params: - form_params.append(('byte', local_var_params['byte'])) # noqa: E501 - if 'binary' in local_var_params: - local_var_files['binary'] = local_var_params['binary'] # noqa: E501 - if 'date' in local_var_params: - form_params.append(('date', local_var_params['date'])) # noqa: E501 - if 'date_time' in local_var_params: - form_params.append(('dateTime', local_var_params['date_time'])) # noqa: E501 - if 'password' in local_var_params: - form_params.append(('password', local_var_params['password'])) # noqa: E501 - if 'param_callback' in local_var_params: - form_params.append(('callback', local_var_params['param_callback'])) # noqa: E501 - - body_params = None - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/x-www-form-urlencoded']) # noqa: E501 - - # Authentication setting - auth_settings = ['http_basic_test'] # noqa: E501 - - return self.api_client.call_api( - '/fake', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_enum_parameters(self, **kwargs): # noqa: E501 - """To test enum parameters # noqa: E501 - - To test enum parameters # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_enum_parameters(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - enum_header_string_array (list[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 (list[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 (list[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' - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_enum_parameters_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.test_enum_parameters_with_http_info(**kwargs) # noqa: E501 - return data - - def test_enum_parameters_with_http_info(self, **kwargs): # noqa: E501 - """To test enum parameters # noqa: E501 - - To test enum parameters # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_enum_parameters_with_http_info(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - enum_header_string_array (list[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 (list[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 (list[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' - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - all_params = ['enum_header_string_array', 'enum_header_string', 'enum_query_string_array', 'enum_query_string', 'enum_query_integer', 'enum_query_double', 'enum_form_string_array', 'enum_form_string'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_enum_parameters" % key + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param] ) - local_var_params[key] = val - del local_var_params['kwargs'] - allowed_values = [">", "$"] # noqa: E501 - if ('enum_header_string_array' in local_var_params and - not set(local_var_params['enum_header_string_array']).issubset(set(allowed_values))): # noqa: E501 - raise ValueError( - "Invalid values for `enum_header_string_array` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(local_var_params['enum_header_string_array']) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) - allowed_values = ["_abc", "-efg", "(xyz)"] # noqa: E501 - if ('enum_header_string' in local_var_params and - local_var_params['enum_header_string'] not in allowed_values): - raise ValueError( - "Invalid value for `enum_header_string` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['enum_header_string'], allowed_values) - ) - allowed_values = [">", "$"] # noqa: E501 - if ('enum_query_string_array' in local_var_params and - not set(local_var_params['enum_query_string_array']).issubset(set(allowed_values))): # noqa: E501 - raise ValueError( - "Invalid values for `enum_query_string_array` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(local_var_params['enum_query_string_array']) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) - allowed_values = ["_abc", "-efg", "(xyz)"] # noqa: E501 - if ('enum_query_string' in local_var_params and - local_var_params['enum_query_string'] not in allowed_values): - raise ValueError( - "Invalid value for `enum_query_string` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['enum_query_string'], allowed_values) - ) - allowed_values = [1, -2] # noqa: E501 - if ('enum_query_integer' in local_var_params and - local_var_params['enum_query_integer'] not in allowed_values): - raise ValueError( - "Invalid value for `enum_query_integer` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['enum_query_integer'], allowed_values) - ) - allowed_values = [1.1, -1.2] # noqa: E501 - if ('enum_query_double' in local_var_params and - local_var_params['enum_query_double'] not in allowed_values): - raise ValueError( - "Invalid value for `enum_query_double` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['enum_query_double'], allowed_values) - ) - allowed_values = [">", "$"] # noqa: E501 - if ('enum_form_string_array' in local_var_params and - not set(local_var_params['enum_form_string_array']).issubset(set(allowed_values))): # noqa: E501 - raise ValueError( - "Invalid values for `enum_form_string_array` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(local_var_params['enum_form_string_array']) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) - allowed_values = ["_abc", "-efg", "(xyz)"] # noqa: E501 - if ('enum_form_string' in local_var_params and - local_var_params['enum_form_string'] not in allowed_values): - raise ValueError( - "Invalid value for `enum_form_string` ({0}), must be one of {1}" # noqa: E501 - .format(local_var_params['enum_form_string'], allowed_values) - ) - - collection_formats = {} - - path_params = {} - - query_params = [] - if 'enum_query_string_array' in local_var_params: - query_params.append(('enum_query_string_array', local_var_params['enum_query_string_array'])) # noqa: E501 - collection_formats['enum_query_string_array'] = 'csv' # noqa: E501 - if 'enum_query_string' in local_var_params: - query_params.append(('enum_query_string', local_var_params['enum_query_string'])) # noqa: E501 - if 'enum_query_integer' in local_var_params: - query_params.append(('enum_query_integer', local_var_params['enum_query_integer'])) # noqa: E501 - if 'enum_query_double' in local_var_params: - query_params.append(('enum_query_double', local_var_params['enum_query_double'])) # noqa: E501 - - header_params = {} - if 'enum_header_string_array' in local_var_params: - header_params['enum_header_string_array'] = local_var_params['enum_header_string_array'] # noqa: E501 - collection_formats['enum_header_string_array'] = 'csv' # noqa: E501 - if 'enum_header_string' in local_var_params: - header_params['enum_header_string'] = local_var_params['enum_header_string'] # noqa: E501 - - form_params = [] - local_var_files = {} - if 'enum_form_string_array' in local_var_params: - form_params.append(('enum_form_string_array', local_var_params['enum_form_string_array'])) # noqa: E501 - collection_formats['enum_form_string_array'] = 'csv' # noqa: E501 - if 'enum_form_string' in local_var_params: - form_params.append(('enum_form_string', local_var_params['enum_form_string'])) # noqa: E501 - - body_params = None - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/x-www-form-urlencoded']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - return self.api_client.call_api( - '/fake', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_group_parameters(self, required_string_group, required_boolean_group, required_int64_group, **kwargs): # noqa: E501 - """Fake endpoint to test group parameters (optional) # noqa: E501 - - Fake endpoint to test group parameters (optional) # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_group_parameters(required_string_group, required_boolean_group, required_int64_group, async_req=True) - >>> result = thread.get() - - Args: - required_string_group (int): Required String in group parameters required_boolean_group (bool): Required Boolean in group parameters required_int64_group (int): Required Integer in group parameters - - Keyword Args: - string_group (int): String in group parameters. [optional] - boolean_group (bool): Boolean in group parameters. [optional] - int64_group (int): Integer in group parameters. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, **kwargs) # noqa: E501 - else: - (data) = self.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, **kwargs) # noqa: E501 - return data - - def test_group_parameters_with_http_info(self, required_string_group, required_boolean_group, required_int64_group, **kwargs): # noqa: E501 - """Fake endpoint to test group parameters (optional) # noqa: E501 - - Fake endpoint to test group parameters (optional) # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_group_parameters_with_http_info(required_string_group, required_boolean_group, required_int64_group, async_req=True) - >>> result = thread.get() - - Args: - required_string_group (int): Required String in group parameters required_boolean_group (bool): Required Boolean in group parameters required_int64_group (int): Required Integer in group parameters - - Keyword Args: - string_group (int): String in group parameters. [optional] - boolean_group (bool): Boolean in group parameters. [optional] - int64_group (int): Integer in group parameters. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == 'file'): + param_location = 'file' + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class """ - - local_var_params = locals() - - all_params = ['required_string_group', 'required_boolean_group', 'required_int64_group', 'string_group', 'boolean_group', 'int64_group'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_group_parameters" % key + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + if kwargs.get('_host_index') and self.settings['servers']: + _host_index = kwargs.get('_host_index') + try: + _host = self.settings['servers'][_host_index] + except IndexError: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'required_string_group' is set - if ('required_string_group' not in local_var_params or - local_var_params['required_string_group'] is None): - raise ApiValueError("Missing the required parameter `required_string_group` when calling `test_group_parameters`") # noqa: E501 - # verify the required parameter 'required_boolean_group' is set - if ('required_boolean_group' not in local_var_params or - local_var_params['required_boolean_group'] is None): - raise ApiValueError("Missing the required parameter `required_boolean_group` when calling `test_group_parameters`") # noqa: E501 - # verify the required parameter 'required_int64_group' is set - if ('required_int64_group' not in local_var_params or - local_var_params['required_int64_group'] is None): - raise ApiValueError("Missing the required parameter `required_int64_group` when calling `test_group_parameters`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - if 'required_string_group' in local_var_params: - query_params.append(('required_string_group', local_var_params['required_string_group'])) # noqa: E501 - if 'required_int64_group' in local_var_params: - query_params.append(('required_int64_group', local_var_params['required_int64_group'])) # noqa: E501 - if 'string_group' in local_var_params: - query_params.append(('string_group', local_var_params['string_group'])) # noqa: E501 - if 'int64_group' in local_var_params: - query_params.append(('int64_group', local_var_params['int64_group'])) # noqa: E501 - - header_params = {} - if 'required_boolean_group' in local_var_params: - header_params['required_boolean_group'] = local_var_params['required_boolean_group'] # noqa: E501 - if 'boolean_group' in local_var_params: - header_params['boolean_group'] = local_var_params['boolean_group'] # noqa: E501 - - form_params = [] - local_var_files = {} - - body_params = None - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_inline_additional_properties(self, param, **kwargs): # noqa: E501 - """test inline additionalProperties # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_inline_additional_properties(param, async_req=True) - >>> result = thread.get() - - Args: - param (dict(str, str)): request body - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_inline_additional_properties_with_http_info(param, **kwargs) # noqa: E501 else: - (data) = self.test_inline_additional_properties_with_http_info(param, **kwargs) # noqa: E501 - return data - - def test_inline_additional_properties_with_http_info(self, param, **kwargs): # noqa: E501 - """test inline additionalProperties # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_inline_additional_properties_with_http_info(param, async_req=True) - >>> result = thread.get() - - Args: - param (dict(str, str)): request body - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ + try: + _host = self.settings['servers'][0] + except IndexError: + _host = None - local_var_params = locals() - - all_params = ['param'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_inline_additional_properties" % key + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'param' is set - if ('param' not in local_var_params or - local_var_params['param'] is None): - raise ApiValueError("Missing the required parameter `param` when calling `test_inline_additional_properties`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'param' in local_var_params: - body_params = local_var_params['param'] - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/fake/inline-additionalProperties', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def test_json_form_data(self, param, param2, **kwargs): # noqa: E501 - """test json serialization of form data # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_json_form_data(param, param2, async_req=True) - >>> result = thread.get() - - Args: - param (str): field1 param2 (str): field2 - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501 - else: - (data) = self.test_json_form_data_with_http_info(param, param2, **kwargs) # noqa: E501 - return data - - def test_json_form_data_with_http_info(self, param, param2, **kwargs): # noqa: E501 - """test json serialization of form data # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_json_form_data_with_http_info(param, param2, async_req=True) - >>> result = thread.get() - - Args: - param (str): field1 param2 (str): field2 - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['param', 'param2'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_json_form_data" % key + if key not in self.params_map['nullable'] and value is None: + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'param' is set - if ('param' not in local_var_params or - local_var_params['param'] is None): - raise ApiValueError("Missing the required parameter `param` when calling `test_json_form_data`") # noqa: E501 - # verify the required parameter 'param2' is set - if ('param2' not in local_var_params or - local_var_params['param2'] is None): - raise ApiValueError("Missing the required parameter `param2` when calling `test_json_form_data`") # noqa: E501 - - collection_formats = {} - path_params = {} - - query_params = [] + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - header_params = {} + self.__validate_inputs(kwargs) - form_params = [] - local_var_files = {} - if 'param' in local_var_params: - form_params.append(('param', local_var_params['param'])) # noqa: E501 - if 'param2' in local_var_params: - form_params.append(('param2', local_var_params['param2'])) # noqa: E501 + params = self.__gather_params(kwargs) - body_params = None - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/x-www-form-urlencoded']) # noqa: E501 + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - # Authentication setting - auth_settings = [] # noqa: E501 + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - '/fake/jsonFormData', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs.get('async_req'), + _return_http_data_only=kwargs.get('_return_http_data_only'), + _preload_content=kwargs.get('_preload_content', True), + _request_timeout=kwargs.get('_request_timeout'), + _host=_host, + collection_formats=params['collection_format']) 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 f054a0a8ec77..6811a990bbcc 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 @@ -18,10 +18,14 @@ import six from petstore_api.api_client import ApiClient -from petstore_api.exceptions import ( # noqa: F401 +from petstore_api.exceptions import ( ApiTypeError, ApiValueError ) +from petstore_api.model_utils import ( + check_allowed_values, + check_validations +) class FakeClassnameTags123Api(object): @@ -36,122 +40,271 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def test_classname(self, body, **kwargs): # noqa: E501 - """To test class name in snake case # noqa: E501 - - To test class name in snake case # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_classname(body, async_req=True) - >>> result = thread.get() - - Args: - body (Client): client model - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + def __test_classname(self, body, **kwargs): # noqa: E501 + """To test class name in snake case # noqa: E501 + + To test class name in snake case # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.test_classname(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param Client body: client model (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Client: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.test_classname_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.test_classname_with_http_info(body, **kwargs) # noqa: E501 - return data - - def test_classname_with_http_info(self, body, **kwargs): # noqa: E501 - """To test class name in snake case # noqa: E501 - - To test class name in snake case # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.test_classname_with_http_info(body, async_req=True) - >>> result = thread.get() + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: Client + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.test_classname = Endpoint( + settings={ + 'response_type': 'Client', + 'auth': [ + 'api_key_query' + ], + 'endpoint_path': '/fake_classname_test', + 'operation_id': 'test_classname', + 'http_method': 'PATCH', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'Client', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client, + callable=__test_classname + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint Args: - body (Client): client model - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Client: + settings (dict): see below key value pairs + 'response_type' (str): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called """ + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only' + ]) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param], + self.validations + ) - local_var_params = locals() + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param] + ) - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == 'file'): + param_location = 'file' + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class + """ + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + if kwargs.get('_host_index') and self.settings['servers']: + _host_index = kwargs.get('_host_index') + try: + _host = self.settings['servers'][_host_index] + except IndexError: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) + else: + try: + _host = self.settings['servers'][0] + except IndexError: + _host = None - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method test_classname" % key + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + if key not in self.params_map['nullable'] and value is None: + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `test_classname`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - header_params = {} + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - form_params = [] - local_var_files = {} + self.__validate_inputs(kwargs) - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + params = self.__gather_params(kwargs) - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - # Authentication setting - auth_settings = ['api_key_query'] # noqa: E501 + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - '/fake_classname_test', 'PATCH', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='Client', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs.get('async_req'), + _return_http_data_only=kwargs.get('_return_http_data_only'), + _preload_content=kwargs.get('_preload_content', True), + _request_timeout=kwargs.get('_request_timeout'), + _host=_host, + collection_formats=params['collection_format']) 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 bd1b58aa9ee5..29bbead6c35a 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 @@ -18,10 +18,14 @@ import six from petstore_api.api_client import ApiClient -from petstore_api.exceptions import ( # noqa: F401 +from petstore_api.exceptions import ( ApiTypeError, ApiValueError ) +from petstore_api.model_utils import ( + check_allowed_values, + check_validations +) class PetApi(object): @@ -36,1078 +40,963 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def add_pet(self, body, **kwargs): # noqa: E501 - """Add a new pet to the store # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.add_pet(body, async_req=True) - >>> result = thread.get() + def __add_pet(self, body, **kwargs): # noqa: E501 + """Add a new pet to the store # noqa: E501 - Args: - body (Pet): Pet object that needs to be added to the store + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.add_pet(body, async_req=True) + >>> result = thread.get() - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param async_req bool: execute request asynchronously + :param 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 + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.add_pet_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.add_pet_with_http_info(body, **kwargs) # noqa: E501 - return data - - def add_pet_with_http_info(self, body, **kwargs): # noqa: E501 - """Add a new pet to the store # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.add_pet_with_http_info(body, async_req=True) - >>> result = thread.get() - - Args: - body (Pet): Pet object that needs to be added to the store - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.add_pet = Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet', + 'operation_id': 'add_pet', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'Pet', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json', + 'application/xml' + ] + }, + api_client=api_client, + callable=__add_pet + ) + + def __delete_pet(self, pet_id, **kwargs): # noqa: E501 + """Deletes a pet # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_pet(pet_id, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param int pet_id: Pet id to delete (required) + :param str api_key: + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method add_pet" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `add_pet`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json', 'application/xml']) # noqa: E501 - - # Authentication setting - auth_settings = ['petstore_auth'] # noqa: E501 - - return self.api_client.call_api( - '/pet', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def delete_pet(self, pet_id, **kwargs): # noqa: E501 - """Deletes a pet # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_pet(pet_id, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): Pet id to delete - - Keyword Args: - api_key (str): [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['pet_id'] = pet_id + return self.call_with_http_info(**kwargs) + + self.delete_pet = Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/{petId}', + 'operation_id': 'delete_pet', + 'http_method': 'DELETE', + 'servers': [], + }, + params_map={ + 'all': [ + 'pet_id', + 'api_key', + ], + 'required': [ + 'pet_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': 'int', + 'api_key': 'str', + }, + 'attribute_map': { + 'pet_id': 'petId', + 'api_key': 'api_key', + }, + 'location_map': { + 'pet_id': 'path', + 'api_key': 'header', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__delete_pet + ) + + def __find_pets_by_status(self, status, **kwargs): # noqa: E501 + """Finds Pets by status # noqa: E501 + + Multiple status values can be provided with comma separated strings # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.find_pets_by_status(status, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param list[str] status: Status values that need to be considered for filter (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.delete_pet_with_http_info(pet_id, **kwargs) # noqa: E501 - else: - (data) = self.delete_pet_with_http_info(pet_id, **kwargs) # noqa: E501 - return data - - def delete_pet_with_http_info(self, pet_id, **kwargs): # noqa: E501 - """Deletes a pet # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_pet_with_http_info(pet_id, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): Pet id to delete - - Keyword Args: - api_key (str): [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: list[Pet] + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['status'] = status + return self.call_with_http_info(**kwargs) + + self.find_pets_by_status = Endpoint( + settings={ + 'response_type': 'list[Pet]', + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/findByStatus', + 'operation_id': 'find_pets_by_status', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + 'status', + ], + 'required': [ + 'status', + ], + 'nullable': [ + ], + 'enum': [ + 'status', + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + ('status',): { + + "AVAILABLE": "available", + "PENDING": "pending", + "SOLD": "sold" + }, + }, + 'openapi_types': { + 'status': 'list[str]', + }, + 'attribute_map': { + 'status': 'status', + }, + 'location_map': { + 'status': 'query', + }, + 'collection_format_map': { + 'status': 'csv', + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__find_pets_by_status + ) + + def __find_pets_by_tags(self, tags, **kwargs): # noqa: E501 + """Finds Pets by tags # noqa: E501 + + Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.find_pets_by_tags(tags, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param list[str] tags: Tags to filter by (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['pet_id', 'api_key'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_pet" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'pet_id' is set - if ('pet_id' not in local_var_params or - local_var_params['pet_id'] is None): - raise ApiValueError("Missing the required parameter `pet_id` when calling `delete_pet`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'pet_id' in local_var_params: - path_params['petId'] = local_var_params['pet_id'] # noqa: E501 - - query_params = [] - - header_params = {} - if 'api_key' in local_var_params: - header_params['api_key'] = local_var_params['api_key'] # noqa: E501 - - form_params = [] - local_var_files = {} - - body_params = None - # Authentication setting - auth_settings = ['petstore_auth'] # noqa: E501 - - return self.api_client.call_api( - '/pet/{petId}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def find_pets_by_status(self, status, **kwargs): # noqa: E501 - """Finds Pets by status # noqa: E501 - - Multiple status values can be provided with comma separated strings # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.find_pets_by_status(status, async_req=True) - >>> result = thread.get() - - Args: - status (list[str]): Status values that need to be considered for filter - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: list[Pet] + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['tags'] = tags + return self.call_with_http_info(**kwargs) + + self.find_pets_by_tags = Endpoint( + settings={ + 'response_type': 'list[Pet]', + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/findByTags', + 'operation_id': 'find_pets_by_tags', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + 'tags', + ], + 'required': [ + 'tags', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'tags': 'list[str]', + }, + 'attribute_map': { + 'tags': 'tags', + }, + 'location_map': { + 'tags': 'query', + }, + 'collection_format_map': { + 'tags': 'csv', + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__find_pets_by_tags + ) + + def __get_pet_by_id(self, pet_id, **kwargs): # noqa: E501 + """Find pet by ID # noqa: E501 + + Returns a single pet # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_pet_by_id(pet_id, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param int pet_id: ID of pet to return (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - list[Pet]: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501 - else: - (data) = self.find_pets_by_status_with_http_info(status, **kwargs) # noqa: E501 - return data - - def find_pets_by_status_with_http_info(self, status, **kwargs): # noqa: E501 - """Finds Pets by status # noqa: E501 - - Multiple status values can be provided with comma separated strings # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.find_pets_by_status_with_http_info(status, async_req=True) - >>> result = thread.get() - - Args: - status (list[str]): Status values that need to be considered for filter - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: Pet + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['pet_id'] = pet_id + return self.call_with_http_info(**kwargs) + + self.get_pet_by_id = Endpoint( + settings={ + 'response_type': 'Pet', + 'auth': [ + 'api_key' + ], + 'endpoint_path': '/pet/{petId}', + 'operation_id': 'get_pet_by_id', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + 'pet_id', + ], + 'required': [ + 'pet_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': 'int', + }, + 'attribute_map': { + 'pet_id': 'petId', + }, + 'location_map': { + 'pet_id': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__get_pet_by_id + ) + + def __update_pet(self, body, **kwargs): # noqa: E501 + """Update an existing pet # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.update_pet(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param 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 + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - list[Pet]: - """ - - local_var_params = locals() - - all_params = ['status'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method find_pets_by_status" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'status' is set - if ('status' not in local_var_params or - local_var_params['status'] is None): - raise ApiValueError("Missing the required parameter `status` when calling `find_pets_by_status`") # noqa: E501 - allowed_values = ["available", "pending", "sold"] # noqa: E501 - if ('status' in local_var_params and - not set(local_var_params['status']).issubset(set(allowed_values))): # noqa: E501 - raise ValueError( - "Invalid values for `status` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(local_var_params['status']) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True ) - - collection_formats = {} - - path_params = {} - - query_params = [] - if 'status' in local_var_params: - query_params.append(('status', local_var_params['status'])) # noqa: E501 - collection_formats['status'] = 'csv' # noqa: E501 - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/xml', 'application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['petstore_auth'] # noqa: E501 - - return self.api_client.call_api( - '/pet/findByStatus', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='list[Pet]', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def find_pets_by_tags(self, tags, **kwargs): # noqa: E501 - """Finds Pets by tags # noqa: E501 - - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.find_pets_by_tags(tags, async_req=True) - >>> result = thread.get() - - Args: - tags (list[str]): Tags to filter by - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.update_pet = Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet', + 'operation_id': 'update_pet', + 'http_method': 'PUT', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'Pet', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/json', + 'application/xml' + ] + }, + api_client=api_client, + callable=__update_pet + ) + + def __update_pet_with_form(self, pet_id, **kwargs): # noqa: E501 + """Updates a pet in the store with form data # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.update_pet_with_form(pet_id, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param int pet_id: ID of pet that needs to be updated (required) + :param str name: Updated name of the pet + :param str status: Updated status of the pet + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - list[Pet]: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501 - else: - (data) = self.find_pets_by_tags_with_http_info(tags, **kwargs) # noqa: E501 - return data - - def find_pets_by_tags_with_http_info(self, tags, **kwargs): # noqa: E501 - """Finds Pets by tags # noqa: E501 - - Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.find_pets_by_tags_with_http_info(tags, async_req=True) - >>> result = thread.get() - - Args: - tags (list[str]): Tags to filter by - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['pet_id'] = pet_id + return self.call_with_http_info(**kwargs) + + self.update_pet_with_form = Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/{petId}', + 'operation_id': 'update_pet_with_form', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'pet_id', + 'name', + 'status', + ], + 'required': [ + 'pet_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': 'int', + 'name': 'str', + 'status': 'str', + }, + 'attribute_map': { + 'pet_id': 'petId', + 'name': 'name', + 'status': 'status', + }, + 'location_map': { + 'pet_id': 'path', + 'name': 'form', + 'status': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [ + 'application/x-www-form-urlencoded' + ] + }, + api_client=api_client, + callable=__update_pet_with_form + ) + + def __upload_file(self, pet_id, **kwargs): # noqa: E501 + """uploads an image # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.upload_file(pet_id, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param int pet_id: ID of pet to update (required) + :param str additional_metadata: Additional data to pass to server + :param file file: file to upload + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - list[Pet]: - """ - - local_var_params = locals() - - all_params = ['tags'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method find_pets_by_tags" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'tags' is set - if ('tags' not in local_var_params or - local_var_params['tags'] is None): - raise ApiValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - if 'tags' in local_var_params: - query_params.append(('tags', local_var_params['tags'])) # noqa: E501 - collection_formats['tags'] = 'csv' # noqa: E501 - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/xml', 'application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['petstore_auth'] # noqa: E501 - - return self.api_client.call_api( - '/pet/findByTags', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='list[Pet]', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_pet_by_id(self, pet_id, **kwargs): # noqa: E501 - """Find pet by ID # noqa: E501 - - Returns a single pet # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_pet_by_id(pet_id, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): ID of pet to return - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: ApiResponse + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['pet_id'] = pet_id + return self.call_with_http_info(**kwargs) + + self.upload_file = Endpoint( + settings={ + 'response_type': 'ApiResponse', + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/pet/{petId}/uploadImage', + 'operation_id': 'upload_file', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'pet_id', + 'additional_metadata', + 'file', + ], + 'required': [ + 'pet_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': 'int', + 'additional_metadata': 'str', + 'file': 'file', + }, + 'attribute_map': { + 'pet_id': 'petId', + 'additional_metadata': 'additionalMetadata', + 'file': 'file', + }, + 'location_map': { + 'pet_id': 'path', + 'additional_metadata': 'form', + 'file': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'multipart/form-data' + ] + }, + api_client=api_client, + callable=__upload_file + ) + + def __upload_file_with_required_file(self, pet_id, required_file, **kwargs): # noqa: E501 + """uploads an image (required) # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.upload_file_with_required_file(pet_id, required_file, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param int pet_id: ID of pet to update (required) + :param file required_file: file to upload (required) + :param str additional_metadata: Additional data to pass to server + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Pet: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501 - else: - (data) = self.get_pet_by_id_with_http_info(pet_id, **kwargs) # noqa: E501 - return data - - def get_pet_by_id_with_http_info(self, pet_id, **kwargs): # noqa: E501 - """Find pet by ID # noqa: E501 - - Returns a single pet # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_pet_by_id_with_http_info(pet_id, async_req=True) - >>> result = thread.get() + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: ApiResponse + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['pet_id'] = pet_id + kwargs['required_file'] = required_file + return self.call_with_http_info(**kwargs) + + self.upload_file_with_required_file = Endpoint( + settings={ + 'response_type': 'ApiResponse', + 'auth': [ + 'petstore_auth' + ], + 'endpoint_path': '/fake/{petId}/uploadImageWithRequiredFile', + 'operation_id': 'upload_file_with_required_file', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'pet_id', + 'required_file', + 'additional_metadata', + ], + 'required': [ + 'pet_id', + 'required_file', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'pet_id': 'int', + 'required_file': 'file', + 'additional_metadata': 'str', + }, + 'attribute_map': { + 'pet_id': 'petId', + 'required_file': 'requiredFile', + 'additional_metadata': 'additionalMetadata', + }, + 'location_map': { + 'pet_id': 'path', + 'required_file': 'form', + 'additional_metadata': 'form', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'multipart/form-data' + ] + }, + api_client=api_client, + callable=__upload_file_with_required_file + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint Args: - pet_id (int): ID of pet to return - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Pet: + settings (dict): see below key value pairs + 'response_type' (str): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called """ - - local_var_params = locals() - - all_params = ['pet_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_pet_by_id" % key + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only' + ]) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param], + self.validations ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'pet_id' is set - if ('pet_id' not in local_var_params or - local_var_params['pet_id'] is None): - raise ApiValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'pet_id' in local_var_params: - path_params['petId'] = local_var_params['pet_id'] # noqa: E501 - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/xml', 'application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['api_key'] # noqa: E501 - - return self.api_client.call_api( - '/pet/{petId}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='Pet', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def update_pet(self, body, **kwargs): # noqa: E501 - """Update an existing pet # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_pet(body, async_req=True) - >>> result = thread.get() - - Args: - body (Pet): Pet object that needs to be added to the store - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_pet_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.update_pet_with_http_info(body, **kwargs) # noqa: E501 - return data - - def update_pet_with_http_info(self, body, **kwargs): # noqa: E501 - """Update an existing pet # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_pet_with_http_info(body, async_req=True) - >>> result = thread.get() - - Args: - body (Pet): Pet object that needs to be added to the store - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method update_pet" % key + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param] ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `update_pet`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json', 'application/xml']) # noqa: E501 - - # Authentication setting - auth_settings = ['petstore_auth'] # noqa: E501 - - return self.api_client.call_api( - '/pet', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def update_pet_with_form(self, pet_id, **kwargs): # noqa: E501 - """Updates a pet in the store with form data # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_pet_with_form(pet_id, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): ID of pet that needs to be updated - - Keyword Args: - name (str): Updated name of the pet. [optional] - status (str): Updated status of the pet. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_pet_with_form_with_http_info(pet_id, **kwargs) # noqa: E501 - else: - (data) = self.update_pet_with_form_with_http_info(pet_id, **kwargs) # noqa: E501 - return data - - def update_pet_with_form_with_http_info(self, pet_id, **kwargs): # noqa: E501 - """Updates a pet in the store with form data # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_pet_with_form_with_http_info(pet_id, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): ID of pet that needs to be updated - - Keyword Args: - name (str): Updated name of the pet. [optional] - status (str): Updated status of the pet. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == 'file'): + param_location = 'file' + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class """ - - local_var_params = locals() - - all_params = ['pet_id', 'name', 'status'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method update_pet_with_form" % key + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + if kwargs.get('_host_index') and self.settings['servers']: + _host_index = kwargs.get('_host_index') + try: + _host = self.settings['servers'][_host_index] + except IndexError: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'pet_id' is set - if ('pet_id' not in local_var_params or - local_var_params['pet_id'] is None): - raise ApiValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'pet_id' in local_var_params: - path_params['petId'] = local_var_params['pet_id'] # noqa: E501 - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - if 'name' in local_var_params: - form_params.append(('name', local_var_params['name'])) # noqa: E501 - if 'status' in local_var_params: - form_params.append(('status', local_var_params['status'])) # noqa: E501 - - body_params = None - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/x-www-form-urlencoded']) # noqa: E501 - - # Authentication setting - auth_settings = ['petstore_auth'] # noqa: E501 - - return self.api_client.call_api( - '/pet/{petId}', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def upload_file(self, pet_id, **kwargs): # noqa: E501 - """uploads an image # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.upload_file(pet_id, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): ID of pet to update - - Keyword Args: - additional_metadata (str): Additional data to pass to server. [optional] - file (file): file to upload. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - ApiResponse: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.upload_file_with_http_info(pet_id, **kwargs) # noqa: E501 else: - (data) = self.upload_file_with_http_info(pet_id, **kwargs) # noqa: E501 - return data - - def upload_file_with_http_info(self, pet_id, **kwargs): # noqa: E501 - """uploads an image # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.upload_file_with_http_info(pet_id, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): ID of pet to update - - Keyword Args: - additional_metadata (str): Additional data to pass to server. [optional] - file (file): file to upload. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - ApiResponse: - """ + try: + _host = self.settings['servers'][0] + except IndexError: + _host = None - local_var_params = locals() - - all_params = ['pet_id', 'additional_metadata', 'file'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method upload_file" % key + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + if key not in self.params_map['nullable'] and value is None: + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'pet_id' is set - if ('pet_id' not in local_var_params or - local_var_params['pet_id'] is None): - raise ApiValueError("Missing the required parameter `pet_id` when calling `upload_file`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'pet_id' in local_var_params: - path_params['petId'] = local_var_params['pet_id'] # noqa: E501 - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - if 'additional_metadata' in local_var_params: - form_params.append(('additionalMetadata', local_var_params['additional_metadata'])) # noqa: E501 - if 'file' in local_var_params: - local_var_files['file'] = local_var_params['file'] # noqa: E501 - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['multipart/form-data']) # noqa: E501 - - # Authentication setting - auth_settings = ['petstore_auth'] # noqa: E501 - - return self.api_client.call_api( - '/pet/{petId}/uploadImage', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='ApiResponse', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def upload_file_with_required_file(self, pet_id, required_file, **kwargs): # noqa: E501 - """uploads an image (required) # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.upload_file_with_required_file(pet_id, required_file, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): ID of pet to update required_file (file): file to upload - - Keyword Args: - additional_metadata (str): Additional data to pass to server. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - ApiResponse: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.upload_file_with_required_file_with_http_info(pet_id, required_file, **kwargs) # noqa: E501 - else: - (data) = self.upload_file_with_required_file_with_http_info(pet_id, required_file, **kwargs) # noqa: E501 - return data - - def upload_file_with_required_file_with_http_info(self, pet_id, required_file, **kwargs): # noqa: E501 - """uploads an image (required) # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.upload_file_with_required_file_with_http_info(pet_id, required_file, async_req=True) - >>> result = thread.get() - - Args: - pet_id (int): ID of pet to update required_file (file): file to upload - Keyword Args: - additional_metadata (str): Additional data to pass to server. [optional] - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - Returns: - ApiResponse: - """ + self.__validate_inputs(kwargs) - local_var_params = locals() + params = self.__gather_params(kwargs) - all_params = ['pet_id', 'required_file', 'additional_metadata'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method upload_file_with_required_file" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'pet_id' is set - if ('pet_id' not in local_var_params or - local_var_params['pet_id'] is None): - raise ApiValueError("Missing the required parameter `pet_id` when calling `upload_file_with_required_file`") # noqa: E501 - # verify the required parameter 'required_file' is set - if ('required_file' not in local_var_params or - local_var_params['required_file'] is None): - raise ApiValueError("Missing the required parameter `required_file` when calling `upload_file_with_required_file`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'pet_id' in local_var_params: - path_params['petId'] = local_var_params['pet_id'] # noqa: E501 - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - if 'additional_metadata' in local_var_params: - form_params.append(('additionalMetadata', local_var_params['additional_metadata'])) # noqa: E501 - if 'required_file' in local_var_params: - local_var_files['requiredFile'] = local_var_params['required_file'] # noqa: E501 - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['multipart/form-data']) # noqa: E501 - - # Authentication setting - auth_settings = ['petstore_auth'] # noqa: E501 + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - '/fake/{petId}/uploadImageWithRequiredFile', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='ApiResponse', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs.get('async_req'), + _return_http_data_only=kwargs.get('_return_http_data_only'), + _preload_content=kwargs.get('_preload_content', True), + _request_timeout=kwargs.get('_request_timeout'), + _host=_host, + collection_formats=params['collection_format']) 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 c80423baf480..db3f4d2561df 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 @@ -18,10 +18,14 @@ import six from petstore_api.api_client import ApiClient -from petstore_api.exceptions import ( # noqa: F401 +from petstore_api.exceptions import ( ApiTypeError, ApiValueError ) +from petstore_api.model_utils import ( + check_allowed_values, + check_validations +) class StoreApi(object): @@ -36,456 +40,503 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def delete_order(self, order_id, **kwargs): # noqa: E501 - """Delete purchase order by ID # noqa: E501 - - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_order(order_id, async_req=True) - >>> result = thread.get() - - Args: - order_id (str): ID of the order that needs to be deleted - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + def __delete_order(self, order_id, **kwargs): # noqa: E501 + """Delete purchase order by ID # noqa: E501 + + For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_order(order_id, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str order_id: ID of the order that needs to be deleted (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.delete_order_with_http_info(order_id, **kwargs) # noqa: E501 - else: - (data) = self.delete_order_with_http_info(order_id, **kwargs) # noqa: E501 - return data - - def delete_order_with_http_info(self, order_id, **kwargs): # noqa: E501 - """Delete purchase order by ID # noqa: E501 - - For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_order_with_http_info(order_id, async_req=True) - >>> result = thread.get() - - Args: - order_id (str): ID of the order that needs to be deleted - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['order_id'] = order_id + return self.call_with_http_info(**kwargs) + + self.delete_order = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/store/order/{order_id}', + 'operation_id': 'delete_order', + 'http_method': 'DELETE', + 'servers': [], + }, + params_map={ + 'all': [ + 'order_id', + ], + 'required': [ + 'order_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'order_id': 'str', + }, + 'attribute_map': { + 'order_id': 'order_id', + }, + 'location_map': { + 'order_id': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__delete_order + ) + + def __get_inventory(self, **kwargs): # noqa: E501 + """Returns pet inventories by status # noqa: E501 + + Returns a map of status codes to quantities # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_inventory(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_order" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ApiValueError("Missing the required parameter `order_id` when calling `delete_order`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/store/order/{order_id}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_inventory(self, **kwargs): # noqa: E501 - """Returns pet inventories by status # noqa: E501 - - Returns a map of status codes to quantities # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_inventory(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: dict(str, int) + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + return self.call_with_http_info(**kwargs) + + self.get_inventory = Endpoint( + settings={ + 'response_type': 'dict(str, int)', + 'auth': [ + 'api_key' + ], + 'endpoint_path': '/store/inventory', + 'operation_id': 'get_inventory', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + }, + 'attribute_map': { + }, + 'location_map': { + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__get_inventory + ) + + def __get_order_by_id(self, order_id, **kwargs): # noqa: E501 + """Find purchase order by ID # noqa: E501 + + For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_order_by_id(order_id, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param int order_id: ID of pet that needs to be fetched (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - dict(str, int): - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_inventory_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.get_inventory_with_http_info(**kwargs) # noqa: E501 - return data - - def get_inventory_with_http_info(self, **kwargs): # noqa: E501 - """Returns pet inventories by status # noqa: E501 - - Returns a map of status codes to quantities # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_inventory_with_http_info(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: Order + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['order_id'] = order_id + return self.call_with_http_info(**kwargs) + + self.get_order_by_id = Endpoint( + settings={ + 'response_type': 'Order', + 'auth': [], + 'endpoint_path': '/store/order/{order_id}', + 'operation_id': 'get_order_by_id', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + 'order_id', + ], + 'required': [ + 'order_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + 'order_id', + ] + }, + root_map={ + 'validations': { + ('order_id',): { + + 'inclusive_maximum': 5, + 'inclusive_minimum': 1, + }, + }, + 'allowed_values': { + }, + 'openapi_types': { + 'order_id': 'int', + }, + 'attribute_map': { + 'order_id': 'order_id', + }, + 'location_map': { + 'order_id': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__get_order_by_id + ) + + def __place_order(self, body, **kwargs): # noqa: E501 + """Place an order for a pet # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.place_order(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param Order body: order placed for purchasing the pet (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - dict(str, int): - """ - - local_var_params = locals() - - all_params = [] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_inventory" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # Authentication setting - auth_settings = ['api_key'] # noqa: E501 - - return self.api_client.call_api( - '/store/inventory', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='dict(str, int)', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_order_by_id(self, order_id, **kwargs): # noqa: E501 - """Find purchase order by ID # noqa: E501 - - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_order_by_id(order_id, async_req=True) - >>> result = thread.get() - - Args: - order_id (int): ID of pet that needs to be fetched - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Order: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_order_by_id_with_http_info(order_id, **kwargs) # noqa: E501 - else: - (data) = self.get_order_by_id_with_http_info(order_id, **kwargs) # noqa: E501 - return data - - def get_order_by_id_with_http_info(self, order_id, **kwargs): # noqa: E501 - """Find purchase order by ID # noqa: E501 - - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_order_by_id_with_http_info(order_id, async_req=True) - >>> result = thread.get() + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: Order + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.place_order = Endpoint( + settings={ + 'response_type': 'Order', + 'auth': [], + 'endpoint_path': '/store/order', + 'operation_id': 'place_order', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'Order', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__place_order + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint Args: - order_id (int): ID of pet that needs to be fetched - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Order: + settings (dict): see below key value pairs + 'response_type' (str): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called """ - - local_var_params = locals() - - all_params = ['order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_order_by_id" % key + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only' + ]) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param], + self.validations ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ApiValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") # noqa: E501 - if 'order_id' in local_var_params and local_var_params['order_id'] > 5: # noqa: E501 - raise ApiValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value less than or equal to `5`") # noqa: E501 - if 'order_id' in local_var_params and local_var_params['order_id'] < 1: # noqa: E501 - raise ApiValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value greater than or equal to `1`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 - - query_params = [] - - header_params = {} - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/xml', 'application/json']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/store/order/{order_id}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='Order', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def place_order(self, body, **kwargs): # noqa: E501 - """Place an order for a pet # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.place_order(body, async_req=True) - >>> result = thread.get() - - Args: - body (Order): order placed for purchasing the pet - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param] + ) - Returns: - Order: + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == 'file'): + param_location = 'file' + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.place_order_with_http_info(body, **kwargs) # noqa: E501 + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + if kwargs.get('_host_index') and self.settings['servers']: + _host_index = kwargs.get('_host_index') + try: + _host = self.settings['servers'][_host_index] + except IndexError: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) else: - (data) = self.place_order_with_http_info(body, **kwargs) # noqa: E501 - return data - - def place_order_with_http_info(self, body, **kwargs): # noqa: E501 - """Place an order for a pet # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.place_order_with_http_info(body, async_req=True) - >>> result = thread.get() + try: + _host = self.settings['servers'][0] + except IndexError: + _host = None - Args: - body (Order): order placed for purchasing the pet - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - Order: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method place_order" % key + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + if key not in self.params_map['nullable'] and value is None: + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `place_order`") # noqa: E501 - - collection_formats = {} - - path_params = {} - query_params = [] + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - header_params = {} + self.__validate_inputs(kwargs) - form_params = [] - local_var_files = {} + params = self.__gather_params(kwargs) - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/xml', 'application/json']) # noqa: E501 + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - # Authentication setting - auth_settings = [] # noqa: E501 + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - '/store/order', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='Order', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs.get('async_req'), + _return_http_data_only=kwargs.get('_return_http_data_only'), + _preload_content=kwargs.get('_preload_content', True), + _request_timeout=kwargs.get('_request_timeout'), + _host=_host, + collection_formats=params['collection_format']) 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 c8de4c6c277c..7a3fb67c1268 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 @@ -18,10 +18,14 @@ import six from petstore_api.api_client import ApiClient -from petstore_api.exceptions import ( # noqa: F401 +from petstore_api.exceptions import ( ApiTypeError, ApiValueError ) +from petstore_api.model_utils import ( + check_allowed_values, + check_validations +) class UserApi(object): @@ -36,900 +40,808 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def create_user(self, body, **kwargs): # noqa: E501 - """Create user # noqa: E501 - - This can only be done by the logged in user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_user(body, async_req=True) - >>> result = thread.get() - - Args: - body (User): Created user object - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + def __create_user(self, body, **kwargs): # noqa: E501 + """Create user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_user(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param User body: Created user object (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_user_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.create_user_with_http_info(body, **kwargs) # noqa: E501 - return data - - def create_user_with_http_info(self, body, **kwargs): # noqa: E501 - """Create user # noqa: E501 - - This can only be done by the logged in user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_user_with_http_info(body, async_req=True) - >>> result = thread.get() - - Args: - body (User): Created user object - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_user" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `create_user`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/user', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_users_with_array_input(self, body, **kwargs): # noqa: E501 - """Creates list of users with given input array # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_users_with_array_input(body, async_req=True) - >>> result = thread.get() - - Args: - body (list[User]): List of user object - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.create_user = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user', + 'operation_id': 'create_user', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'User', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__create_user + ) + + def __create_users_with_array_input(self, body, **kwargs): # noqa: E501 + """Creates list of users with given input array # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_users_with_array_input(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param list[User] body: List of user object (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_users_with_array_input_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.create_users_with_array_input_with_http_info(body, **kwargs) # noqa: E501 - return data - - def create_users_with_array_input_with_http_info(self, body, **kwargs): # noqa: E501 - """Creates list of users with given input array # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_users_with_array_input_with_http_info(body, async_req=True) - >>> result = thread.get() - - Args: - body (list[User]): List of user object - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.create_users_with_array_input = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/createWithArray', + 'operation_id': 'create_users_with_array_input', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'list[User]', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__create_users_with_array_input + ) + + def __create_users_with_list_input(self, body, **kwargs): # noqa: E501 + """Creates list of users with given input array # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_users_with_list_input(body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param list[User] body: List of user object (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_users_with_array_input" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `create_users_with_array_input`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/user/createWithArray', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_users_with_list_input(self, body, **kwargs): # noqa: E501 - """Creates list of users with given input array # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_users_with_list_input(body, async_req=True) - >>> result = thread.get() - - Args: - body (list[User]): List of user object - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.create_users_with_list_input = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/createWithList', + 'operation_id': 'create_users_with_list_input', + 'http_method': 'POST', + 'servers': [], + }, + params_map={ + 'all': [ + 'body', + ], + 'required': [ + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'body': 'list[User]', + }, + 'attribute_map': { + }, + 'location_map': { + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__create_users_with_list_input + ) + + def __delete_user(self, username, **kwargs): # noqa: E501 + """Delete user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.delete_user(username, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str username: The name that needs to be deleted (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_users_with_list_input_with_http_info(body, **kwargs) # noqa: E501 - else: - (data) = self.create_users_with_list_input_with_http_info(body, **kwargs) # noqa: E501 - return data - - def create_users_with_list_input_with_http_info(self, body, **kwargs): # noqa: E501 - """Creates list of users with given input array # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_users_with_list_input_with_http_info(body, async_req=True) - >>> result = thread.get() - - Args: - body (list[User]): List of user object - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['username'] = username + return self.call_with_http_info(**kwargs) + + self.delete_user = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/{username}', + 'operation_id': 'delete_user', + 'http_method': 'DELETE', + 'servers': [], + }, + params_map={ + 'all': [ + 'username', + ], + 'required': [ + 'username', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'username': 'str', + }, + 'attribute_map': { + 'username': 'username', + }, + 'location_map': { + 'username': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__delete_user + ) + + def __get_user_by_name(self, username, **kwargs): # noqa: E501 + """Get user by user name # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_user_by_name(username, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str username: The name that needs to be fetched. Use user1 for testing. (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_users_with_list_input" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `create_users_with_list_input`") # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/user/createWithList', 'POST', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def delete_user(self, username, **kwargs): # noqa: E501 - """Delete user # noqa: E501 - - This can only be done by the logged in user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_user(username, async_req=True) - >>> result = thread.get() - - Args: - username (str): The name that needs to be deleted - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: User + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['username'] = username + return self.call_with_http_info(**kwargs) + + self.get_user_by_name = Endpoint( + settings={ + 'response_type': 'User', + 'auth': [], + 'endpoint_path': '/user/{username}', + 'operation_id': 'get_user_by_name', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + 'username', + ], + 'required': [ + 'username', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'username': 'str', + }, + 'attribute_map': { + 'username': 'username', + }, + 'location_map': { + 'username': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__get_user_by_name + ) + + def __login_user(self, username, password, **kwargs): # noqa: E501 + """Logs user into the system # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.login_user(username, password, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str username: The user name for login (required) + :param str password: The password for login in clear text (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.delete_user_with_http_info(username, **kwargs) # noqa: E501 - else: - (data) = self.delete_user_with_http_info(username, **kwargs) # noqa: E501 - return data - - def delete_user_with_http_info(self, username, **kwargs): # noqa: E501 - """Delete user # noqa: E501 - - This can only be done by the logged in user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_user_with_http_info(username, async_req=True) - >>> result = thread.get() - - Args: - username (str): The name that needs to be deleted - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: str + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['username'] = username + kwargs['password'] = password + return self.call_with_http_info(**kwargs) + + self.login_user = Endpoint( + settings={ + 'response_type': 'str', + 'auth': [], + 'endpoint_path': '/user/login', + 'operation_id': 'login_user', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + 'username', + 'password', + ], + 'required': [ + 'username', + 'password', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'username': 'str', + 'password': 'str', + }, + 'attribute_map': { + 'username': 'username', + 'password': 'password', + }, + 'location_map': { + 'username': 'query', + 'password': 'query', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/xml', + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client, + callable=__login_user + ) + + def __logout_user(self, **kwargs): # noqa: E501 + """Logs out current logged in user session # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.logout_user(async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['username'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method delete_user" % key - ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'username' is set - if ('username' not in local_var_params or - local_var_params['username'] is None): - raise ApiValueError("Missing the required parameter `username` when calling `delete_user`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'username' in local_var_params: - path_params['username'] = local_var_params['username'] # noqa: E501 - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/user/{username}', 'DELETE', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def get_user_by_name(self, username, **kwargs): # noqa: E501 - """Get user by user name # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_user_by_name(username, async_req=True) - >>> result = thread.get() - - Args: - username (str): The name that needs to be fetched. Use user1 for testing. - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + return self.call_with_http_info(**kwargs) + + self.logout_user = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/logout', + 'operation_id': 'logout_user', + 'http_method': 'GET', + 'servers': [], + }, + params_map={ + 'all': [ + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + }, + 'attribute_map': { + }, + 'location_map': { + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__logout_user + ) + + def __update_user(self, username, body, **kwargs): # noqa: E501 + """Updated user # noqa: E501 + + This can only be done by the logged in user. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.update_user(username, body, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param str username: name that need to be deleted (required) + :param User body: Updated user object (required) + :param _return_http_data_only: response data without head status + code and headers + :param _preload_content: if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - User: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_user_by_name_with_http_info(username, **kwargs) # noqa: E501 - else: - (data) = self.get_user_by_name_with_http_info(username, **kwargs) # noqa: E501 - return data - - def get_user_by_name_with_http_info(self, username, **kwargs): # noqa: E501 - """Get user by user name # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_user_by_name_with_http_info(username, async_req=True) - >>> result = thread.get() + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + :return: None + If the method is called asynchronously, returns the request + thread. + """ + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['username'] = username + kwargs['body'] = body + return self.call_with_http_info(**kwargs) + + self.update_user = Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/user/{username}', + 'operation_id': 'update_user', + 'http_method': 'PUT', + 'servers': [], + }, + params_map={ + 'all': [ + 'username', + 'body', + ], + 'required': [ + 'username', + 'body', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'username': 'str', + 'body': 'User', + }, + 'attribute_map': { + 'username': 'username', + }, + 'location_map': { + 'username': 'path', + 'body': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [], + 'content_type': [], + }, + api_client=api_client, + callable=__update_user + ) + + +class Endpoint(object): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): + """Creates an endpoint Args: - username (str): The name that needs to be fetched. Use user1 for testing. - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - User: + settings (dict): see below key value pairs + 'response_type' (str): response type + 'auth' (list): a list of auth type keys + 'endpoint_path' (str): the endpoint path + 'operation_id' (str): endpoint string identifier + 'http_method' (str): POST/PUT/PATCH/GET etc + 'servers' (list): list of str servers that this endpoint is at + params_map (dict): see below key value pairs + 'all' (list): list of str endpoint parameter names + 'required' (list): list of required parameter names + 'nullable' (list): list of nullable parameter names + 'enum' (list): list of parameters with enum values + 'validation' (list): list of parameters with validations + root_map + 'validations' (dict): the dict mapping endpoint parameter tuple + paths to their validation dictionaries + 'allowed_values' (dict): the dict mapping endpoint parameter + tuple paths to their allowed_values (enum) dictionaries + 'openapi_types' (dict): param_name to openapi type + 'attribute_map' (dict): param_name to camelCase name + 'location_map' (dict): param_name to 'body', 'file', 'form', + 'header', 'path', 'query' + collection_format_map (dict): param_name to `csv` etc. + headers_map (dict): see below key value pairs + 'accept' (list): list of Accept header strings + 'content_type' (list): list of Content-Type header strings + api_client (ApiClient) api client instance + callable (function): the function which is invoked when the + Endpoint is called """ - - local_var_params = locals() - - all_params = ['username'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_user_by_name" % key + self.settings = settings + self.params_map = params_map + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only' + ]) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] + self.headers_map = headers_map + self.api_client = api_client + self.callable = callable + + def __validate_inputs(self, kwargs): + for param in self.params_map['enum']: + if param in kwargs: + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param], + self.validations ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'username' is set - if ('username' not in local_var_params or - local_var_params['username'] is None): - raise ApiValueError("Missing the required parameter `username` when calling `get_user_by_name`") # noqa: E501 - - collection_formats = {} - - path_params = {} - if 'username' in local_var_params: - path_params['username'] = local_var_params['username'] # noqa: E501 - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/xml', 'application/json']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/user/{username}', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='User', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def login_user(self, username, password, **kwargs): # noqa: E501 - """Logs user into the system # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.login_user(username, password, async_req=True) - >>> result = thread.get() - - Args: - username (str): The user name for login password (str): The password for login in clear text - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - str: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.login_user_with_http_info(username, password, **kwargs) # noqa: E501 - else: - (data) = self.login_user_with_http_info(username, password, **kwargs) # noqa: E501 - return data - - def login_user_with_http_info(self, username, password, **kwargs): # noqa: E501 - """Logs user into the system # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.login_user_with_http_info(username, password, async_req=True) - >>> result = thread.get() - - Args: - username (str): The user name for login password (str): The password for login in clear text - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - str: - """ - - local_var_params = locals() - - all_params = ['username', 'password'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method login_user" % key + for param in self.params_map['validation']: + if param in kwargs: + check_validations( + self.validations, + (param,), + kwargs[param] ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'username' is set - if ('username' not in local_var_params or - local_var_params['username'] is None): - raise ApiValueError("Missing the required parameter `username` when calling `login_user`") # noqa: E501 - # verify the required parameter 'password' is set - if ('password' not in local_var_params or - local_var_params['password'] is None): - raise ApiValueError("Missing the required parameter `password` when calling `login_user`") # noqa: E501 - collection_formats = {} - - path_params = {} - - query_params = [] - if 'username' in local_var_params: - query_params.append(('username', local_var_params['username'])) # noqa: E501 - if 'password' in local_var_params: - query_params.append(('password', local_var_params['password'])) # noqa: E501 - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/xml', 'application/json']) # noqa: E501 - - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/user/login', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type='str', # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def logout_user(self, **kwargs): # noqa: E501 - """Logs out current logged in user session # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.logout_user(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: + def __gather_params(self, kwargs): + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } + + for param_name, param_value in six.iteritems(kwargs): + param_location = self.location_map.get(param_name) + if param_location: + if param_location == 'body': + params['body'] = param_value + continue + base_name = self.attribute_map[param_name] + if (param_location == 'form' and + self.openapi_types[param_name] == 'file'): + param_location = 'file' + elif param_location in {'form', 'query'}: + param_value_full = (base_name, param_value) + params[param_location].append(param_value_full) + if param_location not in {'form', 'query'}: + params[param_location][base_name] = param_value + collection_format = self.collection_format_map.get(param_name) + if collection_format: + params['collection_format'][base_name] = collection_format + + return params + + def __call__(self, *args, **kwargs): + """ This method is invoked when endpoints are called + Example: + pet_api = PetApi() + pet_api.add_pet # this is an instance of the class Endpoint + pet_api.add_pet() # this invokes pet_api.add_pet.__call__() + which then invokes the callable functions stored in that endpoint at + pet_api.add_pet.callable or self.callable in this class """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.logout_user_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.logout_user_with_http_info(**kwargs) # noqa: E501 - return data - - def logout_user_with_http_info(self, **kwargs): # noqa: E501 - """Logs out current logged in user session # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.logout_user_with_http_info(async_req=True) - >>> result = thread.get() - - - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = [] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method logout_user" % key + return self.callable(self, *args, **kwargs) + + def call_with_http_info(self, **kwargs): + + if kwargs.get('_host_index') and self.settings['servers']: + _host_index = kwargs.get('_host_index') + try: + _host = self.settings['servers'][_host_index] + except IndexError: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - - collection_formats = {} - - path_params = {} - - query_params = [] - - header_params = {} - - form_params = [] - local_var_files = {} - - body_params = None - # Authentication setting - auth_settings = [] # noqa: E501 - - return self.api_client.call_api( - '/user/logout', 'GET', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def update_user(self, username, body, **kwargs): # noqa: E501 - """Updated user # noqa: E501 - - This can only be done by the logged in user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_user(username, body, async_req=True) - >>> result = thread.get() - - Args: - username (str): name that need to be deleted body (User): Updated user object - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_user_with_http_info(username, body, **kwargs) # noqa: E501 else: - (data) = self.update_user_with_http_info(username, body, **kwargs) # noqa: E501 - return data - - def update_user_with_http_info(self, username, body, **kwargs): # noqa: E501 - """Updated user # noqa: E501 + try: + _host = self.settings['servers'][0] + except IndexError: + _host = None - This can only be done by the logged in user. # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_user_with_http_info(username, body, async_req=True) - >>> result = thread.get() - - Args: - username (str): name that need to be deleted body (User): Updated user object - - Keyword Args: - async_req (bool): execute request asynchronously - param _preload_content (bool): if False, the urllib3.HTTPResponse - object will be returned without reading/decoding response data. - Default is True. - param _request_timeout (float/tuple): timeout setting for this - request. If one number provided, it will be total request - timeout. It can also be a pair (tuple) of (connection, read) - timeouts. - - Returns: - None: - """ - - local_var_params = locals() - - all_params = ['username', 'body'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - - for key, val in six.iteritems(local_var_params['kwargs']): - if key not in all_params: + for key, value in six.iteritems(kwargs): + if key not in self.params_map['all']: raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method update_user" % key + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) + ) + if key not in self.params_map['nullable'] and value is None: + raise ApiValueError( + "Value may not be None for non-nullable parameter `%s`" + " when calling `%s`" % + (key, self.settings['operation_id']) ) - local_var_params[key] = val - del local_var_params['kwargs'] - # verify the required parameter 'username' is set - if ('username' not in local_var_params or - local_var_params['username'] is None): - raise ApiValueError("Missing the required parameter `username` when calling `update_user`") # noqa: E501 - # verify the required parameter 'body' is set - if ('body' not in local_var_params or - local_var_params['body'] is None): - raise ApiValueError("Missing the required parameter `body` when calling `update_user`") # noqa: E501 - - collection_formats = {} - path_params = {} - if 'username' in local_var_params: - path_params['username'] = local_var_params['username'] # noqa: E501 + for key in self.params_map['required']: + if key not in kwargs.keys(): + raise ApiValueError( + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) + ) - query_params = [] + self.__validate_inputs(kwargs) - header_params = {} + params = self.__gather_params(kwargs) - form_params = [] - local_var_files = {} + accept_headers_list = self.headers_map['accept'] + if accept_headers_list: + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - body_params = None - if 'body' in local_var_params: - body_params = local_var_params['body'] - # Authentication setting - auth_settings = [] # noqa: E501 + content_type_headers_list = self.headers_map['content_type'] + if content_type_headers_list: + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - '/user/{username}', 'PUT', - path_params, - query_params, - header_params, - body=body_params, - post_params=form_params, - files=local_var_files, - response_type=None, # noqa: E501 - auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs.get('async_req'), + _return_http_data_only=kwargs.get('_return_http_data_only'), + _preload_content=kwargs.get('_preload_content', True), + _request_timeout=kwargs.get('_request_timeout'), + _host=_host, + collection_formats=params['collection_format']) diff --git a/samples/client/petstore/python-experimental/petstore_api/api_client.py b/samples/client/petstore/python-experimental/petstore_api/api_client.py index df3a9815aa04..7afd6306dcfc 100644 --- a/samples/client/petstore/python-experimental/petstore_api/api_client.py +++ b/samples/client/petstore/python-experimental/petstore_api/api_client.py @@ -11,6 +11,7 @@ from __future__ import absolute_import import datetime +import inspect import json import mimetypes from multiprocessing.pool import ThreadPool @@ -22,9 +23,13 @@ import six from six.moves.urllib.parse import quote -from petstore_api.configuration import Configuration import petstore_api.models from petstore_api import rest +from petstore_api.configuration import Configuration +from petstore_api.model_utils import ( + ModelNormal, + ModelSimple +) from petstore_api.exceptions import ApiValueError @@ -216,7 +221,7 @@ def sanitize_for_serialization(self, obj): if isinstance(obj, dict): obj_dict = obj - else: + elif isinstance(obj, ModelNormal): # Convert model obj to dict except # attributes `openapi_types`, `attribute_map` # and attributes which value is not None. @@ -225,6 +230,8 @@ def sanitize_for_serialization(self, obj): obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) for attr, _ in six.iteritems(obj.openapi_types) if getattr(obj, attr) is not None} + elif isinstance(obj, ModelSimple): + return self.sanitize_for_serialization(obj.value) return {key: self.sanitize_for_serialization(val) for key, val in six.iteritems(obj_dict)} @@ -563,6 +570,8 @@ def __deserialize_primitive(self, data, klass): return six.text_type(data) except TypeError: return data + except ValueError as exc: + raise ApiValueError(str(exc)) def __deserialize_object(self, value): """Return an original value. @@ -614,25 +623,39 @@ def __deserialize_model(self, data, klass): """Deserializes list or dict to model. :param data: dict, list. - :param klass: class literal. + :param klass: class literal, ModelSimple or ModelNormal :return: model object. """ - if not klass.openapi_types and not hasattr(klass, - 'get_real_child_model'): - return data + if issubclass(klass, ModelSimple): + value = self.__deserialize(data, klass.openapi_types['value']) + return klass(value) - kwargs = {} + # code to handle ModelNormal + used_data = data + if not isinstance(data, (list, dict)): + used_data = [data] + keyword_args = {} + positional_args = [] if klass.openapi_types is not None: for attr, attr_type in six.iteritems(klass.openapi_types): if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): - value = data[klass.attribute_map[attr]] - kwargs[attr] = self.__deserialize(value, attr_type) - - instance = klass(**kwargs) - + klass.attribute_map[attr] in used_data): + value = used_data[klass.attribute_map[attr]] + keyword_args[attr] = self.__deserialize(value, attr_type) + end_index = None + argspec = inspect.getargspec(getattr(klass, '__init__')) + if argspec.defaults: + end_index = -len(argspec.defaults) + required_positional_args = argspec.args[1:end_index] + for index, req_positional_arg in enumerate(required_positional_args): + if keyword_args and req_positional_arg in keyword_args: + positional_args.append(keyword_args[req_positional_arg]) + del keyword_args[req_positional_arg] + elif (not keyword_args and index < len(used_data) and + isinstance(used_data, list)): + positional_args.append(used_data[index]) + instance = klass(*positional_args, **keyword_args) if hasattr(instance, 'get_real_child_model'): klass_name = instance.get_real_child_model(data) if klass_name: diff --git a/samples/client/petstore/python-experimental/petstore_api/configuration.py b/samples/client/petstore/python-experimental/petstore_api/configuration.py index fa0c3f4d320c..459ff6a3ca25 100644 --- a/samples/client/petstore/python-experimental/petstore_api/configuration.py +++ b/samples/client/petstore/python-experimental/petstore_api/configuration.py @@ -67,6 +67,9 @@ def __init__(self, host="http://petstore.swagger.io:80/v2", self.api_key_prefix = api_key_prefix """dict to store API prefix (e.g. Bearer) """ + self.refresh_api_key_hook = None + """function hook to refresh API key if expired + """ self.username = username """Username for HTTP basic authentication """ @@ -227,11 +230,15 @@ def get_api_key_with_prefix(self, identifier): :param identifier: The identifier of apiKey. :return: The token for api key authentication. """ - if (self.api_key.get(identifier) and - self.api_key_prefix.get(identifier)): - return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501 - elif self.api_key.get(identifier): - return self.api_key[identifier] + if self.refresh_api_key_hook is not None: + self.refresh_api_key_hook(self) + key = self.api_key.get(identifier) + if key: + prefix = self.api_key_prefix.get(identifier) + if prefix: + return "%s %s" % (prefix, key) + else: + return key def get_basic_auth_token(self): """Gets HTTP basic authentication header (string). diff --git a/samples/client/petstore/python-experimental/petstore_api/model_utils.py b/samples/client/petstore/python-experimental/petstore_api/model_utils.py new file mode 100644 index 000000000000..57ca211a0f7c --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/model_utils.py @@ -0,0 +1,183 @@ +# 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 +""" + +import re + +from petstore_api.exceptions import ApiValueError + + +def check_allowed_values(allowed_values, input_variable_path, input_values, + validations): + """Raises an exception if the input_values are not allowed + + Args: + allowed_values (dict): the allowed_values dict + input_variable_path (tuple): the path to the input variable + input_values (list/str/int/float/date/datetime): the values that we + are checking to see if they are in allowed_values + validations (dict): the validations dict + """ + min_collection_length = ( + validations.get(input_variable_path, {}).get('min_length') or + validations.get(input_variable_path, {}).get('min_items', 0)) + these_allowed_values = list(allowed_values[input_variable_path].values()) + if (isinstance(input_values, list) + and len(input_values) > min_collection_length + and not set(input_values).issubset( + set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values) - set(these_allowed_values))), + raise ApiValueError( + "Invalid values for `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (isinstance(input_values, dict) + and len(input_values) > min_collection_length + and not set( + input_values.keys()).issubset(set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values.keys()) - set(these_allowed_values))) + raise ApiValueError( + "Invalid keys in `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) + ) + elif (not isinstance(input_values, (list, dict)) + and input_values not in these_allowed_values): + raise ApiValueError( + "Invalid value for `%s` (%s), must be one of %s" % + ( + input_variable_path[0], + input_values, + these_allowed_values + ) + ) + + +def check_validations(validations, input_variable_path, input_values): + """Raises an exception if the input_values are invalid + + Args: + validations (dict): the validation dictionary + input_variable_path (tuple): the path to the input variable + input_values (list/str/int/float/date/datetime): the values that we + are checking + """ + current_validations = validations[input_variable_path] + if ('max_length' in current_validations and + len(input_values) > current_validations['max_length']): + raise ApiValueError( + "Invalid value for `%s`, length must be less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['max_length'] + ) + ) + + if ('min_length' in current_validations and + len(input_values) < current_validations['min_length']): + raise ApiValueError( + "Invalid value for `%s`, length must be greater than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['min_length'] + ) + ) + + if ('max_items' in current_validations and + len(input_values) > current_validations['max_items']): + raise ApiValueError( + "Invalid value for `%s`, number of items must be less than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['max_items'] + ) + ) + + if ('min_items' in current_validations and + len(input_values) < current_validations['min_items']): + raise ValueError( + "Invalid value for `%s`, number of items must be greater than or " + "equal to `%s`" % ( + input_variable_path[0], + current_validations['min_items'] + ) + ) + + if ('exclusive_maximum' in current_validations and + input_values >= current_validations['exclusive_maximum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value less than `%s`" % ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if ('inclusive_maximum' in current_validations and + input_values > current_validations['inclusive_maximum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value less than or equal to " + "`%s`" % ( + input_variable_path[0], + current_validations['inclusive_maximum'] + ) + ) + + if ('exclusive_minimum' in current_validations and + input_values <= current_validations['exclusive_minimum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value greater than `%s`" % + ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) + ) + + if ('inclusive_minimum' in current_validations and + input_values < current_validations['inclusive_minimum']): + raise ApiValueError( + "Invalid value for `%s`, must be a value greater than or equal " + "to `%s`" % ( + input_variable_path[0], + current_validations['inclusive_minimum'] + ) + ) + flags = current_validations.get('regex', {}).get('flags', 0) + if ('regex' in current_validations and + not re.search(current_validations['regex']['pattern'], + input_values, flags=flags)): + raise ApiValueError( + r"Invalid value for `%s`, must be a follow pattern or equal to " + r"`%s` with flags=`%s`" % ( + input_variable_path[0], + current_validations['regex']['pattern'], + flags + ) + ) + + +class ModelSimple(object): + # the parent class of models whose type != object in their swagger/openapi + # spec + pass + + +class ModelNormal(object): + # the parent class of models whose type == object in their swagger/openapi + # spec + pass 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 96fd17471f19..1f2bb89aa33d 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/__init__.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/__init__.py @@ -52,9 +52,11 @@ 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 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 ec5fa2a9a28e..25e165ed7b57 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class AdditionalPropertiesAnyType(object): + +class AdditionalPropertiesAnyType(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', + + allowed_values = { } attribute_map = { - 'name': 'name', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, name=None): # noqa: E501 - """AdditionalPropertiesAnyType - a model defined in OpenAPI - + openapi_types = { + 'name': 'str' + } + validations = { + } - Keyword Args: - name (str): [optional] # noqa: E501 - """ + def __init__(self, name=None): # noqa: E501 + """AdditionalPropertiesAnyType - a model defined in OpenAPI""" # noqa: E501 self._name = None self.discriminator = None if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) @property def name(self): @@ -64,9 +84,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this AdditionalPropertiesAnyType. @@ -75,7 +93,8 @@ def name( """ self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 e04ae6f4c04c..5de262b864d9 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class AdditionalPropertiesArray(object): + +class AdditionalPropertiesArray(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', + + allowed_values = { } attribute_map = { - 'name': 'name', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, name=None): # noqa: E501 - """AdditionalPropertiesArray - a model defined in OpenAPI - + openapi_types = { + 'name': 'str' + } + validations = { + } - Keyword Args: - name (str): [optional] # noqa: E501 - """ + def __init__(self, name=None): # noqa: E501 + """AdditionalPropertiesArray - a model defined in OpenAPI""" # noqa: E501 self._name = None self.discriminator = None if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) @property def name(self): @@ -64,9 +84,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this AdditionalPropertiesArray. @@ -75,7 +93,8 @@ def name( """ self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 f5e7dc23d238..70675c7d3aee 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class AdditionalPropertiesBoolean(object): + +class AdditionalPropertiesBoolean(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', + + allowed_values = { } attribute_map = { - 'name': 'name', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, name=None): # noqa: E501 - """AdditionalPropertiesBoolean - a model defined in OpenAPI - + openapi_types = { + 'name': 'str' + } + validations = { + } - Keyword Args: - name (str): [optional] # noqa: E501 - """ + def __init__(self, name=None): # noqa: E501 + """AdditionalPropertiesBoolean - a model defined in OpenAPI""" # noqa: E501 self._name = None self.discriminator = None if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) @property def name(self): @@ -64,9 +84,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this AdditionalPropertiesBoolean. @@ -75,7 +93,8 @@ def name( """ self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 d5082c17ce48..efa4d6a09d19 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,38 +10,45 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class AdditionalPropertiesClass(object): + +class AdditionalPropertiesClass(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'map_string': 'dict(str, str)', - 'map_number': 'dict(str, float)', - 'map_integer': 'dict(str, int)', - 'map_boolean': 'dict(str, bool)', - 'map_array_integer': 'dict(str, list[int])', - 'map_array_anytype': 'dict(str, list[object])', - 'map_map_string': 'dict(str, dict(str, str))', - 'map_map_anytype': 'dict(str, dict(str, object))', - 'anytype_1': 'object', - 'anytype_2': 'object', - 'anytype_3': 'object', + + allowed_values = { } attribute_map = { @@ -55,27 +62,28 @@ class AdditionalPropertiesClass(object): '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 + 'anytype_3': 'anytype_3' # noqa: E501 + } + + openapi_types = { + 'map_string': 'dict(str, str)', + 'map_number': 'dict(str, float)', + 'map_integer': 'dict(str, int)', + 'map_boolean': 'dict(str, bool)', + 'map_array_integer': 'dict(str, list[int])', + 'map_array_anytype': 'dict(str, list[object])', + 'map_map_string': 'dict(str, dict(str, str))', + 'map_map_anytype': 'dict(str, dict(str, object))', + 'anytype_1': 'object', + 'anytype_2': 'object', + 'anytype_3': 'object' + } + + validations = { } def __init__(self, map_string=None, map_number=None, map_integer=None, map_boolean=None, map_array_integer=None, map_array_anytype=None, map_map_string=None, map_map_anytype=None, anytype_1=None, anytype_2=None, anytype_3=None): # noqa: E501 - """AdditionalPropertiesClass - a model defined in OpenAPI - - - - Keyword Args: - map_string (dict(str, str)): [optional] # noqa: E501 - map_number (dict(str, float)): [optional] # noqa: E501 - map_integer (dict(str, int)): [optional] # noqa: E501 - map_boolean (dict(str, bool)): [optional] # noqa: E501 - map_array_integer (dict(str, list[int])): [optional] # noqa: E501 - map_array_anytype (dict(str, list[object])): [optional] # noqa: E501 - map_map_string (dict(str, dict(str, str))): [optional] # noqa: E501 - map_map_anytype (dict(str, dict(str, object))): [optional] # noqa: E501 - anytype_1 (object): [optional] # noqa: E501 - anytype_2 (object): [optional] # noqa: E501 - anytype_3 (object): [optional] # noqa: E501 - """ + """AdditionalPropertiesClass - a model defined in OpenAPI""" # noqa: E501 self._map_string = None self._map_number = None @@ -91,27 +99,49 @@ def __init__(self, map_string=None, map_number=None, map_integer=None, map_boole self.discriminator = None if map_string is not None: - self.map_string = map_string # noqa: E501 + self.map_string = ( + map_string + ) if map_number is not None: - self.map_number = map_number # noqa: E501 + self.map_number = ( + map_number + ) if map_integer is not None: - self.map_integer = map_integer # noqa: E501 + self.map_integer = ( + map_integer + ) if map_boolean is not None: - self.map_boolean = map_boolean # noqa: E501 + self.map_boolean = ( + map_boolean + ) if map_array_integer is not None: - self.map_array_integer = map_array_integer # noqa: E501 + self.map_array_integer = ( + map_array_integer + ) if map_array_anytype is not None: - self.map_array_anytype = map_array_anytype # noqa: E501 + self.map_array_anytype = ( + map_array_anytype + ) if map_map_string is not None: - self.map_map_string = map_map_string # noqa: E501 + self.map_map_string = ( + map_map_string + ) if map_map_anytype is not None: - self.map_map_anytype = map_map_anytype # noqa: E501 + self.map_map_anytype = ( + map_map_anytype + ) if anytype_1 is not None: - self.anytype_1 = anytype_1 # noqa: E501 + self.anytype_1 = ( + anytype_1 + ) if anytype_2 is not None: - self.anytype_2 = anytype_2 # noqa: E501 + self.anytype_2 = ( + anytype_2 + ) if anytype_3 is not None: - self.anytype_3 = anytype_3 # noqa: E501 + self.anytype_3 = ( + anytype_3 + ) @property def map_string(self): @@ -124,9 +154,7 @@ def map_string(self): return self._map_string @map_string.setter - def map_string( - self, - map_string): + def map_string(self, map_string): # noqa: E501 """Sets the map_string of this AdditionalPropertiesClass. @@ -135,7 +163,8 @@ def map_string( """ self._map_string = ( - map_string) + map_string + ) @property def map_number(self): @@ -148,9 +177,7 @@ def map_number(self): return self._map_number @map_number.setter - def map_number( - self, - map_number): + def map_number(self, map_number): # noqa: E501 """Sets the map_number of this AdditionalPropertiesClass. @@ -159,7 +186,8 @@ def map_number( """ self._map_number = ( - map_number) + map_number + ) @property def map_integer(self): @@ -172,9 +200,7 @@ def map_integer(self): return self._map_integer @map_integer.setter - def map_integer( - self, - map_integer): + def map_integer(self, map_integer): # noqa: E501 """Sets the map_integer of this AdditionalPropertiesClass. @@ -183,7 +209,8 @@ def map_integer( """ self._map_integer = ( - map_integer) + map_integer + ) @property def map_boolean(self): @@ -196,9 +223,7 @@ def map_boolean(self): return self._map_boolean @map_boolean.setter - def map_boolean( - self, - map_boolean): + def map_boolean(self, map_boolean): # noqa: E501 """Sets the map_boolean of this AdditionalPropertiesClass. @@ -207,7 +232,8 @@ def map_boolean( """ self._map_boolean = ( - map_boolean) + map_boolean + ) @property def map_array_integer(self): @@ -220,9 +246,7 @@ def map_array_integer(self): return self._map_array_integer @map_array_integer.setter - def map_array_integer( - self, - map_array_integer): + def map_array_integer(self, map_array_integer): # noqa: E501 """Sets the map_array_integer of this AdditionalPropertiesClass. @@ -231,7 +255,8 @@ def map_array_integer( """ self._map_array_integer = ( - map_array_integer) + map_array_integer + ) @property def map_array_anytype(self): @@ -244,9 +269,7 @@ def map_array_anytype(self): return self._map_array_anytype @map_array_anytype.setter - def map_array_anytype( - self, - map_array_anytype): + def map_array_anytype(self, map_array_anytype): # noqa: E501 """Sets the map_array_anytype of this AdditionalPropertiesClass. @@ -255,7 +278,8 @@ def map_array_anytype( """ self._map_array_anytype = ( - map_array_anytype) + map_array_anytype + ) @property def map_map_string(self): @@ -268,9 +292,7 @@ def map_map_string(self): return self._map_map_string @map_map_string.setter - def map_map_string( - self, - map_map_string): + def map_map_string(self, map_map_string): # noqa: E501 """Sets the map_map_string of this AdditionalPropertiesClass. @@ -279,7 +301,8 @@ def map_map_string( """ self._map_map_string = ( - map_map_string) + map_map_string + ) @property def map_map_anytype(self): @@ -292,9 +315,7 @@ def map_map_anytype(self): return self._map_map_anytype @map_map_anytype.setter - def map_map_anytype( - self, - map_map_anytype): + def map_map_anytype(self, map_map_anytype): # noqa: E501 """Sets the map_map_anytype of this AdditionalPropertiesClass. @@ -303,7 +324,8 @@ def map_map_anytype( """ self._map_map_anytype = ( - map_map_anytype) + map_map_anytype + ) @property def anytype_1(self): @@ -316,9 +338,7 @@ def anytype_1(self): return self._anytype_1 @anytype_1.setter - def anytype_1( - self, - anytype_1): + def anytype_1(self, anytype_1): # noqa: E501 """Sets the anytype_1 of this AdditionalPropertiesClass. @@ -327,7 +347,8 @@ def anytype_1( """ self._anytype_1 = ( - anytype_1) + anytype_1 + ) @property def anytype_2(self): @@ -340,9 +361,7 @@ def anytype_2(self): return self._anytype_2 @anytype_2.setter - def anytype_2( - self, - anytype_2): + def anytype_2(self, anytype_2): # noqa: E501 """Sets the anytype_2 of this AdditionalPropertiesClass. @@ -351,7 +370,8 @@ def anytype_2( """ self._anytype_2 = ( - anytype_2) + anytype_2 + ) @property def anytype_3(self): @@ -364,9 +384,7 @@ def anytype_3(self): return self._anytype_3 @anytype_3.setter - def anytype_3( - self, - anytype_3): + def anytype_3(self, anytype_3): # noqa: E501 """Sets the anytype_3 of this AdditionalPropertiesClass. @@ -375,7 +393,8 @@ def anytype_3( """ self._anytype_3 = ( - anytype_3) + anytype_3 + ) def to_dict(self): """Returns the model properties as a dict""" 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 9b3715f8f26c..55ba58e1e20a 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class AdditionalPropertiesInteger(object): + +class AdditionalPropertiesInteger(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', + + allowed_values = { } attribute_map = { - 'name': 'name', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, name=None): # noqa: E501 - """AdditionalPropertiesInteger - a model defined in OpenAPI - + openapi_types = { + 'name': 'str' + } + validations = { + } - Keyword Args: - name (str): [optional] # noqa: E501 - """ + def __init__(self, name=None): # noqa: E501 + """AdditionalPropertiesInteger - a model defined in OpenAPI""" # noqa: E501 self._name = None self.discriminator = None if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) @property def name(self): @@ -64,9 +84,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this AdditionalPropertiesInteger. @@ -75,7 +93,8 @@ def name( """ self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 1d4e26e87339..32a59a5bc522 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class AdditionalPropertiesNumber(object): + +class AdditionalPropertiesNumber(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', + + allowed_values = { } attribute_map = { - 'name': 'name', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, name=None): # noqa: E501 - """AdditionalPropertiesNumber - a model defined in OpenAPI - + openapi_types = { + 'name': 'str' + } + validations = { + } - Keyword Args: - name (str): [optional] # noqa: E501 - """ + def __init__(self, name=None): # noqa: E501 + """AdditionalPropertiesNumber - a model defined in OpenAPI""" # noqa: E501 self._name = None self.discriminator = None if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) @property def name(self): @@ -64,9 +84,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this AdditionalPropertiesNumber. @@ -75,7 +93,8 @@ def name( """ self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 96b92ade0188..362023c8460e 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class AdditionalPropertiesObject(object): + +class AdditionalPropertiesObject(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', + + allowed_values = { } attribute_map = { - 'name': 'name', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, name=None): # noqa: E501 - """AdditionalPropertiesObject - a model defined in OpenAPI - + openapi_types = { + 'name': 'str' + } + validations = { + } - Keyword Args: - name (str): [optional] # noqa: E501 - """ + def __init__(self, name=None): # noqa: E501 + """AdditionalPropertiesObject - a model defined in OpenAPI""" # noqa: E501 self._name = None self.discriminator = None if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) @property def name(self): @@ -64,9 +84,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this AdditionalPropertiesObject. @@ -75,7 +93,8 @@ def name( """ self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 a61c1fb70e85..e01ff7028f23 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class AdditionalPropertiesString(object): + +class AdditionalPropertiesString(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', + + allowed_values = { } attribute_map = { - 'name': 'name', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, name=None): # noqa: E501 - """AdditionalPropertiesString - a model defined in OpenAPI - + openapi_types = { + 'name': 'str' + } + validations = { + } - Keyword Args: - name (str): [optional] # noqa: E501 - """ + def __init__(self, name=None): # noqa: E501 + """AdditionalPropertiesString - a model defined in OpenAPI""" # noqa: E501 self._name = None self.discriminator = None if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) @property def name(self): @@ -64,9 +84,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this AdditionalPropertiesString. @@ -75,7 +93,8 @@ def name( """ self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 d5c0162b088a..a2ce846a64d7 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,50 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Animal(object): + +class Animal(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'class_name': 'str', - 'color': 'str', + + allowed_values = { } attribute_map = { 'class_name': 'className', # noqa: E501 - 'color': 'color', # noqa: E501 + 'color': 'color' # noqa: E501 } discriminator_value_class_map = { @@ -45,15 +61,16 @@ class Animal(object): 'Cat': 'Cat' } - def __init__(self, class_name, color=None): # noqa: E501 - """Animal - a model defined in OpenAPI + openapi_types = { + 'class_name': 'str', + 'color': 'str' + } - Args: - class_name (str): + validations = { + } - Keyword Args: # noqa: E501 - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 - """ + def __init__(self, class_name=None, color='red'): # noqa: E501 + """Animal - a model defined in OpenAPI""" # noqa: E501 self._class_name = None self._color = None @@ -61,7 +78,9 @@ def __init__(self, class_name, color=None): # noqa: E501 self.class_name = class_name if color is not None: - self.color = color # noqa: E501 + self.color = ( + color + ) @property def class_name(self): @@ -74,9 +93,7 @@ def class_name(self): return self._class_name @class_name.setter - def class_name( - self, - class_name): + def class_name(self, class_name): # noqa: E501 """Sets the class_name of this Animal. @@ -84,10 +101,11 @@ def class_name( :type: str """ if class_name is None: - raise ValueError("Invalid value for `class_name`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `class_name`, must not be `None`") # noqa: E501 self._class_name = ( - class_name) + class_name + ) @property def color(self): @@ -100,9 +118,7 @@ def color(self): return self._color @color.setter - def color( - self, - color): + def color(self, color): # noqa: E501 """Sets the color of this Animal. @@ -111,7 +127,8 @@ def color( """ self._color = ( - color) + color + ) def get_real_child_model(self, data): """Returns the real base class specified by the discriminator""" 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 431819627147..4f9f3a12bd47 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,48 +10,64 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class ApiResponse(object): + +class ApiResponse(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'code': 'int', - 'type': 'str', - 'message': 'str', + + allowed_values = { } attribute_map = { 'code': 'code', # noqa: E501 'type': 'type', # noqa: E501 - 'message': 'message', # noqa: E501 + 'message': 'message' # noqa: E501 } - def __init__(self, code=None, type=None, message=None): # noqa: E501 - """ApiResponse - a model defined in OpenAPI - + openapi_types = { + 'code': 'int', + 'type': 'str', + 'message': 'str' + } + validations = { + } - Keyword Args: - code (int): [optional] # noqa: E501 - type (str): [optional] # noqa: E501 - message (str): [optional] # noqa: E501 - """ + def __init__(self, code=None, type=None, message=None): # noqa: E501 + """ApiResponse - a model defined in OpenAPI""" # noqa: E501 self._code = None self._type = None @@ -59,11 +75,17 @@ def __init__(self, code=None, type=None, message=None): # noqa: E501 self.discriminator = None if code is not None: - self.code = code # noqa: E501 + self.code = ( + code + ) if type is not None: - self.type = type # noqa: E501 + self.type = ( + type + ) if message is not None: - self.message = message # noqa: E501 + self.message = ( + message + ) @property def code(self): @@ -76,9 +98,7 @@ def code(self): return self._code @code.setter - def code( - self, - code): + def code(self, code): # noqa: E501 """Sets the code of this ApiResponse. @@ -87,7 +107,8 @@ def code( """ self._code = ( - code) + code + ) @property def type(self): @@ -100,9 +121,7 @@ def type(self): return self._type @type.setter - def type( - self, - type): + def type(self, type): # noqa: E501 """Sets the type of this ApiResponse. @@ -111,7 +130,8 @@ def type( """ self._type = ( - type) + type + ) @property def message(self): @@ -124,9 +144,7 @@ def message(self): return self._message @message.setter - def message( - self, - message): + def message(self, message): # noqa: E501 """Sets the message of this ApiResponse. @@ -135,7 +153,8 @@ def message( """ self._message = ( - message) + message + ) def to_dict(self): """Returns the model properties as a dict""" 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 d49c620abc1e..2beb87728306 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class ArrayOfArrayOfNumberOnly(object): + +class ArrayOfArrayOfNumberOnly(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'array_array_number': 'list[list[float]]', + + allowed_values = { } attribute_map = { - 'array_array_number': 'ArrayArrayNumber', # noqa: E501 + 'array_array_number': 'ArrayArrayNumber' # noqa: E501 } - def __init__(self, array_array_number=None): # noqa: E501 - """ArrayOfArrayOfNumberOnly - a model defined in OpenAPI - + openapi_types = { + 'array_array_number': 'list[list[float]]' + } + validations = { + } - Keyword Args: - array_array_number (list[list[float]]): [optional] # noqa: E501 - """ + def __init__(self, array_array_number=None): # noqa: E501 + """ArrayOfArrayOfNumberOnly - a model defined in OpenAPI""" # noqa: E501 self._array_array_number = None self.discriminator = None if array_array_number is not None: - self.array_array_number = array_array_number # noqa: E501 + self.array_array_number = ( + array_array_number + ) @property def array_array_number(self): @@ -64,9 +84,7 @@ def array_array_number(self): return self._array_array_number @array_array_number.setter - def array_array_number( - self, - array_array_number): + def array_array_number(self, array_array_number): # noqa: E501 """Sets the array_array_number of this ArrayOfArrayOfNumberOnly. @@ -75,7 +93,8 @@ def array_array_number( """ self._array_array_number = ( - array_array_number) + array_array_number + ) def to_dict(self): """Returns the model properties as a dict""" 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 f87d00b168ab..7c67bcf59d77 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class ArrayOfNumberOnly(object): + +class ArrayOfNumberOnly(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'array_number': 'list[float]', + + allowed_values = { } attribute_map = { - 'array_number': 'ArrayNumber', # noqa: E501 + 'array_number': 'ArrayNumber' # noqa: E501 } - def __init__(self, array_number=None): # noqa: E501 - """ArrayOfNumberOnly - a model defined in OpenAPI - + openapi_types = { + 'array_number': 'list[float]' + } + validations = { + } - Keyword Args: - array_number (list[float]): [optional] # noqa: E501 - """ + def __init__(self, array_number=None): # noqa: E501 + """ArrayOfNumberOnly - a model defined in OpenAPI""" # noqa: E501 self._array_number = None self.discriminator = None if array_number is not None: - self.array_number = array_number # noqa: E501 + self.array_number = ( + array_number + ) @property def array_number(self): @@ -64,9 +84,7 @@ def array_number(self): return self._array_number @array_number.setter - def array_number( - self, - array_number): + def array_number(self, array_number): # noqa: E501 """Sets the array_number of this ArrayOfNumberOnly. @@ -75,7 +93,8 @@ def array_number( """ self._array_number = ( - array_number) + array_number + ) def to_dict(self): """Returns the model properties as a dict""" 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 5098375a2f06..adcb8690dea0 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,48 +10,64 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class ArrayTest(object): + +class ArrayTest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'array_of_string': 'list[str]', - 'array_array_of_integer': 'list[list[int]]', - 'array_array_of_model': 'list[list[ReadOnlyFirst]]', + + 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 + 'array_array_of_model': 'array_array_of_model' # noqa: E501 } - def __init__(self, array_of_string=None, array_array_of_integer=None, array_array_of_model=None): # noqa: E501 - """ArrayTest - a model defined in OpenAPI - + openapi_types = { + 'array_of_string': 'list[str]', + 'array_array_of_integer': 'list[list[int]]', + 'array_array_of_model': 'list[list[ReadOnlyFirst]]' + } + validations = { + } - Keyword Args: - array_of_string (list[str]): [optional] # noqa: E501 - array_array_of_integer (list[list[int]]): [optional] # noqa: E501 - array_array_of_model (list[list[ReadOnlyFirst]]): [optional] # noqa: E501 - """ + def __init__(self, array_of_string=None, array_array_of_integer=None, array_array_of_model=None): # noqa: E501 + """ArrayTest - a model defined in OpenAPI""" # noqa: E501 self._array_of_string = None self._array_array_of_integer = None @@ -59,11 +75,17 @@ def __init__(self, array_of_string=None, array_array_of_integer=None, array_arra self.discriminator = None if array_of_string is not None: - self.array_of_string = array_of_string # noqa: E501 + self.array_of_string = ( + array_of_string + ) if array_array_of_integer is not None: - self.array_array_of_integer = array_array_of_integer # noqa: E501 + self.array_array_of_integer = ( + array_array_of_integer + ) if array_array_of_model is not None: - self.array_array_of_model = array_array_of_model # noqa: E501 + self.array_array_of_model = ( + array_array_of_model + ) @property def array_of_string(self): @@ -76,9 +98,7 @@ def array_of_string(self): return self._array_of_string @array_of_string.setter - def array_of_string( - self, - array_of_string): + def array_of_string(self, array_of_string): # noqa: E501 """Sets the array_of_string of this ArrayTest. @@ -87,7 +107,8 @@ def array_of_string( """ self._array_of_string = ( - array_of_string) + array_of_string + ) @property def array_array_of_integer(self): @@ -100,9 +121,7 @@ def array_array_of_integer(self): return self._array_array_of_integer @array_array_of_integer.setter - def array_array_of_integer( - self, - array_array_of_integer): + def array_array_of_integer(self, array_array_of_integer): # noqa: E501 """Sets the array_array_of_integer of this ArrayTest. @@ -111,7 +130,8 @@ def array_array_of_integer( """ self._array_array_of_integer = ( - array_array_of_integer) + array_array_of_integer + ) @property def array_array_of_model(self): @@ -124,9 +144,7 @@ def array_array_of_model(self): return self._array_array_of_model @array_array_of_model.setter - def array_array_of_model( - self, - array_array_of_model): + def array_array_of_model(self, array_array_of_model): # noqa: E501 """Sets the array_array_of_model of this ArrayTest. @@ -135,7 +153,8 @@ def array_array_of_model( """ self._array_array_of_model = ( - array_array_of_model) + array_array_of_model + ) def to_dict(self): """Returns the model properties as a dict""" 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 e94eca3e4021..5eeafb5ac7bc 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/capitalization.py @@ -10,33 +10,45 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Capitalization(object): + +class Capitalization(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'small_camel': 'str', - 'capital_camel': 'str', - 'small_snake': 'str', - 'capital_snake': 'str', - 'sca_eth_flow_points': 'str', - 'att_name': 'str', + + allowed_values = { } attribute_map = { @@ -45,22 +57,23 @@ class Capitalization(object): '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 + 'att_name': 'ATT_NAME' # noqa: E501 } - def __init__(self, small_camel=None, capital_camel=None, small_snake=None, capital_snake=None, sca_eth_flow_points=None, att_name=None): # noqa: E501 - """Capitalization - a model defined in OpenAPI - + openapi_types = { + 'small_camel': 'str', + 'capital_camel': 'str', + 'small_snake': 'str', + 'capital_snake': 'str', + 'sca_eth_flow_points': 'str', + 'att_name': 'str' + } + validations = { + } - Keyword Args: - small_camel (str): [optional] # noqa: E501 - capital_camel (str): [optional] # noqa: E501 - small_snake (str): [optional] # noqa: E501 - capital_snake (str): [optional] # noqa: E501 - sca_eth_flow_points (str): [optional] # noqa: E501 - att_name (str): Name of the pet . [optional] # noqa: E501 - """ + def __init__(self, small_camel=None, capital_camel=None, small_snake=None, capital_snake=None, sca_eth_flow_points=None, att_name=None): # noqa: E501 + """Capitalization - a model defined in OpenAPI""" # noqa: E501 self._small_camel = None self._capital_camel = None @@ -71,17 +84,29 @@ def __init__(self, small_camel=None, capital_camel=None, small_snake=None, capit self.discriminator = None if small_camel is not None: - self.small_camel = small_camel # noqa: E501 + self.small_camel = ( + small_camel + ) if capital_camel is not None: - self.capital_camel = capital_camel # noqa: E501 + self.capital_camel = ( + capital_camel + ) if small_snake is not None: - self.small_snake = small_snake # noqa: E501 + self.small_snake = ( + small_snake + ) if capital_snake is not None: - self.capital_snake = capital_snake # noqa: E501 + self.capital_snake = ( + capital_snake + ) if sca_eth_flow_points is not None: - self.sca_eth_flow_points = sca_eth_flow_points # noqa: E501 + self.sca_eth_flow_points = ( + sca_eth_flow_points + ) if att_name is not None: - self.att_name = att_name # noqa: E501 + self.att_name = ( + att_name + ) @property def small_camel(self): @@ -94,9 +119,7 @@ def small_camel(self): return self._small_camel @small_camel.setter - def small_camel( - self, - small_camel): + def small_camel(self, small_camel): # noqa: E501 """Sets the small_camel of this Capitalization. @@ -105,7 +128,8 @@ def small_camel( """ self._small_camel = ( - small_camel) + small_camel + ) @property def capital_camel(self): @@ -118,9 +142,7 @@ def capital_camel(self): return self._capital_camel @capital_camel.setter - def capital_camel( - self, - capital_camel): + def capital_camel(self, capital_camel): # noqa: E501 """Sets the capital_camel of this Capitalization. @@ -129,7 +151,8 @@ def capital_camel( """ self._capital_camel = ( - capital_camel) + capital_camel + ) @property def small_snake(self): @@ -142,9 +165,7 @@ def small_snake(self): return self._small_snake @small_snake.setter - def small_snake( - self, - small_snake): + def small_snake(self, small_snake): # noqa: E501 """Sets the small_snake of this Capitalization. @@ -153,7 +174,8 @@ def small_snake( """ self._small_snake = ( - small_snake) + small_snake + ) @property def capital_snake(self): @@ -166,9 +188,7 @@ def capital_snake(self): return self._capital_snake @capital_snake.setter - def capital_snake( - self, - capital_snake): + def capital_snake(self, capital_snake): # noqa: E501 """Sets the capital_snake of this Capitalization. @@ -177,7 +197,8 @@ def capital_snake( """ self._capital_snake = ( - capital_snake) + capital_snake + ) @property def sca_eth_flow_points(self): @@ -190,9 +211,7 @@ def sca_eth_flow_points(self): return self._sca_eth_flow_points @sca_eth_flow_points.setter - def sca_eth_flow_points( - self, - sca_eth_flow_points): + def sca_eth_flow_points(self, sca_eth_flow_points): # noqa: E501 """Sets the sca_eth_flow_points of this Capitalization. @@ -201,7 +220,8 @@ def sca_eth_flow_points( """ self._sca_eth_flow_points = ( - sca_eth_flow_points) + sca_eth_flow_points + ) @property def att_name(self): @@ -215,9 +235,7 @@ def att_name(self): return self._att_name @att_name.setter - def att_name( - self, - att_name): + def att_name(self, att_name): # noqa: E501 """Sets the att_name of this Capitalization. Name of the pet # noqa: E501 @@ -227,7 +245,8 @@ def att_name( """ self._att_name = ( - att_name) + att_name + ) def to_dict(self): """Returns the model properties as a dict""" 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 2a19eddd5ed1..b496a13fe98e 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/cat.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/cat.py @@ -10,54 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Cat(object): + +class Cat(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'class_name': 'str', - 'declawed': 'bool', - 'color': 'str', + + allowed_values = { } attribute_map = { - 'class_name': 'className', # noqa: E501 - 'declawed': 'declawed', # noqa: E501 - 'color': 'color', # noqa: E501 + 'declawed': 'declawed' # noqa: E501 } - def __init__(self, class_name, declawed=None, color=None): # noqa: E501 - """Cat - a model defined in OpenAPI + openapi_types = { + 'declawed': 'bool' + } - Args: - class_name (str): + validations = { + } - Keyword Args: # noqa: E501 - declawed (bool): [optional] # noqa: E501 - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 - """ + def __init__(self, declawed=None): # noqa: E501 + """Cat - a model defined in OpenAPI""" # noqa: E501 self._declawed = None self.discriminator = None if declawed is not None: - self.declawed = declawed # noqa: E501 + self.declawed = ( + declawed + ) @property def declawed(self): @@ -70,9 +84,7 @@ def declawed(self): return self._declawed @declawed.setter - def declawed( - self, - declawed): + def declawed(self, declawed): # noqa: E501 """Sets the declawed of this Cat. @@ -81,7 +93,8 @@ def declawed( """ self._declawed = ( - declawed) + declawed + ) def to_dict(self): """Returns the model properties as a dict""" 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 88260a5e3d91..0a8267293dd3 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class CatAllOf(object): + +class CatAllOf(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'declawed': 'bool', + + allowed_values = { } attribute_map = { - 'declawed': 'declawed', # noqa: E501 + 'declawed': 'declawed' # noqa: E501 } - def __init__(self, declawed=None): # noqa: E501 - """CatAllOf - a model defined in OpenAPI - + openapi_types = { + 'declawed': 'bool' + } + validations = { + } - Keyword Args: - declawed (bool): [optional] # noqa: E501 - """ + def __init__(self, declawed=None): # noqa: E501 + """CatAllOf - a model defined in OpenAPI""" # noqa: E501 self._declawed = None self.discriminator = None if declawed is not None: - self.declawed = declawed # noqa: E501 + self.declawed = ( + declawed + ) @property def declawed(self): @@ -64,9 +84,7 @@ def declawed(self): return self._declawed @declawed.setter - def declawed( - self, - declawed): + def declawed(self, declawed): # noqa: E501 """Sets the declawed of this CatAllOf. @@ -75,7 +93,8 @@ def declawed( """ self._declawed = ( - declawed) + declawed + ) def to_dict(self): """Returns the model properties as a dict""" 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 347ed14927e4..bf117a1317df 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/category.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/category.py @@ -10,52 +10,71 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Category(object): + +class Category(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', - 'id': 'int', + + allowed_values = { } attribute_map = { - 'name': 'name', # noqa: E501 'id': 'id', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, name='default-name', id=None): # noqa: E501 - """Category - a model defined in OpenAPI + openapi_types = { + 'id': 'int', + 'name': 'str' + } - Args: + validations = { + } - Keyword Args: - name (str): defaults to 'default-name', must be one of ['default-name'] # noqa: E501 - id (int): [optional] # noqa: E501 - """ + def __init__(self, id=None, name='default-name'): # noqa: E501 + """Category - a model defined in OpenAPI""" # noqa: E501 self._id = None self._name = None self.discriminator = None if id is not None: - self.id = id # noqa: E501 + self.id = ( + id + ) self.name = name @property @@ -69,9 +88,7 @@ def id(self): return self._id @id.setter - def id( - self, - id): + def id(self, id): # noqa: E501 """Sets the id of this Category. @@ -80,7 +97,8 @@ def id( """ self._id = ( - id) + id + ) @property def name(self): @@ -93,9 +111,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this Category. @@ -103,10 +119,11 @@ def name( :type: str """ if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 bac11b0e1383..907e0f6ce2db 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class ClassModel(object): + +class ClassModel(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - '_class': 'str', + + allowed_values = { } attribute_map = { - '_class': '_class', # noqa: E501 + '_class': '_class' # noqa: E501 } - def __init__(self, _class=None): # noqa: E501 - """ClassModel - a model defined in OpenAPI - + openapi_types = { + '_class': 'str' + } + validations = { + } - Keyword Args: - _class (str): [optional] # noqa: E501 - """ + def __init__(self, _class=None): # noqa: E501 + """ClassModel - a model defined in OpenAPI""" # noqa: E501 self.__class = None self.discriminator = None if _class is not None: - self._class = _class # noqa: E501 + self._class = ( + _class + ) @property def _class(self): @@ -64,9 +84,7 @@ def _class(self): return self.__class @_class.setter - def _class( - self, - _class): + def _class(self, _class): # noqa: E501 """Sets the _class of this ClassModel. @@ -75,7 +93,8 @@ def _class( """ self.__class = ( - _class) + _class + ) def to_dict(self): """Returns the model properties as a dict""" 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 4cde17963c5f..7b133a387147 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/client.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/client.py @@ -10,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Client(object): + +class Client(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'client': 'str', + + allowed_values = { } attribute_map = { - 'client': 'client', # noqa: E501 + 'client': 'client' # noqa: E501 } - def __init__(self, client=None): # noqa: E501 - """Client - a model defined in OpenAPI - + openapi_types = { + 'client': 'str' + } + validations = { + } - Keyword Args: - client (str): [optional] # noqa: E501 - """ + def __init__(self, client=None): # noqa: E501 + """Client - a model defined in OpenAPI""" # noqa: E501 self._client = None self.discriminator = None if client is not None: - self.client = client # noqa: E501 + self.client = ( + client + ) @property def client(self): @@ -64,9 +84,7 @@ def client(self): return self._client @client.setter - def client( - self, - client): + def client(self, client): # noqa: E501 """Sets the client of this Client. @@ -75,7 +93,8 @@ def client( """ self._client = ( - client) + client + ) def to_dict(self): """Returns the model properties as a dict""" 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 14c4eedcc59a..61ef9958fc40 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/dog.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/dog.py @@ -10,54 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Dog(object): + +class Dog(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'class_name': 'str', - 'breed': 'str', - 'color': 'str', + + allowed_values = { } attribute_map = { - 'class_name': 'className', # noqa: E501 - 'breed': 'breed', # noqa: E501 - 'color': 'color', # noqa: E501 + 'breed': 'breed' # noqa: E501 } - def __init__(self, class_name, breed=None, color=None): # noqa: E501 - """Dog - a model defined in OpenAPI + openapi_types = { + 'breed': 'str' + } - Args: - class_name (str): + validations = { + } - Keyword Args: # noqa: E501 - breed (str): [optional] # noqa: E501 - color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501 - """ + def __init__(self, breed=None): # noqa: E501 + """Dog - a model defined in OpenAPI""" # noqa: E501 self._breed = None self.discriminator = None if breed is not None: - self.breed = breed # noqa: E501 + self.breed = ( + breed + ) @property def breed(self): @@ -70,9 +84,7 @@ def breed(self): return self._breed @breed.setter - def breed( - self, - breed): + def breed(self, breed): # noqa: E501 """Sets the breed of this Dog. @@ -81,7 +93,8 @@ def breed( """ self._breed = ( - breed) + breed + ) def to_dict(self): """Returns the model properties as a dict""" 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 7940637ce5ec..cc082b5b3576 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class DogAllOf(object): + +class DogAllOf(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'breed': 'str', + + allowed_values = { } attribute_map = { - 'breed': 'breed', # noqa: E501 + 'breed': 'breed' # noqa: E501 } - def __init__(self, breed=None): # noqa: E501 - """DogAllOf - a model defined in OpenAPI - + openapi_types = { + 'breed': 'str' + } + validations = { + } - Keyword Args: - breed (str): [optional] # noqa: E501 - """ + def __init__(self, breed=None): # noqa: E501 + """DogAllOf - a model defined in OpenAPI""" # noqa: E501 self._breed = None self.discriminator = None if breed is not None: - self.breed = breed # noqa: E501 + self.breed = ( + breed + ) @property def breed(self): @@ -64,9 +84,7 @@ def breed(self): return self._breed @breed.setter - def breed( - self, - breed): + def breed(self, breed): # noqa: E501 """Sets the breed of this DogAllOf. @@ -75,7 +93,8 @@ def breed( """ self._breed = ( - breed) + breed + ) def to_dict(self): """Returns the model properties as a dict""" 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 ad0e8c3d9b6d..fe8355e7defa 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,54 +10,83 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class EnumArrays(object): + +class EnumArrays(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'just_symbol': 'str', - 'array_enum': 'list[str]', + + allowed_values = { + ('just_symbol',): { + '>=': ">=", + '$': "$" + }, + ('array_enum',): { + 'FISH': "fish", + 'CRAB': "crab" + }, } attribute_map = { 'just_symbol': 'just_symbol', # noqa: E501 - 'array_enum': 'array_enum', # noqa: E501 + 'array_enum': 'array_enum' # noqa: E501 } - def __init__(self, just_symbol=None, array_enum=None): # noqa: E501 - """EnumArrays - a model defined in OpenAPI - + openapi_types = { + 'just_symbol': 'str', + 'array_enum': 'list[str]' + } + validations = { + } - Keyword Args: - just_symbol (str): [optional] # noqa: E501 - array_enum (list[str]): [optional] # noqa: E501 - """ + def __init__(self, just_symbol=None, array_enum=None): # noqa: E501 + """EnumArrays - a model defined in OpenAPI""" # noqa: E501 self._just_symbol = None self._array_enum = None self.discriminator = None if just_symbol is not None: - self.just_symbol = just_symbol # noqa: E501 + self.just_symbol = ( + just_symbol + ) if array_enum is not None: - self.array_enum = array_enum # noqa: E501 + self.array_enum = ( + array_enum + ) @property def just_symbol(self): @@ -70,24 +99,23 @@ def just_symbol(self): return self._just_symbol @just_symbol.setter - def just_symbol( - self, - just_symbol): + def just_symbol(self, just_symbol): # noqa: E501 """Sets the just_symbol of this EnumArrays. :param just_symbol: The just_symbol of this EnumArrays. # noqa: E501 :type: str """ - allowed_values = [">=", "$"] # noqa: E501 - if just_symbol not in allowed_values: - raise ValueError( - "Invalid value for `just_symbol` ({0}), must be one of {1}" # noqa: E501 - .format(just_symbol, allowed_values) - ) + check_allowed_values( + self.allowed_values, + ('just_symbol',), + just_symbol, + self.validations + ) self._just_symbol = ( - just_symbol) + just_symbol + ) @property def array_enum(self): @@ -100,25 +128,23 @@ def array_enum(self): return self._array_enum @array_enum.setter - def array_enum( - self, - array_enum): + def array_enum(self, array_enum): # noqa: E501 """Sets the array_enum of this EnumArrays. :param array_enum: The array_enum of this EnumArrays. # noqa: E501 :type: list[str] """ - allowed_values = ["fish", "crab"] # noqa: E501 - if not set(array_enum).issubset(set(allowed_values)): - raise ValueError( - "Invalid values for `array_enum` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(array_enum) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) + check_allowed_values( + self.allowed_values, + ('array_enum',), + array_enum, + self.validations + ) self._array_enum = ( - array_enum) + array_enum + ) def to_dict(self): """Returns the model properties as a dict""" 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 a2f3a3e4a781..60d4f64e9c17 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,75 +10,97 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class EnumClass(object): + +class EnumClass(ModelSimple): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - - """ - allowed enum values - """ - _ABC = "_abc" - _EFG = "-efg" - _XYZ_ = "(xyz)" - """ 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. openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. + 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. """ + + allowed_values = { + ('value',): { + '_ABC': "_abc", + '-EFG': "-efg", + '(XYZ)': "(xyz)" + }, + } + openapi_types = { + 'value': 'str' } - attribute_map = { + validations = { } - def __init__(self): # noqa: E501 - """EnumClass - a model defined in OpenAPI + def __init__(self, value='-efg'): # noqa: E501 + """EnumClass - a model defined in OpenAPI""" # noqa: E501 + + self._value = None + self.discriminator = None + + self.value = value + @property + def value(self): + """Gets the value of this EnumClass. # noqa: E501 - Keyword Args: + :return: The value of this EnumClass. # noqa: E501 + :rtype: str """ - self.discriminator = None + return self._value + + @value.setter + def value(self, value): # noqa: E501 + """Sets the value of this EnumClass. - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result + + :param value: The value of this EnumClass. # noqa: E501 + :type: str + """ + if value is None: + raise ApiValueError("Invalid value for `value`, must not be `None`") # noqa: E501 + check_allowed_values( + self.allowed_values, + ('value',), + value, + self.validations + ) + + self._value = ( + value + ) def to_str(self): """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) + return str(self._value) def __repr__(self): """For `print` and `pprint`""" 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 4ea9e777f686..0ec5096c0abd 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,54 +10,86 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class EnumTest(object): + +class EnumTest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'enum_string_required': 'str', - 'enum_string': 'str', - 'enum_integer': 'int', - 'enum_number': 'float', - 'outer_enum': 'OuterEnum', + + allowed_values = { + ('enum_string',): { + 'UPPER': "UPPER", + 'LOWER': "lower", + 'EMPTY': "" + }, + ('enum_string_required',): { + 'UPPER': "UPPER", + 'LOWER': "lower", + 'EMPTY': "" + }, + ('enum_integer',): { + '1': 1, + '-1': -1 + }, + ('enum_number',): { + '1.1': 1.1, + '-1.2': -1.2 + }, } attribute_map = { - 'enum_string_required': 'enum_string_required', # noqa: E501 '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 + 'outer_enum': 'outerEnum' # noqa: E501 } - def __init__(self, enum_string_required, enum_string=None, enum_integer=None, enum_number=None, outer_enum=None): # noqa: E501 - """EnumTest - a model defined in OpenAPI + openapi_types = { + 'enum_string': 'str', + 'enum_string_required': 'str', + 'enum_integer': 'int', + 'enum_number': 'float', + 'outer_enum': 'OuterEnum' + } - Args: - enum_string_required (str): + validations = { + } - Keyword Args: # noqa: E501 - enum_string (str): [optional] # noqa: E501 - enum_integer (int): [optional] # noqa: E501 - enum_number (float): [optional] # noqa: E501 - outer_enum (OuterEnum): [optional] # noqa: E501 - """ + def __init__(self, enum_string=None, enum_string_required=None, enum_integer=None, enum_number=None, outer_enum=None): # noqa: E501 + """EnumTest - a model defined in OpenAPI""" # noqa: E501 self._enum_string = None self._enum_string_required = None @@ -67,14 +99,22 @@ def __init__(self, enum_string_required, enum_string=None, enum_integer=None, en self.discriminator = None if enum_string is not None: - self.enum_string = enum_string # noqa: E501 + self.enum_string = ( + enum_string + ) self.enum_string_required = enum_string_required if enum_integer is not None: - self.enum_integer = enum_integer # noqa: E501 + self.enum_integer = ( + enum_integer + ) if enum_number is not None: - self.enum_number = enum_number # noqa: E501 + self.enum_number = ( + enum_number + ) if outer_enum is not None: - self.outer_enum = outer_enum # noqa: E501 + self.outer_enum = ( + outer_enum + ) @property def enum_string(self): @@ -87,24 +127,23 @@ def enum_string(self): return self._enum_string @enum_string.setter - def enum_string( - self, - enum_string): + def enum_string(self, enum_string): # noqa: E501 """Sets the enum_string of this EnumTest. :param enum_string: The enum_string of this EnumTest. # noqa: E501 :type: str """ - allowed_values = ["UPPER", "lower", ""] # noqa: E501 - if enum_string not in allowed_values: - raise ValueError( - "Invalid value for `enum_string` ({0}), must be one of {1}" # noqa: E501 - .format(enum_string, allowed_values) - ) + check_allowed_values( + self.allowed_values, + ('enum_string',), + enum_string, + self.validations + ) self._enum_string = ( - enum_string) + enum_string + ) @property def enum_string_required(self): @@ -117,9 +156,7 @@ def enum_string_required(self): return self._enum_string_required @enum_string_required.setter - def enum_string_required( - self, - enum_string_required): + def enum_string_required(self, enum_string_required): # noqa: E501 """Sets the enum_string_required of this EnumTest. @@ -127,16 +164,17 @@ def enum_string_required( :type: str """ if enum_string_required is None: - raise ValueError("Invalid value for `enum_string_required`, must not be `None`") # noqa: E501 - allowed_values = ["UPPER", "lower", ""] # noqa: E501 - if enum_string_required not in allowed_values: - raise ValueError( - "Invalid value for `enum_string_required` ({0}), must be one of {1}" # noqa: E501 - .format(enum_string_required, allowed_values) - ) + raise ApiValueError("Invalid value for `enum_string_required`, must not be `None`") # noqa: E501 + check_allowed_values( + self.allowed_values, + ('enum_string_required',), + enum_string_required, + self.validations + ) self._enum_string_required = ( - enum_string_required) + enum_string_required + ) @property def enum_integer(self): @@ -149,24 +187,23 @@ def enum_integer(self): return self._enum_integer @enum_integer.setter - def enum_integer( - self, - enum_integer): + def enum_integer(self, enum_integer): # noqa: E501 """Sets the enum_integer of this EnumTest. :param enum_integer: The enum_integer of this EnumTest. # noqa: E501 :type: int """ - allowed_values = [1, -1] # noqa: E501 - if enum_integer not in allowed_values: - raise ValueError( - "Invalid value for `enum_integer` ({0}), must be one of {1}" # noqa: E501 - .format(enum_integer, allowed_values) - ) + check_allowed_values( + self.allowed_values, + ('enum_integer',), + enum_integer, + self.validations + ) self._enum_integer = ( - enum_integer) + enum_integer + ) @property def enum_number(self): @@ -179,24 +216,23 @@ def enum_number(self): return self._enum_number @enum_number.setter - def enum_number( - self, - enum_number): + def enum_number(self, enum_number): # noqa: E501 """Sets the enum_number of this EnumTest. :param enum_number: The enum_number of this EnumTest. # noqa: E501 :type: float """ - allowed_values = [1.1, -1.2] # noqa: E501 - if enum_number not in allowed_values: - raise ValueError( - "Invalid value for `enum_number` ({0}), must be one of {1}" # noqa: E501 - .format(enum_number, allowed_values) - ) + check_allowed_values( + self.allowed_values, + ('enum_number',), + enum_number, + self.validations + ) self._enum_number = ( - enum_number) + enum_number + ) @property def outer_enum(self): @@ -209,9 +245,7 @@ def outer_enum(self): return self._outer_enum @outer_enum.setter - def outer_enum( - self, - outer_enum): + def outer_enum(self, outer_enum): # noqa: E501 """Sets the outer_enum of this EnumTest. @@ -220,7 +254,8 @@ def outer_enum( """ self._outer_enum = ( - outer_enum) + outer_enum + ) def to_dict(self): """Returns the model properties as a dict""" 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 70e1611a2370..6411e70e07b9 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/file.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/file.py @@ -10,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class File(object): + +class File(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'source_uri': 'str', + + allowed_values = { } attribute_map = { - 'source_uri': 'sourceURI', # noqa: E501 + 'source_uri': 'sourceURI' # noqa: E501 } - def __init__(self, source_uri=None): # noqa: E501 - """File - a model defined in OpenAPI - + openapi_types = { + 'source_uri': 'str' + } + validations = { + } - Keyword Args: - source_uri (str): Test capitalization. [optional] # noqa: E501 - """ + def __init__(self, source_uri=None): # noqa: E501 + """File - a model defined in OpenAPI""" # noqa: E501 self._source_uri = None self.discriminator = None if source_uri is not None: - self.source_uri = source_uri # noqa: E501 + self.source_uri = ( + source_uri + ) @property def source_uri(self): @@ -65,9 +85,7 @@ def source_uri(self): return self._source_uri @source_uri.setter - def source_uri( - self, - source_uri): + def source_uri(self, source_uri): # noqa: E501 """Sets the source_uri of this File. Test capitalization # noqa: E501 @@ -77,7 +95,8 @@ def source_uri( """ self._source_uri = ( - source_uri) + source_uri + ) def to_dict(self): """Returns the model properties as a dict""" 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 86e926ca153b..e773e2cb194c 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,54 +10,75 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class FileSchemaTestClass(object): + +class FileSchemaTestClass(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'file': 'File', - 'files': 'list[File]', + + allowed_values = { } attribute_map = { 'file': 'file', # noqa: E501 - 'files': 'files', # noqa: E501 + 'files': 'files' # noqa: E501 } - def __init__(self, file=None, files=None): # noqa: E501 - """FileSchemaTestClass - a model defined in OpenAPI - + openapi_types = { + 'file': 'File', + 'files': 'list[File]' + } + validations = { + } - Keyword Args: - file (File): [optional] # noqa: E501 - files (list[File]): [optional] # noqa: E501 - """ + def __init__(self, file=None, files=None): # noqa: E501 + """FileSchemaTestClass - a model defined in OpenAPI""" # noqa: E501 self._file = None self._files = None self.discriminator = None if file is not None: - self.file = file # noqa: E501 + self.file = ( + file + ) if files is not None: - self.files = files # noqa: E501 + self.files = ( + files + ) @property def file(self): @@ -70,9 +91,7 @@ def file(self): return self._file @file.setter - def file( - self, - file): + def file(self, file): # noqa: E501 """Sets the file of this FileSchemaTestClass. @@ -81,7 +100,8 @@ def file( """ self._file = ( - file) + file + ) @property def files(self): @@ -94,9 +114,7 @@ def files(self): return self._files @files.setter - def files( - self, - files): + def files(self, files): # noqa: E501 """Sets the files of this FileSchemaTestClass. @@ -105,7 +123,8 @@ def files( """ self._files = ( - files) + files + ) def to_dict(self): """Returns the model properties as a dict""" 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 a7936dc37ec6..8b1a5143e013 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,78 +10,126 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class FormatTest(object): + +class FormatTest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'number': 'float', - 'byte': 'str', - 'date': 'date', - 'password': 'str', - 'integer': 'int', - 'int32': 'int', - 'int64': 'int', - 'float': 'float', - 'double': 'float', - 'string': 'str', - 'binary': 'file', - 'date_time': 'datetime', - 'uuid': 'str', + + allowed_values = { } 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 + '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 } - def __init__(self, number, byte, date, password, integer=None, int32=None, int64=None, float=None, double=None, string=None, binary=None, date_time=None, uuid=None): # noqa: E501 - """FormatTest - a model defined in OpenAPI - - Args: - number (float): - byte (str): - date (date): - password (str): - - Keyword Args: # noqa: E501 # noqa: E501 # noqa: E501 # noqa: E501 - integer (int): [optional] # noqa: E501 - int32 (int): [optional] # noqa: E501 - int64 (int): [optional] # noqa: E501 - float (float): [optional] # noqa: E501 - double (float): [optional] # noqa: E501 - string (str): [optional] # noqa: E501 - binary (file): [optional] # noqa: E501 - date_time (datetime): [optional] # noqa: E501 - uuid (str): [optional] # noqa: E501 - """ + openapi_types = { + 'integer': 'int', + 'int32': 'int', + 'int64': 'int', + 'number': 'float', + 'float': 'float', + 'double': 'float', + 'string': 'str', + 'byte': 'str', + 'binary': 'file', + 'date': 'date', + 'date_time': 'datetime', + 'uuid': 'str', + 'password': 'str' + } + + validations = { + ('integer',): { + + 'inclusive_maximum': 100, + 'inclusive_minimum': 10, + }, + ('int32',): { + + 'inclusive_maximum': 200, + 'inclusive_minimum': 20, + }, + ('number',): { + + 'inclusive_maximum': 543.2, + 'inclusive_minimum': 32.1, + }, + ('float',): { + + 'inclusive_maximum': 987.6, + 'inclusive_minimum': 54.3, + }, + ('double',): { + + 'inclusive_maximum': 123.4, + 'inclusive_minimum': 67.8, + }, + ('string',): { + + 'regex': { + 'pattern': r'^[a-z]+$', # noqa: E501 + '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, + }, + } + + def __init__(self, integer=None, int32=None, int64=None, number=None, float=None, double=None, string=None, byte=None, binary=None, date=None, date_time=None, uuid=None, password=None): # noqa: E501 + """FormatTest - a model defined in OpenAPI""" # noqa: E501 self._integer = None self._int32 = None @@ -99,26 +147,44 @@ def __init__(self, number, byte, date, password, integer=None, int32=None, int64 self.discriminator = None if integer is not None: - self.integer = integer # noqa: E501 + self.integer = ( + integer + ) if int32 is not None: - self.int32 = int32 # noqa: E501 + self.int32 = ( + int32 + ) if int64 is not None: - self.int64 = int64 # noqa: E501 + self.int64 = ( + int64 + ) self.number = number if float is not None: - self.float = float # noqa: E501 + self.float = ( + float + ) if double is not None: - self.double = double # noqa: E501 + self.double = ( + double + ) if string is not None: - self.string = string # noqa: E501 + self.string = ( + string + ) self.byte = byte if binary is not None: - self.binary = binary # noqa: E501 + self.binary = ( + binary + ) self.date = date if date_time is not None: - self.date_time = date_time # noqa: E501 + self.date_time = ( + date_time + ) if uuid is not None: - self.uuid = uuid # noqa: E501 + self.uuid = ( + uuid + ) self.password = password @property @@ -132,22 +198,22 @@ def integer(self): return self._integer @integer.setter - def integer( - self, - integer): + def integer(self, integer): # noqa: E501 """Sets the integer of this FormatTest. :param integer: The integer of this FormatTest. # noqa: E501 :type: int """ - if integer is not None and integer > 100: # noqa: E501 - raise ValueError("Invalid value for `integer`, must be a value less than or equal to `100`") # noqa: E501 - if integer is not None and integer < 10: # noqa: E501 - raise ValueError("Invalid value for `integer`, must be a value greater than or equal to `10`") # noqa: E501 + check_validations( + self.validations, + ('integer',), + integer + ) self._integer = ( - integer) + integer + ) @property def int32(self): @@ -160,22 +226,22 @@ def int32(self): return self._int32 @int32.setter - def int32( - self, - int32): + def int32(self, int32): # noqa: E501 """Sets the int32 of this FormatTest. :param int32: The int32 of this FormatTest. # noqa: E501 :type: int """ - if int32 is not None and int32 > 200: # noqa: E501 - raise ValueError("Invalid value for `int32`, must be a value less than or equal to `200`") # noqa: E501 - if int32 is not None and int32 < 20: # noqa: E501 - raise ValueError("Invalid value for `int32`, must be a value greater than or equal to `20`") # noqa: E501 + check_validations( + self.validations, + ('int32',), + int32 + ) self._int32 = ( - int32) + int32 + ) @property def int64(self): @@ -188,9 +254,7 @@ def int64(self): return self._int64 @int64.setter - def int64( - self, - int64): + def int64(self, int64): # noqa: E501 """Sets the int64 of this FormatTest. @@ -199,7 +263,8 @@ def int64( """ self._int64 = ( - int64) + int64 + ) @property def number(self): @@ -212,9 +277,7 @@ def number(self): return self._number @number.setter - def number( - self, - number): + def number(self, number): # noqa: E501 """Sets the number of this FormatTest. @@ -222,14 +285,16 @@ def number( :type: float """ if number is None: - raise ValueError("Invalid value for `number`, must not be `None`") # noqa: E501 - if number is not None and number > 543.2: # noqa: E501 - raise ValueError("Invalid value for `number`, must be a value less than or equal to `543.2`") # noqa: E501 - if number is not None and number < 32.1: # noqa: E501 - raise ValueError("Invalid value for `number`, must be a value greater than or equal to `32.1`") # noqa: E501 + raise ApiValueError("Invalid value for `number`, must not be `None`") # noqa: E501 + check_validations( + self.validations, + ('number',), + number + ) self._number = ( - number) + number + ) @property def float(self): @@ -242,22 +307,22 @@ def float(self): return self._float @float.setter - def float( - self, - float): + def float(self, float): # noqa: E501 """Sets the float of this FormatTest. :param float: The float of this FormatTest. # noqa: E501 :type: float """ - if float is not None and float > 987.6: # noqa: E501 - raise ValueError("Invalid value for `float`, must be a value less than or equal to `987.6`") # noqa: E501 - if float is not None and float < 54.3: # noqa: E501 - raise ValueError("Invalid value for `float`, must be a value greater than or equal to `54.3`") # noqa: E501 + check_validations( + self.validations, + ('float',), + float + ) self._float = ( - float) + float + ) @property def double(self): @@ -270,22 +335,22 @@ def double(self): return self._double @double.setter - def double( - self, - double): + def double(self, double): # noqa: E501 """Sets the double of this FormatTest. :param double: The double of this FormatTest. # noqa: E501 :type: float """ - if double is not None and double > 123.4: # noqa: E501 - raise ValueError("Invalid value for `double`, must be a value less than or equal to `123.4`") # noqa: E501 - if double is not None and double < 67.8: # noqa: E501 - raise ValueError("Invalid value for `double`, must be a value greater than or equal to `67.8`") # noqa: E501 + check_validations( + self.validations, + ('double',), + double + ) self._double = ( - double) + double + ) @property def string(self): @@ -298,20 +363,22 @@ def string(self): return self._string @string.setter - def string( - self, - string): + def string(self, string): # noqa: E501 """Sets the string of this FormatTest. :param string: The string of this FormatTest. # noqa: E501 :type: str """ - if string is not None and not re.search(r'[a-z]', string, flags=re.IGNORECASE): # noqa: E501 - raise ValueError(r"Invalid value for `string`, must be a follow pattern or equal to `/[a-z]/i`") # noqa: E501 + check_validations( + self.validations, + ('string',), + string + ) self._string = ( - string) + string + ) @property def byte(self): @@ -324,9 +391,7 @@ def byte(self): return self._byte @byte.setter - def byte( - self, - byte): + def byte(self, byte): # noqa: E501 """Sets the byte of this FormatTest. @@ -334,12 +399,16 @@ def byte( :type: str """ if byte is None: - raise ValueError("Invalid value for `byte`, must not be `None`") # noqa: E501 - if byte is not None and not re.search(r'^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$', byte): # noqa: E501 - raise ValueError(r"Invalid value for `byte`, must be a follow pattern or equal to `/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/`") # noqa: E501 + raise ApiValueError("Invalid value for `byte`, must not be `None`") # noqa: E501 + check_validations( + self.validations, + ('byte',), + byte + ) self._byte = ( - byte) + byte + ) @property def binary(self): @@ -352,9 +421,7 @@ def binary(self): return self._binary @binary.setter - def binary( - self, - binary): + def binary(self, binary): # noqa: E501 """Sets the binary of this FormatTest. @@ -363,7 +430,8 @@ def binary( """ self._binary = ( - binary) + binary + ) @property def date(self): @@ -376,9 +444,7 @@ def date(self): return self._date @date.setter - def date( - self, - date): + def date(self, date): # noqa: E501 """Sets the date of this FormatTest. @@ -386,10 +452,11 @@ def date( :type: date """ if date is None: - raise ValueError("Invalid value for `date`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `date`, must not be `None`") # noqa: E501 self._date = ( - date) + date + ) @property def date_time(self): @@ -402,9 +469,7 @@ def date_time(self): return self._date_time @date_time.setter - def date_time( - self, - date_time): + def date_time(self, date_time): # noqa: E501 """Sets the date_time of this FormatTest. @@ -413,7 +478,8 @@ def date_time( """ self._date_time = ( - date_time) + date_time + ) @property def uuid(self): @@ -426,9 +492,7 @@ def uuid(self): return self._uuid @uuid.setter - def uuid( - self, - uuid): + def uuid(self, uuid): # noqa: E501 """Sets the uuid of this FormatTest. @@ -437,7 +501,8 @@ def uuid( """ self._uuid = ( - uuid) + uuid + ) @property def password(self): @@ -450,9 +515,7 @@ def password(self): return self._password @password.setter - def password( - self, - password): + def password(self, password): # noqa: E501 """Sets the password of this FormatTest. @@ -460,14 +523,16 @@ def password( :type: str """ if password is None: - raise ValueError("Invalid value for `password`, must not be `None`") # noqa: E501 - if password is not None and len(password) > 64: - raise ValueError("Invalid value for `password`, length must be less than or equal to `64`") # noqa: E501 - if password is not None and len(password) < 10: - raise ValueError("Invalid value for `password`, length must be greater than or equal to `10`") # noqa: E501 + raise ApiValueError("Invalid value for `password`, must not be `None`") # noqa: E501 + check_validations( + self.validations, + ('password',), + password + ) self._password = ( - password) + password + ) def to_dict(self): """Returns the model properties as a dict""" 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 8744de383447..2ef64381ea32 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,54 +10,75 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class HasOnlyReadOnly(object): + +class HasOnlyReadOnly(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'bar': 'str', - 'foo': 'str', + + allowed_values = { } attribute_map = { 'bar': 'bar', # noqa: E501 - 'foo': 'foo', # noqa: E501 + 'foo': 'foo' # noqa: E501 } - def __init__(self, bar=None, foo=None): # noqa: E501 - """HasOnlyReadOnly - a model defined in OpenAPI - + openapi_types = { + 'bar': 'str', + 'foo': 'str' + } + validations = { + } - Keyword Args: - bar (str): [optional] # noqa: E501 - foo (str): [optional] # noqa: E501 - """ + def __init__(self, bar=None, foo=None): # noqa: E501 + """HasOnlyReadOnly - a model defined in OpenAPI""" # noqa: E501 self._bar = None self._foo = None self.discriminator = None if bar is not None: - self.bar = bar # noqa: E501 + self.bar = ( + bar + ) if foo is not None: - self.foo = foo # noqa: E501 + self.foo = ( + foo + ) @property def bar(self): @@ -70,9 +91,7 @@ def bar(self): return self._bar @bar.setter - def bar( - self, - bar): + def bar(self, bar): # noqa: E501 """Sets the bar of this HasOnlyReadOnly. @@ -81,7 +100,8 @@ def bar( """ self._bar = ( - bar) + bar + ) @property def foo(self): @@ -94,9 +114,7 @@ def foo(self): return self._foo @foo.setter - def foo( - self, - foo): + def foo(self, foo): # noqa: E501 """Sets the foo of this HasOnlyReadOnly. @@ -105,7 +123,8 @@ def foo( """ self._foo = ( - foo) + foo + ) def to_dict(self): """Returns the model properties as a dict""" 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 14b9a6561759..388989603a92 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/list.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/list.py @@ -10,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class List(object): + +class List(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - '_123_list': 'str', + + allowed_values = { } attribute_map = { - '_123_list': '123-list', # noqa: E501 + '_123_list': '123-list' # noqa: E501 } - def __init__(self, _123_list=None): # noqa: E501 - """List - a model defined in OpenAPI - + openapi_types = { + '_123_list': 'str' + } + validations = { + } - Keyword Args: - _123_list (str): [optional] # noqa: E501 - """ + def __init__(self, _123_list=None): # noqa: E501 + """List - a model defined in OpenAPI""" # noqa: E501 self.__123_list = None self.discriminator = None if _123_list is not None: - self._123_list = _123_list # noqa: E501 + self._123_list = ( + _123_list + ) @property def _123_list(self): @@ -64,9 +84,7 @@ def _123_list(self): return self.__123_list @_123_list.setter - def _123_list( - self, - _123_list): + def _123_list(self, _123_list): # noqa: E501 """Sets the _123_list of this List. @@ -75,7 +93,8 @@ def _123_list( """ self.__123_list = ( - _123_list) + _123_list + ) def to_dict(self): """Returns the model properties as a dict""" 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 d6d975f16e6b..171791435046 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,51 +10,70 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class MapTest(object): + +class MapTest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'map_map_of_string': 'dict(str, dict(str, str))', - 'map_of_enum_string': 'dict(str, str)', - 'direct_map': 'dict(str, bool)', - 'indirect_map': 'dict(str, bool)', + + allowed_values = { + ('map_of_enum_string',): { + 'UPPER': "UPPER", + 'LOWER': "lower" + }, } 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 + 'indirect_map': 'indirect_map' # noqa: E501 } - def __init__(self, map_map_of_string=None, map_of_enum_string=None, direct_map=None, indirect_map=None): # noqa: E501 - """MapTest - a model defined in OpenAPI - + openapi_types = { + 'map_map_of_string': 'dict(str, dict(str, str))', + 'map_of_enum_string': 'dict(str, str)', + 'direct_map': 'dict(str, bool)', + 'indirect_map': 'StringBooleanMap' + } + validations = { + } - Keyword Args: - map_map_of_string (dict(str, dict(str, str))): [optional] # noqa: E501 - map_of_enum_string (dict(str, str)): [optional] # noqa: E501 - direct_map (dict(str, bool)): [optional] # noqa: E501 - indirect_map (dict(str, bool)): [optional] # noqa: E501 - """ + def __init__(self, map_map_of_string=None, map_of_enum_string=None, direct_map=None, indirect_map=None): # noqa: E501 + """MapTest - a model defined in OpenAPI""" # noqa: E501 self._map_map_of_string = None self._map_of_enum_string = None @@ -63,13 +82,21 @@ def __init__(self, map_map_of_string=None, map_of_enum_string=None, direct_map=N self.discriminator = None if map_map_of_string is not None: - self.map_map_of_string = map_map_of_string # noqa: E501 + self.map_map_of_string = ( + map_map_of_string + ) if map_of_enum_string is not None: - self.map_of_enum_string = map_of_enum_string # noqa: E501 + self.map_of_enum_string = ( + map_of_enum_string + ) if direct_map is not None: - self.direct_map = direct_map # noqa: E501 + self.direct_map = ( + direct_map + ) if indirect_map is not None: - self.indirect_map = indirect_map # noqa: E501 + self.indirect_map = ( + indirect_map + ) @property def map_map_of_string(self): @@ -82,9 +109,7 @@ def map_map_of_string(self): return self._map_map_of_string @map_map_of_string.setter - def map_map_of_string( - self, - map_map_of_string): + def map_map_of_string(self, map_map_of_string): # noqa: E501 """Sets the map_map_of_string of this MapTest. @@ -93,7 +118,8 @@ def map_map_of_string( """ self._map_map_of_string = ( - map_map_of_string) + map_map_of_string + ) @property def map_of_enum_string(self): @@ -106,25 +132,23 @@ def map_of_enum_string(self): return self._map_of_enum_string @map_of_enum_string.setter - def map_of_enum_string( - self, - map_of_enum_string): + def map_of_enum_string(self, map_of_enum_string): # noqa: E501 """Sets the map_of_enum_string of this MapTest. :param map_of_enum_string: The map_of_enum_string of this MapTest. # noqa: E501 :type: dict(str, str) """ - allowed_values = ["UPPER", "lower"] # noqa: E501 - if not set(map_of_enum_string.keys()).issubset(set(allowed_values)): - raise ValueError( - "Invalid keys in `map_of_enum_string` [{0}], must be a subset of [{1}]" # noqa: E501 - .format(", ".join(map(str, set(map_of_enum_string.keys()) - set(allowed_values))), # noqa: E501 - ", ".join(map(str, allowed_values))) - ) + check_allowed_values( + self.allowed_values, + ('map_of_enum_string',), + map_of_enum_string, + self.validations + ) self._map_of_enum_string = ( - map_of_enum_string) + map_of_enum_string + ) @property def direct_map(self): @@ -137,9 +161,7 @@ def direct_map(self): return self._direct_map @direct_map.setter - def direct_map( - self, - direct_map): + def direct_map(self, direct_map): # noqa: E501 """Sets the direct_map of this MapTest. @@ -148,7 +170,8 @@ def direct_map( """ self._direct_map = ( - direct_map) + direct_map + ) @property def indirect_map(self): @@ -156,23 +179,22 @@ def indirect_map(self): :return: The indirect_map of this MapTest. # noqa: E501 - :rtype: dict(str, bool) + :rtype: StringBooleanMap """ return self._indirect_map @indirect_map.setter - def indirect_map( - self, - indirect_map): + def indirect_map(self, indirect_map): # noqa: E501 """Sets the indirect_map of this MapTest. :param indirect_map: The indirect_map of this MapTest. # noqa: E501 - :type: dict(str, bool) + :type: StringBooleanMap """ self._indirect_map = ( - indirect_map) + indirect_map + ) def to_dict(self): """Returns the model properties as a dict""" 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 ac8d5626fbf7..670e5d9905ed 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,48 +10,64 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class MixedPropertiesAndAdditionalPropertiesClass(object): + +class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'uuid': 'str', - 'date_time': 'datetime', - 'map': 'dict(str, Animal)', + + allowed_values = { } attribute_map = { 'uuid': 'uuid', # noqa: E501 'date_time': 'dateTime', # noqa: E501 - 'map': 'map', # noqa: E501 + 'map': 'map' # noqa: E501 } - def __init__(self, uuid=None, date_time=None, map=None): # noqa: E501 - """MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI - + openapi_types = { + 'uuid': 'str', + 'date_time': 'datetime', + 'map': 'dict(str, Animal)' + } + validations = { + } - Keyword Args: - uuid (str): [optional] # noqa: E501 - date_time (datetime): [optional] # noqa: E501 - map (dict(str, Animal)): [optional] # noqa: E501 - """ + def __init__(self, uuid=None, date_time=None, map=None): # noqa: E501 + """MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI""" # noqa: E501 self._uuid = None self._date_time = None @@ -59,11 +75,17 @@ def __init__(self, uuid=None, date_time=None, map=None): # noqa: E501 self.discriminator = None if uuid is not None: - self.uuid = uuid # noqa: E501 + self.uuid = ( + uuid + ) if date_time is not None: - self.date_time = date_time # noqa: E501 + self.date_time = ( + date_time + ) if map is not None: - self.map = map # noqa: E501 + self.map = ( + map + ) @property def uuid(self): @@ -76,9 +98,7 @@ def uuid(self): return self._uuid @uuid.setter - def uuid( - self, - uuid): + def uuid(self, uuid): # noqa: E501 """Sets the uuid of this MixedPropertiesAndAdditionalPropertiesClass. @@ -87,7 +107,8 @@ def uuid( """ self._uuid = ( - uuid) + uuid + ) @property def date_time(self): @@ -100,9 +121,7 @@ def date_time(self): return self._date_time @date_time.setter - def date_time( - self, - date_time): + def date_time(self, date_time): # noqa: E501 """Sets the date_time of this MixedPropertiesAndAdditionalPropertiesClass. @@ -111,7 +130,8 @@ def date_time( """ self._date_time = ( - date_time) + date_time + ) @property def map(self): @@ -124,9 +144,7 @@ def map(self): return self._map @map.setter - def map( - self, - map): + def map(self, map): # noqa: E501 """Sets the map of this MixedPropertiesAndAdditionalPropertiesClass. @@ -135,7 +153,8 @@ def map( """ self._map = ( - map) + map + ) def to_dict(self): """Returns the model properties as a dict""" 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 cec843833ad1..f110d0208258 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,54 +10,75 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Model200Response(object): + +class Model200Response(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'int', - '_class': 'str', + + allowed_values = { } attribute_map = { 'name': 'name', # noqa: E501 - '_class': 'class', # noqa: E501 + '_class': 'class' # noqa: E501 } - def __init__(self, name=None, _class=None): # noqa: E501 - """Model200Response - a model defined in OpenAPI - + openapi_types = { + 'name': 'int', + '_class': 'str' + } + validations = { + } - Keyword Args: - name (int): [optional] # noqa: E501 - _class (str): [optional] # noqa: E501 - """ + def __init__(self, name=None, _class=None): # noqa: E501 + """Model200Response - a model defined in OpenAPI""" # noqa: E501 self._name = None self.__class = None self.discriminator = None if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) if _class is not None: - self._class = _class # noqa: E501 + self._class = ( + _class + ) @property def name(self): @@ -70,9 +91,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this Model200Response. @@ -81,7 +100,8 @@ def name( """ self._name = ( - name) + name + ) @property def _class(self): @@ -94,9 +114,7 @@ def _class(self): return self.__class @_class.setter - def _class( - self, - _class): + def _class(self, _class): # noqa: E501 """Sets the _class of this Model200Response. @@ -105,7 +123,8 @@ def _class( """ self.__class = ( - _class) + _class + ) def to_dict(self): """Returns the model properties as a dict""" 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 3c8096b7c458..0ba8ad99b99b 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class ModelReturn(object): + +class ModelReturn(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - '_return': 'int', + + allowed_values = { } attribute_map = { - '_return': 'return', # noqa: E501 + '_return': 'return' # noqa: E501 } - def __init__(self, _return=None): # noqa: E501 - """ModelReturn - a model defined in OpenAPI - + openapi_types = { + '_return': 'int' + } + validations = { + } - Keyword Args: - _return (int): [optional] # noqa: E501 - """ + def __init__(self, _return=None): # noqa: E501 + """ModelReturn - a model defined in OpenAPI""" # noqa: E501 self.__return = None self.discriminator = None if _return is not None: - self._return = _return # noqa: E501 + self._return = ( + _return + ) @property def _return(self): @@ -64,9 +84,7 @@ def _return(self): return self.__return @_return.setter - def _return( - self, - _return): + def _return(self, _return): # noqa: E501 """Sets the _return of this ModelReturn. @@ -75,7 +93,8 @@ def _return( """ self.__return = ( - _return) + _return + ) def to_dict(self): """Returns the model properties as a dict""" 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 9d1814c670f6..59c5429366d3 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/name.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/name.py @@ -10,51 +10,66 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Name(object): + +class Name(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'int', - 'snake_case': 'int', - '_property': 'str', - '_123_number': 'int', + + allowed_values = { } attribute_map = { 'name': 'name', # noqa: E501 'snake_case': 'snake_case', # noqa: E501 '_property': 'property', # noqa: E501 - '_123_number': '123Number', # noqa: E501 + '_123_number': '123Number' # noqa: E501 } - def __init__(self, name, snake_case=None, _property=None, _123_number=None): # noqa: E501 - """Name - a model defined in OpenAPI + openapi_types = { + 'name': 'int', + 'snake_case': 'int', + '_property': 'str', + '_123_number': 'int' + } - Args: - name (int): + validations = { + } - Keyword Args: # noqa: E501 - snake_case (int): [optional] # noqa: E501 - _property (str): [optional] # noqa: E501 - _123_number (int): [optional] # noqa: E501 - """ + def __init__(self, name=None, snake_case=None, _property=None, _123_number=None): # noqa: E501 + """Name - a model defined in OpenAPI""" # noqa: E501 self._name = None self._snake_case = None @@ -64,11 +79,17 @@ def __init__(self, name, snake_case=None, _property=None, _123_number=None): # self.name = name if snake_case is not None: - self.snake_case = snake_case # noqa: E501 + self.snake_case = ( + snake_case + ) if _property is not None: - self._property = _property # noqa: E501 + self._property = ( + _property + ) if _123_number is not None: - self._123_number = _123_number # noqa: E501 + self._123_number = ( + _123_number + ) @property def name(self): @@ -81,9 +102,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this Name. @@ -91,10 +110,11 @@ def name( :type: int """ if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = ( - name) + name + ) @property def snake_case(self): @@ -107,9 +127,7 @@ def snake_case(self): return self._snake_case @snake_case.setter - def snake_case( - self, - snake_case): + def snake_case(self, snake_case): # noqa: E501 """Sets the snake_case of this Name. @@ -118,7 +136,8 @@ def snake_case( """ self._snake_case = ( - snake_case) + snake_case + ) @property def _property(self): @@ -131,9 +150,7 @@ def _property(self): return self.__property @_property.setter - def _property( - self, - _property): + def _property(self, _property): # noqa: E501 """Sets the _property of this Name. @@ -142,7 +159,8 @@ def _property( """ self.__property = ( - _property) + _property + ) @property def _123_number(self): @@ -155,9 +173,7 @@ def _123_number(self): return self.__123_number @_123_number.setter - def _123_number( - self, - _123_number): + def _123_number(self, _123_number): # noqa: E501 """Sets the _123_number of this Name. @@ -166,7 +182,8 @@ def _123_number( """ self.__123_number = ( - _123_number) + _123_number + ) def to_dict(self): """Returns the model properties as a dict""" 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 70741767c495..cb7825618738 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class NumberOnly(object): + +class NumberOnly(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'just_number': 'float', + + allowed_values = { } attribute_map = { - 'just_number': 'JustNumber', # noqa: E501 + 'just_number': 'JustNumber' # noqa: E501 } - def __init__(self, just_number=None): # noqa: E501 - """NumberOnly - a model defined in OpenAPI - + openapi_types = { + 'just_number': 'float' + } + validations = { + } - Keyword Args: - just_number (float): [optional] # noqa: E501 - """ + def __init__(self, just_number=None): # noqa: E501 + """NumberOnly - a model defined in OpenAPI""" # noqa: E501 self._just_number = None self.discriminator = None if just_number is not None: - self.just_number = just_number # noqa: E501 + self.just_number = ( + just_number + ) @property def just_number(self): @@ -64,9 +84,7 @@ def just_number(self): return self._just_number @just_number.setter - def just_number( - self, - just_number): + def just_number(self, just_number): # noqa: E501 """Sets the just_number of this NumberOnly. @@ -75,7 +93,8 @@ def just_number( """ self._just_number = ( - just_number) + just_number + ) def to_dict(self): """Returns the model properties as a dict""" 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 f1c8220033c2..7b866df4c894 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/order.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/order.py @@ -10,33 +10,50 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Order(object): + +class Order(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'id': 'int', - 'pet_id': 'int', - 'quantity': 'int', - 'ship_date': 'datetime', - 'status': 'str', - 'complete': 'bool', + + allowed_values = { + ('status',): { + 'PLACED': "placed", + 'APPROVED': "approved", + 'DELIVERED': "delivered" + }, } attribute_map = { @@ -45,22 +62,23 @@ class Order(object): 'quantity': 'quantity', # noqa: E501 'ship_date': 'shipDate', # noqa: E501 'status': 'status', # noqa: E501 - 'complete': 'complete', # noqa: E501 + 'complete': 'complete' # noqa: E501 } - def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=None): # noqa: E501 - """Order - a model defined in OpenAPI - + openapi_types = { + 'id': 'int', + 'pet_id': 'int', + 'quantity': 'int', + 'ship_date': 'datetime', + 'status': 'str', + 'complete': 'bool' + } + validations = { + } - Keyword Args: - id (int): [optional] # noqa: E501 - pet_id (int): [optional] # noqa: E501 - quantity (int): [optional] # noqa: E501 - ship_date (datetime): [optional] # noqa: E501 - status (str): Order Status. [optional] # noqa: E501 - complete (bool): [optional] if omitted the server will use the default value of False # noqa: E501 - """ + def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False): # noqa: E501 + """Order - a model defined in OpenAPI""" # noqa: E501 self._id = None self._pet_id = None @@ -71,17 +89,29 @@ def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=N self.discriminator = None if id is not None: - self.id = id # noqa: E501 + self.id = ( + id + ) if pet_id is not None: - self.pet_id = pet_id # noqa: E501 + self.pet_id = ( + pet_id + ) if quantity is not None: - self.quantity = quantity # noqa: E501 + self.quantity = ( + quantity + ) if ship_date is not None: - self.ship_date = ship_date # noqa: E501 + self.ship_date = ( + ship_date + ) if status is not None: - self.status = status # noqa: E501 + self.status = ( + status + ) if complete is not None: - self.complete = complete # noqa: E501 + self.complete = ( + complete + ) @property def id(self): @@ -94,9 +124,7 @@ def id(self): return self._id @id.setter - def id( - self, - id): + def id(self, id): # noqa: E501 """Sets the id of this Order. @@ -105,7 +133,8 @@ def id( """ self._id = ( - id) + id + ) @property def pet_id(self): @@ -118,9 +147,7 @@ def pet_id(self): return self._pet_id @pet_id.setter - def pet_id( - self, - pet_id): + def pet_id(self, pet_id): # noqa: E501 """Sets the pet_id of this Order. @@ -129,7 +156,8 @@ def pet_id( """ self._pet_id = ( - pet_id) + pet_id + ) @property def quantity(self): @@ -142,9 +170,7 @@ def quantity(self): return self._quantity @quantity.setter - def quantity( - self, - quantity): + def quantity(self, quantity): # noqa: E501 """Sets the quantity of this Order. @@ -153,7 +179,8 @@ def quantity( """ self._quantity = ( - quantity) + quantity + ) @property def ship_date(self): @@ -166,9 +193,7 @@ def ship_date(self): return self._ship_date @ship_date.setter - def ship_date( - self, - ship_date): + def ship_date(self, ship_date): # noqa: E501 """Sets the ship_date of this Order. @@ -177,7 +202,8 @@ def ship_date( """ self._ship_date = ( - ship_date) + ship_date + ) @property def status(self): @@ -191,9 +217,7 @@ def status(self): return self._status @status.setter - def status( - self, - status): + def status(self, status): # noqa: E501 """Sets the status of this Order. Order Status # noqa: E501 @@ -201,15 +225,16 @@ def status( :param status: The status of this Order. # noqa: E501 :type: str """ - allowed_values = ["placed", "approved", "delivered"] # noqa: E501 - if status not in allowed_values: - raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) - ) + check_allowed_values( + self.allowed_values, + ('status',), + status, + self.validations + ) self._status = ( - status) + status + ) @property def complete(self): @@ -222,9 +247,7 @@ def complete(self): return self._complete @complete.setter - def complete( - self, - complete): + def complete(self, complete): # noqa: E501 """Sets the complete of this Order. @@ -233,7 +256,8 @@ def complete( """ self._complete = ( - complete) + complete + ) def to_dict(self): """Returns the model properties as a dict""" 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 f3887c8a3267..70c9e7915fb0 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,48 +10,64 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class OuterComposite(object): + +class OuterComposite(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'my_number': 'float', - 'my_string': 'str', - 'my_boolean': 'bool', + + allowed_values = { } attribute_map = { 'my_number': 'my_number', # noqa: E501 'my_string': 'my_string', # noqa: E501 - 'my_boolean': 'my_boolean', # noqa: E501 + 'my_boolean': 'my_boolean' # noqa: E501 } - def __init__(self, my_number=None, my_string=None, my_boolean=None): # noqa: E501 - """OuterComposite - a model defined in OpenAPI - + openapi_types = { + 'my_number': 'OuterNumber', + 'my_string': 'str', + 'my_boolean': 'bool' + } + validations = { + } - Keyword Args: - my_number (float): [optional] # noqa: E501 - my_string (str): [optional] # noqa: E501 - my_boolean (bool): [optional] # noqa: E501 - """ + def __init__(self, my_number=None, my_string=None, my_boolean=None): # noqa: E501 + """OuterComposite - a model defined in OpenAPI""" # noqa: E501 self._my_number = None self._my_string = None @@ -59,11 +75,17 @@ def __init__(self, my_number=None, my_string=None, my_boolean=None): # noqa: E5 self.discriminator = None if my_number is not None: - self.my_number = my_number # noqa: E501 + self.my_number = ( + my_number + ) if my_string is not None: - self.my_string = my_string # noqa: E501 + self.my_string = ( + my_string + ) if my_boolean is not None: - self.my_boolean = my_boolean # noqa: E501 + self.my_boolean = ( + my_boolean + ) @property def my_number(self): @@ -71,23 +93,22 @@ def my_number(self): :return: The my_number of this OuterComposite. # noqa: E501 - :rtype: float + :rtype: OuterNumber """ return self._my_number @my_number.setter - def my_number( - self, - my_number): + def my_number(self, my_number): # noqa: E501 """Sets the my_number of this OuterComposite. :param my_number: The my_number of this OuterComposite. # noqa: E501 - :type: float + :type: OuterNumber """ self._my_number = ( - my_number) + my_number + ) @property def my_string(self): @@ -100,9 +121,7 @@ def my_string(self): return self._my_string @my_string.setter - def my_string( - self, - my_string): + def my_string(self, my_string): # noqa: E501 """Sets the my_string of this OuterComposite. @@ -111,7 +130,8 @@ def my_string( """ self._my_string = ( - my_string) + my_string + ) @property def my_boolean(self): @@ -124,9 +144,7 @@ def my_boolean(self): return self._my_boolean @my_boolean.setter - def my_boolean( - self, - my_boolean): + def my_boolean(self, my_boolean): # noqa: E501 """Sets the my_boolean of this OuterComposite. @@ -135,7 +153,8 @@ def my_boolean( """ self._my_boolean = ( - my_boolean) + my_boolean + ) def to_dict(self): """Returns the model properties as a dict""" 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 d042dbe3ceba..d9cdd3d0c602 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,75 +10,97 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class OuterEnum(object): + +class OuterEnum(ModelSimple): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - - """ - allowed enum values - """ - PLACED = "placed" - APPROVED = "approved" - DELIVERED = "delivered" - """ 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. openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. + 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. """ + + allowed_values = { + ('value',): { + 'PLACED': "placed", + 'APPROVED': "approved", + 'DELIVERED': "delivered" + }, + } + openapi_types = { + 'value': 'str' } - attribute_map = { + validations = { } - def __init__(self): # noqa: E501 - """OuterEnum - a model defined in OpenAPI + def __init__(self, value=None): # noqa: E501 + """OuterEnum - a model defined in OpenAPI""" # noqa: E501 + + self._value = None + self.discriminator = None + + self.value = value + @property + def value(self): + """Gets the value of this OuterEnum. # noqa: E501 - Keyword Args: + :return: The value of this OuterEnum. # noqa: E501 + :rtype: str """ - self.discriminator = None + return self._value + + @value.setter + def value(self, value): # noqa: E501 + """Sets the value of this OuterEnum. - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result + + :param value: The value of this OuterEnum. # noqa: E501 + :type: str + """ + if value is None: + raise ApiValueError("Invalid value for `value`, must not be `None`") # noqa: E501 + check_allowed_values( + self.allowed_values, + ('value',), + value, + self.validations + ) + + self._value = ( + value + ) def to_str(self): """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) + return str(self._value) def __repr__(self): """For `print` and `pprint`""" 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 new file mode 100644 index 000000000000..36c2bd3da192 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/outer_number.py @@ -0,0 +1,117 @@ +# 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 +""" + + +import pprint # noqa: F401 +import re # noqa: F401 + +import six # noqa: F401 + +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) + + +class OuterNumber(ModelSimple): + """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. + 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. + """ + + allowed_values = { + } + + openapi_types = { + 'value': 'float' + } + + validations = { + ('value',): { + + 'inclusive_maximum': 2E+1, + 'inclusive_minimum': 1E+1, + }, + } + + def __init__(self, value=None): # noqa: E501 + """OuterNumber - a model defined in OpenAPI""" # noqa: E501 + + self._value = None + self.discriminator = None + + self.value = value + + @property + def value(self): + """Gets the value of this OuterNumber. # noqa: E501 + + + :return: The value of this OuterNumber. # noqa: E501 + :rtype: float + """ + return self._value + + @value.setter + def value(self, value): # noqa: E501 + """Sets the value of this OuterNumber. + + + :param value: The value of this OuterNumber. # noqa: E501 + :type: float + """ + if value is None: + raise ApiValueError("Invalid value for `value`, must not be `None`") # noqa: E501 + check_validations( + self.validations, + ('value',), + value + ) + + self._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 + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other 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 a3b12d20c6ca..07db65229314 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/pet.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/pet.py @@ -10,57 +10,75 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Pet(object): + +class Pet(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'name': 'str', - 'photo_urls': 'list[str]', - 'id': 'int', - 'category': 'Category', - 'tags': 'list[Tag]', - 'status': 'str', + + allowed_values = { + ('status',): { + 'AVAILABLE': "available", + 'PENDING': "pending", + 'SOLD': "sold" + }, } attribute_map = { - 'name': 'name', # noqa: E501 - 'photo_urls': 'photoUrls', # noqa: E501 '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 + 'status': 'status' # noqa: E501 } - def __init__(self, name, photo_urls, id=None, category=None, tags=None, status=None): # noqa: E501 - """Pet - a model defined in OpenAPI + openapi_types = { + 'id': 'int', + 'category': 'Category', + 'name': 'str', + 'photo_urls': 'list[str]', + 'tags': 'list[Tag]', + 'status': 'str' + } - Args: - name (str): - photo_urls (list[str]): + validations = { + } - Keyword Args: # noqa: E501 # noqa: E501 - id (int): [optional] # noqa: E501 - category (Category): [optional] # noqa: E501 - tags (list[Tag]): [optional] # noqa: E501 - status (str): pet status in the store. [optional] # noqa: E501 - """ + def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None): # noqa: E501 + """Pet - a model defined in OpenAPI""" # noqa: E501 self._id = None self._category = None @@ -71,15 +89,23 @@ def __init__(self, name, photo_urls, id=None, category=None, tags=None, status=N self.discriminator = None if id is not None: - self.id = id # noqa: E501 + self.id = ( + id + ) if category is not None: - self.category = category # noqa: E501 + self.category = ( + category + ) self.name = name self.photo_urls = photo_urls if tags is not None: - self.tags = tags # noqa: E501 + self.tags = ( + tags + ) if status is not None: - self.status = status # noqa: E501 + self.status = ( + status + ) @property def id(self): @@ -92,9 +118,7 @@ def id(self): return self._id @id.setter - def id( - self, - id): + def id(self, id): # noqa: E501 """Sets the id of this Pet. @@ -103,7 +127,8 @@ def id( """ self._id = ( - id) + id + ) @property def category(self): @@ -116,9 +141,7 @@ def category(self): return self._category @category.setter - def category( - self, - category): + def category(self, category): # noqa: E501 """Sets the category of this Pet. @@ -127,7 +150,8 @@ def category( """ self._category = ( - category) + category + ) @property def name(self): @@ -140,9 +164,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this Pet. @@ -150,10 +172,11 @@ def name( :type: str """ if name is None: - raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = ( - name) + name + ) @property def photo_urls(self): @@ -166,9 +189,7 @@ def photo_urls(self): return self._photo_urls @photo_urls.setter - def photo_urls( - self, - photo_urls): + def photo_urls(self, photo_urls): # noqa: E501 """Sets the photo_urls of this Pet. @@ -176,10 +197,11 @@ def photo_urls( :type: list[str] """ if photo_urls is None: - raise ValueError("Invalid value for `photo_urls`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `photo_urls`, must not be `None`") # noqa: E501 self._photo_urls = ( - photo_urls) + photo_urls + ) @property def tags(self): @@ -192,9 +214,7 @@ def tags(self): return self._tags @tags.setter - def tags( - self, - tags): + def tags(self, tags): # noqa: E501 """Sets the tags of this Pet. @@ -203,7 +223,8 @@ def tags( """ self._tags = ( - tags) + tags + ) @property def status(self): @@ -217,9 +238,7 @@ def status(self): return self._status @status.setter - def status( - self, - status): + def status(self, status): # noqa: E501 """Sets the status of this Pet. pet status in the store # noqa: E501 @@ -227,15 +246,16 @@ def status( :param status: The status of this Pet. # noqa: E501 :type: str """ - allowed_values = ["available", "pending", "sold"] # noqa: E501 - if status not in allowed_values: - raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) - ) + check_allowed_values( + self.allowed_values, + ('status',), + status, + self.validations + ) self._status = ( - status) + status + ) def to_dict(self): """Returns the model properties as a dict""" 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 93f2be298612..96d93afbd2b6 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,54 +10,75 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class ReadOnlyFirst(object): + +class ReadOnlyFirst(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'bar': 'str', - 'baz': 'str', + + allowed_values = { } attribute_map = { 'bar': 'bar', # noqa: E501 - 'baz': 'baz', # noqa: E501 + 'baz': 'baz' # noqa: E501 } - def __init__(self, bar=None, baz=None): # noqa: E501 - """ReadOnlyFirst - a model defined in OpenAPI - + openapi_types = { + 'bar': 'str', + 'baz': 'str' + } + validations = { + } - Keyword Args: - bar (str): [optional] # noqa: E501 - baz (str): [optional] # noqa: E501 - """ + def __init__(self, bar=None, baz=None): # noqa: E501 + """ReadOnlyFirst - a model defined in OpenAPI""" # noqa: E501 self._bar = None self._baz = None self.discriminator = None if bar is not None: - self.bar = bar # noqa: E501 + self.bar = ( + bar + ) if baz is not None: - self.baz = baz # noqa: E501 + self.baz = ( + baz + ) @property def bar(self): @@ -70,9 +91,7 @@ def bar(self): return self._bar @bar.setter - def bar( - self, - bar): + def bar(self, bar): # noqa: E501 """Sets the bar of this ReadOnlyFirst. @@ -81,7 +100,8 @@ def bar( """ self._bar = ( - bar) + bar + ) @property def baz(self): @@ -94,9 +114,7 @@ def baz(self): return self._baz @baz.setter - def baz( - self, - baz): + def baz(self, baz): # noqa: E501 """Sets the baz of this ReadOnlyFirst. @@ -105,7 +123,8 @@ def baz( """ self._baz = ( - baz) + baz + ) def to_dict(self): """Returns the model properties as a dict""" 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 9eb9757a1d22..83ab1e65054a 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,48 +10,68 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class SpecialModelName(object): + +class SpecialModelName(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'special_property_name': 'int', + + allowed_values = { } attribute_map = { - 'special_property_name': '$special[property.name]', # noqa: E501 + 'special_property_name': '$special[property.name]' # noqa: E501 } - def __init__(self, special_property_name=None): # noqa: E501 - """SpecialModelName - a model defined in OpenAPI - + openapi_types = { + 'special_property_name': 'int' + } + validations = { + } - Keyword Args: - special_property_name (int): [optional] # noqa: E501 - """ + def __init__(self, special_property_name=None): # noqa: E501 + """SpecialModelName - a model defined in OpenAPI""" # noqa: E501 self._special_property_name = None self.discriminator = None if special_property_name is not None: - self.special_property_name = special_property_name # noqa: E501 + self.special_property_name = ( + special_property_name + ) @property def special_property_name(self): @@ -64,9 +84,7 @@ def special_property_name(self): return self._special_property_name @special_property_name.setter - def special_property_name( - self, - special_property_name): + def special_property_name(self, special_property_name): # noqa: E501 """Sets the special_property_name of this SpecialModelName. @@ -75,7 +93,8 @@ def special_property_name( """ self._special_property_name = ( - special_property_name) + special_property_name + ) def to_dict(self): """Returns the model properties as a dict""" 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 new file mode 100644 index 000000000000..01427c702be3 --- /dev/null +++ b/samples/client/petstore/python-experimental/petstore_api/models/string_boolean_map.py @@ -0,0 +1,108 @@ +# 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 +""" + + +import pprint # noqa: F401 +import re # noqa: F401 + +import six # noqa: F401 + +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) + + +class StringBooleanMap(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. + """ + + allowed_values = { + } + + attribute_map = { + } + + openapi_types = { + } + + validations = { + } + + def __init__(self): # noqa: E501 + """StringBooleanMap - a model defined in OpenAPI""" # noqa: E501 + self.discriminator = None + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + 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 + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other 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 2fbb5adb76bf..f5e08704a007 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/tag.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/tag.py @@ -10,54 +10,75 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class Tag(object): + +class Tag(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'id': 'int', - 'name': 'str', + + allowed_values = { } attribute_map = { 'id': 'id', # noqa: E501 - 'name': 'name', # noqa: E501 + 'name': 'name' # noqa: E501 } - def __init__(self, id=None, name=None): # noqa: E501 - """Tag - a model defined in OpenAPI - + openapi_types = { + 'id': 'int', + 'name': 'str' + } + validations = { + } - Keyword Args: - id (int): [optional] # noqa: E501 - name (str): [optional] # noqa: E501 - """ + def __init__(self, id=None, name=None): # noqa: E501 + """Tag - a model defined in OpenAPI""" # noqa: E501 self._id = None self._name = None self.discriminator = None if id is not None: - self.id = id # noqa: E501 + self.id = ( + id + ) if name is not None: - self.name = name # noqa: E501 + self.name = ( + name + ) @property def id(self): @@ -70,9 +91,7 @@ def id(self): return self._id @id.setter - def id( - self, - id): + def id(self, id): # noqa: E501 """Sets the id of this Tag. @@ -81,7 +100,8 @@ def id( """ self._id = ( - id) + id + ) @property def name(self): @@ -94,9 +114,7 @@ def name(self): return self._name @name.setter - def name( - self, - name): + def name(self, name): # noqa: E501 """Sets the name of this Tag. @@ -105,7 +123,8 @@ def name( """ self._name = ( - name) + name + ) def to_dict(self): """Returns the model properties as a dict""" 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 08d1ac6432b1..a27e05e14d21 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,34 +10,45 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class TypeHolderDefault(object): + +class TypeHolderDefault(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'string_item': 'str', - 'number_item': 'float', - 'integer_item': 'int', - 'bool_item': 'bool', - 'array_item': 'list[int]', - 'date_item': 'date', - 'datetime_item': 'datetime', + + allowed_values = { } attribute_map = { @@ -45,25 +56,26 @@ class TypeHolderDefault(object): '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 + 'array_item': 'array_item' # noqa: E501 } - def __init__(self, array_item, string_item='what', number_item=1.234, integer_item=-2, bool_item=True, date_item=None, datetime_item=None): # noqa: E501 - """TypeHolderDefault - a model defined in OpenAPI + openapi_types = { + 'string_item': 'str', + 'number_item': 'float', + 'integer_item': 'int', + 'bool_item': 'bool', + 'date_item': 'date', + 'datetime_item': 'datetime', + 'array_item': 'list[int]' + } - Args: - array_item (list[int]): + validations = { + } - Keyword Args: - string_item (str): defaults to 'what', must be one of ['what'] # noqa: E501 - number_item (float): defaults to 1.234, must be one of [1.234] # noqa: E501 - integer_item (int): defaults to -2, must be one of [-2] # noqa: E501 - bool_item (bool): defaults to True, must be one of [True] # noqa: E501 # noqa: E501 - date_item (date): [optional] # noqa: E501 - datetime_item (datetime): [optional] # noqa: E501 - """ + def __init__(self, string_item='what', number_item=1.234, integer_item=-2, bool_item=True, date_item=None, datetime_item=None, array_item=None): # noqa: E501 + """TypeHolderDefault - a model defined in OpenAPI""" # noqa: E501 self._string_item = None self._number_item = None @@ -79,9 +91,13 @@ def __init__(self, array_item, string_item='what', number_item=1.234, integer_it self.integer_item = integer_item self.bool_item = bool_item if date_item is not None: - self.date_item = date_item # noqa: E501 + self.date_item = ( + date_item + ) if datetime_item is not None: - self.datetime_item = datetime_item # noqa: E501 + self.datetime_item = ( + datetime_item + ) self.array_item = array_item @property @@ -95,9 +111,7 @@ def string_item(self): return self._string_item @string_item.setter - def string_item( - self, - string_item): + def string_item(self, string_item): # noqa: E501 """Sets the string_item of this TypeHolderDefault. @@ -105,10 +119,11 @@ def string_item( :type: str """ if string_item is None: - raise ValueError("Invalid value for `string_item`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `string_item`, must not be `None`") # noqa: E501 self._string_item = ( - string_item) + string_item + ) @property def number_item(self): @@ -121,9 +136,7 @@ def number_item(self): return self._number_item @number_item.setter - def number_item( - self, - number_item): + def number_item(self, number_item): # noqa: E501 """Sets the number_item of this TypeHolderDefault. @@ -131,10 +144,11 @@ def number_item( :type: float """ if number_item is None: - raise ValueError("Invalid value for `number_item`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `number_item`, must not be `None`") # noqa: E501 self._number_item = ( - number_item) + number_item + ) @property def integer_item(self): @@ -147,9 +161,7 @@ def integer_item(self): return self._integer_item @integer_item.setter - def integer_item( - self, - integer_item): + def integer_item(self, integer_item): # noqa: E501 """Sets the integer_item of this TypeHolderDefault. @@ -157,10 +169,11 @@ def integer_item( :type: int """ if integer_item is None: - raise ValueError("Invalid value for `integer_item`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `integer_item`, must not be `None`") # noqa: E501 self._integer_item = ( - integer_item) + integer_item + ) @property def bool_item(self): @@ -173,9 +186,7 @@ def bool_item(self): return self._bool_item @bool_item.setter - def bool_item( - self, - bool_item): + def bool_item(self, bool_item): # noqa: E501 """Sets the bool_item of this TypeHolderDefault. @@ -183,10 +194,11 @@ def bool_item( :type: bool """ if bool_item is None: - raise ValueError("Invalid value for `bool_item`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `bool_item`, must not be `None`") # noqa: E501 self._bool_item = ( - bool_item) + bool_item + ) @property def date_item(self): @@ -199,9 +211,7 @@ def date_item(self): return self._date_item @date_item.setter - def date_item( - self, - date_item): + def date_item(self, date_item): # noqa: E501 """Sets the date_item of this TypeHolderDefault. @@ -210,7 +220,8 @@ def date_item( """ self._date_item = ( - date_item) + date_item + ) @property def datetime_item(self): @@ -223,9 +234,7 @@ def datetime_item(self): return self._datetime_item @datetime_item.setter - def datetime_item( - self, - datetime_item): + def datetime_item(self, datetime_item): # noqa: E501 """Sets the datetime_item of this TypeHolderDefault. @@ -234,7 +243,8 @@ def datetime_item( """ self._datetime_item = ( - datetime_item) + datetime_item + ) @property def array_item(self): @@ -247,9 +257,7 @@ def array_item(self): return self._array_item @array_item.setter - def array_item( - self, - array_item): + def array_item(self, array_item): # noqa: E501 """Sets the array_item of this TypeHolderDefault. @@ -257,10 +265,11 @@ def array_item( :type: list[int] """ if array_item is None: - raise ValueError("Invalid value for `array_item`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `array_item`, must not be `None`") # noqa: E501 self._array_item = ( - array_item) + array_item + ) def to_dict(self): """Returns the model properties as a dict""" 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 96620b8b5491..661bb21a3805 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,32 +10,54 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class TypeHolderExample(object): + +class TypeHolderExample(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'string_item': 'str', - 'number_item': 'float', - 'integer_item': 'int', - 'bool_item': 'bool', - 'array_item': 'list[int]', + + allowed_values = { + ('string_item',): { + 'WHAT': "what" + }, + ('number_item',): { + '1.234': 1.234 + }, + ('integer_item',): { + '-2': -2 + }, } attribute_map = { @@ -43,21 +65,22 @@ class TypeHolderExample(object): 'number_item': 'number_item', # noqa: E501 'integer_item': 'integer_item', # noqa: E501 'bool_item': 'bool_item', # noqa: E501 - 'array_item': 'array_item', # noqa: E501 + 'array_item': 'array_item' # noqa: E501 } - def __init__(self, bool_item, array_item, string_item='what', number_item=1.234, integer_item=-2): # noqa: E501 - """TypeHolderExample - a model defined in OpenAPI + openapi_types = { + 'string_item': 'str', + 'number_item': 'float', + 'integer_item': 'int', + 'bool_item': 'bool', + 'array_item': 'list[int]' + } - Args: - bool_item (bool): - array_item (list[int]): + validations = { + } - Keyword Args: - string_item (str): defaults to 'what', must be one of ['what'] # noqa: E501 - number_item (float): defaults to 1.234, must be one of [1.234] # noqa: E501 - integer_item (int): defaults to -2, must be one of [-2] # noqa: E501 # noqa: E501 # noqa: E501 - """ + def __init__(self, string_item='what', number_item=1.234, integer_item=-2, bool_item=None, array_item=None): # noqa: E501 + """TypeHolderExample - a model defined in OpenAPI""" # noqa: E501 self._string_item = None self._number_item = None @@ -83,9 +106,7 @@ def string_item(self): return self._string_item @string_item.setter - def string_item( - self, - string_item): + def string_item(self, string_item): # noqa: E501 """Sets the string_item of this TypeHolderExample. @@ -93,16 +114,17 @@ def string_item( :type: str """ if string_item is None: - raise ValueError("Invalid value for `string_item`, must not be `None`") # noqa: E501 - allowed_values = ["what"] # noqa: E501 - if string_item not in allowed_values: - raise ValueError( - "Invalid value for `string_item` ({0}), must be one of {1}" # noqa: E501 - .format(string_item, allowed_values) - ) + raise ApiValueError("Invalid value for `string_item`, must not be `None`") # noqa: E501 + check_allowed_values( + self.allowed_values, + ('string_item',), + string_item, + self.validations + ) self._string_item = ( - string_item) + string_item + ) @property def number_item(self): @@ -115,9 +137,7 @@ def number_item(self): return self._number_item @number_item.setter - def number_item( - self, - number_item): + def number_item(self, number_item): # noqa: E501 """Sets the number_item of this TypeHolderExample. @@ -125,16 +145,17 @@ def number_item( :type: float """ if number_item is None: - raise ValueError("Invalid value for `number_item`, must not be `None`") # noqa: E501 - allowed_values = [1.234] # noqa: E501 - if number_item not in allowed_values: - raise ValueError( - "Invalid value for `number_item` ({0}), must be one of {1}" # noqa: E501 - .format(number_item, allowed_values) - ) + raise ApiValueError("Invalid value for `number_item`, must not be `None`") # noqa: E501 + check_allowed_values( + self.allowed_values, + ('number_item',), + number_item, + self.validations + ) self._number_item = ( - number_item) + number_item + ) @property def integer_item(self): @@ -147,9 +168,7 @@ def integer_item(self): return self._integer_item @integer_item.setter - def integer_item( - self, - integer_item): + def integer_item(self, integer_item): # noqa: E501 """Sets the integer_item of this TypeHolderExample. @@ -157,16 +176,17 @@ def integer_item( :type: int """ if integer_item is None: - raise ValueError("Invalid value for `integer_item`, must not be `None`") # noqa: E501 - allowed_values = [-2] # noqa: E501 - if integer_item not in allowed_values: - raise ValueError( - "Invalid value for `integer_item` ({0}), must be one of {1}" # noqa: E501 - .format(integer_item, allowed_values) - ) + raise ApiValueError("Invalid value for `integer_item`, must not be `None`") # noqa: E501 + check_allowed_values( + self.allowed_values, + ('integer_item',), + integer_item, + self.validations + ) self._integer_item = ( - integer_item) + integer_item + ) @property def bool_item(self): @@ -179,9 +199,7 @@ def bool_item(self): return self._bool_item @bool_item.setter - def bool_item( - self, - bool_item): + def bool_item(self, bool_item): # noqa: E501 """Sets the bool_item of this TypeHolderExample. @@ -189,10 +207,11 @@ def bool_item( :type: bool """ if bool_item is None: - raise ValueError("Invalid value for `bool_item`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `bool_item`, must not be `None`") # noqa: E501 self._bool_item = ( - bool_item) + bool_item + ) @property def array_item(self): @@ -205,9 +224,7 @@ def array_item(self): return self._array_item @array_item.setter - def array_item( - self, - array_item): + def array_item(self, array_item): # noqa: E501 """Sets the array_item of this TypeHolderExample. @@ -215,10 +232,11 @@ def array_item( :type: list[int] """ if array_item is None: - raise ValueError("Invalid value for `array_item`, must not be `None`") # noqa: E501 + raise ApiValueError("Invalid value for `array_item`, must not be `None`") # noqa: E501 self._array_item = ( - array_item) + array_item + ) def to_dict(self): """Returns the model properties as a dict""" 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 382f0cc5fc50..1dcf8d755325 100644 --- a/samples/client/petstore/python-experimental/petstore_api/models/user.py +++ b/samples/client/petstore/python-experimental/petstore_api/models/user.py @@ -10,35 +10,45 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class User(object): + +class User(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'id': 'int', - 'username': 'str', - 'first_name': 'str', - 'last_name': 'str', - 'email': 'str', - 'password': 'str', - 'phone': 'str', - 'user_status': 'int', + + allowed_values = { } attribute_map = { @@ -49,24 +59,25 @@ class User(object): 'email': 'email', # noqa: E501 'password': 'password', # noqa: E501 'phone': 'phone', # noqa: E501 - 'user_status': 'userStatus', # noqa: E501 + 'user_status': 'userStatus' # noqa: E501 } - def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): # noqa: E501 - """User - a model defined in OpenAPI - + openapi_types = { + 'id': 'int', + 'username': 'str', + 'first_name': 'str', + 'last_name': 'str', + 'email': 'str', + 'password': 'str', + 'phone': 'str', + 'user_status': 'int' + } + validations = { + } - Keyword Args: - id (int): [optional] # noqa: E501 - username (str): [optional] # noqa: E501 - first_name (str): [optional] # noqa: E501 - last_name (str): [optional] # noqa: E501 - email (str): [optional] # noqa: E501 - password (str): [optional] # noqa: E501 - phone (str): [optional] # noqa: E501 - user_status (int): User Status. [optional] # noqa: E501 - """ + def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): # noqa: E501 + """User - a model defined in OpenAPI""" # noqa: E501 self._id = None self._username = None @@ -79,21 +90,37 @@ def __init__(self, id=None, username=None, first_name=None, last_name=None, emai self.discriminator = None if id is not None: - self.id = id # noqa: E501 + self.id = ( + id + ) if username is not None: - self.username = username # noqa: E501 + self.username = ( + username + ) if first_name is not None: - self.first_name = first_name # noqa: E501 + self.first_name = ( + first_name + ) if last_name is not None: - self.last_name = last_name # noqa: E501 + self.last_name = ( + last_name + ) if email is not None: - self.email = email # noqa: E501 + self.email = ( + email + ) if password is not None: - self.password = password # noqa: E501 + self.password = ( + password + ) if phone is not None: - self.phone = phone # noqa: E501 + self.phone = ( + phone + ) if user_status is not None: - self.user_status = user_status # noqa: E501 + self.user_status = ( + user_status + ) @property def id(self): @@ -106,9 +133,7 @@ def id(self): return self._id @id.setter - def id( - self, - id): + def id(self, id): # noqa: E501 """Sets the id of this User. @@ -117,7 +142,8 @@ def id( """ self._id = ( - id) + id + ) @property def username(self): @@ -130,9 +156,7 @@ def username(self): return self._username @username.setter - def username( - self, - username): + def username(self, username): # noqa: E501 """Sets the username of this User. @@ -141,7 +165,8 @@ def username( """ self._username = ( - username) + username + ) @property def first_name(self): @@ -154,9 +179,7 @@ def first_name(self): return self._first_name @first_name.setter - def first_name( - self, - first_name): + def first_name(self, first_name): # noqa: E501 """Sets the first_name of this User. @@ -165,7 +188,8 @@ def first_name( """ self._first_name = ( - first_name) + first_name + ) @property def last_name(self): @@ -178,9 +202,7 @@ def last_name(self): return self._last_name @last_name.setter - def last_name( - self, - last_name): + def last_name(self, last_name): # noqa: E501 """Sets the last_name of this User. @@ -189,7 +211,8 @@ def last_name( """ self._last_name = ( - last_name) + last_name + ) @property def email(self): @@ -202,9 +225,7 @@ def email(self): return self._email @email.setter - def email( - self, - email): + def email(self, email): # noqa: E501 """Sets the email of this User. @@ -213,7 +234,8 @@ def email( """ self._email = ( - email) + email + ) @property def password(self): @@ -226,9 +248,7 @@ def password(self): return self._password @password.setter - def password( - self, - password): + def password(self, password): # noqa: E501 """Sets the password of this User. @@ -237,7 +257,8 @@ def password( """ self._password = ( - password) + password + ) @property def phone(self): @@ -250,9 +271,7 @@ def phone(self): return self._phone @phone.setter - def phone( - self, - phone): + def phone(self, phone): # noqa: E501 """Sets the phone of this User. @@ -261,7 +280,8 @@ def phone( """ self._phone = ( - phone) + phone + ) @property def user_status(self): @@ -275,9 +295,7 @@ def user_status(self): return self._user_status @user_status.setter - def user_status( - self, - user_status): + def user_status(self, user_status): # noqa: E501 """Sets the user_status of this User. User Status # noqa: E501 @@ -287,7 +305,8 @@ def user_status( """ self._user_status = ( - user_status) + user_status + ) def to_dict(self): """Returns the model properties as a dict""" 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 4d9c57350be0..3657b04b1e6b 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,56 +10,45 @@ """ -import pprint +import pprint # noqa: F401 import re # noqa: F401 -import six +import six # noqa: F401 +from petstore_api.exceptions import ApiValueError # noqa: F401 +from petstore_api.model_utils import ( # noqa: F401 + ModelNormal, + ModelSimple, + check_allowed_values, + check_validations +) -class XmlItem(object): + +class XmlItem(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. - """ - """ Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. + 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. + 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. """ - openapi_types = { - 'attribute_string': 'str', - 'attribute_number': 'float', - 'attribute_integer': 'int', - 'attribute_boolean': 'bool', - 'wrapped_array': 'list[int]', - 'name_string': 'str', - 'name_number': 'float', - 'name_integer': 'int', - 'name_boolean': 'bool', - 'name_array': 'list[int]', - 'name_wrapped_array': 'list[int]', - 'prefix_string': 'str', - 'prefix_number': 'float', - 'prefix_integer': 'int', - 'prefix_boolean': 'bool', - 'prefix_array': 'list[int]', - 'prefix_wrapped_array': 'list[int]', - 'namespace_string': 'str', - 'namespace_number': 'float', - 'namespace_integer': 'int', - 'namespace_boolean': 'bool', - 'namespace_array': 'list[int]', - 'namespace_wrapped_array': 'list[int]', - 'prefix_ns_string': 'str', - 'prefix_ns_number': 'float', - 'prefix_ns_integer': 'int', - 'prefix_ns_boolean': 'bool', - 'prefix_ns_array': 'list[int]', - 'prefix_ns_wrapped_array': 'list[int]', + + allowed_values = { } attribute_map = { @@ -91,45 +80,46 @@ class XmlItem(object): '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 + 'prefix_ns_wrapped_array': 'prefix_ns_wrapped_array' # noqa: E501 + } + + openapi_types = { + 'attribute_string': 'str', + 'attribute_number': 'float', + 'attribute_integer': 'int', + 'attribute_boolean': 'bool', + 'wrapped_array': 'list[int]', + 'name_string': 'str', + 'name_number': 'float', + 'name_integer': 'int', + 'name_boolean': 'bool', + 'name_array': 'list[int]', + 'name_wrapped_array': 'list[int]', + 'prefix_string': 'str', + 'prefix_number': 'float', + 'prefix_integer': 'int', + 'prefix_boolean': 'bool', + 'prefix_array': 'list[int]', + 'prefix_wrapped_array': 'list[int]', + 'namespace_string': 'str', + 'namespace_number': 'float', + 'namespace_integer': 'int', + 'namespace_boolean': 'bool', + 'namespace_array': 'list[int]', + 'namespace_wrapped_array': 'list[int]', + 'prefix_ns_string': 'str', + 'prefix_ns_number': 'float', + 'prefix_ns_integer': 'int', + 'prefix_ns_boolean': 'bool', + 'prefix_ns_array': 'list[int]', + 'prefix_ns_wrapped_array': 'list[int]' + } + + validations = { } def __init__(self, attribute_string=None, attribute_number=None, attribute_integer=None, attribute_boolean=None, wrapped_array=None, name_string=None, name_number=None, name_integer=None, name_boolean=None, name_array=None, name_wrapped_array=None, prefix_string=None, prefix_number=None, prefix_integer=None, prefix_boolean=None, prefix_array=None, prefix_wrapped_array=None, namespace_string=None, namespace_number=None, namespace_integer=None, namespace_boolean=None, namespace_array=None, namespace_wrapped_array=None, prefix_ns_string=None, prefix_ns_number=None, prefix_ns_integer=None, prefix_ns_boolean=None, prefix_ns_array=None, prefix_ns_wrapped_array=None): # noqa: E501 - """XmlItem - a model defined in OpenAPI - - - - Keyword Args: - attribute_string (str): [optional] # noqa: E501 - attribute_number (float): [optional] # noqa: E501 - attribute_integer (int): [optional] # noqa: E501 - attribute_boolean (bool): [optional] # noqa: E501 - wrapped_array (list[int]): [optional] # noqa: E501 - name_string (str): [optional] # noqa: E501 - name_number (float): [optional] # noqa: E501 - name_integer (int): [optional] # noqa: E501 - name_boolean (bool): [optional] # noqa: E501 - name_array (list[int]): [optional] # noqa: E501 - name_wrapped_array (list[int]): [optional] # noqa: E501 - prefix_string (str): [optional] # noqa: E501 - prefix_number (float): [optional] # noqa: E501 - prefix_integer (int): [optional] # noqa: E501 - prefix_boolean (bool): [optional] # noqa: E501 - prefix_array (list[int]): [optional] # noqa: E501 - prefix_wrapped_array (list[int]): [optional] # noqa: E501 - namespace_string (str): [optional] # noqa: E501 - namespace_number (float): [optional] # noqa: E501 - namespace_integer (int): [optional] # noqa: E501 - namespace_boolean (bool): [optional] # noqa: E501 - namespace_array (list[int]): [optional] # noqa: E501 - namespace_wrapped_array (list[int]): [optional] # noqa: E501 - prefix_ns_string (str): [optional] # noqa: E501 - prefix_ns_number (float): [optional] # noqa: E501 - prefix_ns_integer (int): [optional] # noqa: E501 - prefix_ns_boolean (bool): [optional] # noqa: E501 - prefix_ns_array (list[int]): [optional] # noqa: E501 - prefix_ns_wrapped_array (list[int]): [optional] # noqa: E501 - """ + """XmlItem - a model defined in OpenAPI""" # noqa: E501 self._attribute_string = None self._attribute_number = None @@ -163,63 +153,121 @@ def __init__(self, attribute_string=None, attribute_number=None, attribute_integ self.discriminator = None if attribute_string is not None: - self.attribute_string = attribute_string # noqa: E501 + self.attribute_string = ( + attribute_string + ) if attribute_number is not None: - self.attribute_number = attribute_number # noqa: E501 + self.attribute_number = ( + attribute_number + ) if attribute_integer is not None: - self.attribute_integer = attribute_integer # noqa: E501 + self.attribute_integer = ( + attribute_integer + ) if attribute_boolean is not None: - self.attribute_boolean = attribute_boolean # noqa: E501 + self.attribute_boolean = ( + attribute_boolean + ) if wrapped_array is not None: - self.wrapped_array = wrapped_array # noqa: E501 + self.wrapped_array = ( + wrapped_array + ) if name_string is not None: - self.name_string = name_string # noqa: E501 + self.name_string = ( + name_string + ) if name_number is not None: - self.name_number = name_number # noqa: E501 + self.name_number = ( + name_number + ) if name_integer is not None: - self.name_integer = name_integer # noqa: E501 + self.name_integer = ( + name_integer + ) if name_boolean is not None: - self.name_boolean = name_boolean # noqa: E501 + self.name_boolean = ( + name_boolean + ) if name_array is not None: - self.name_array = name_array # noqa: E501 + self.name_array = ( + name_array + ) if name_wrapped_array is not None: - self.name_wrapped_array = name_wrapped_array # noqa: E501 + self.name_wrapped_array = ( + name_wrapped_array + ) if prefix_string is not None: - self.prefix_string = prefix_string # noqa: E501 + self.prefix_string = ( + prefix_string + ) if prefix_number is not None: - self.prefix_number = prefix_number # noqa: E501 + self.prefix_number = ( + prefix_number + ) if prefix_integer is not None: - self.prefix_integer = prefix_integer # noqa: E501 + self.prefix_integer = ( + prefix_integer + ) if prefix_boolean is not None: - self.prefix_boolean = prefix_boolean # noqa: E501 + self.prefix_boolean = ( + prefix_boolean + ) if prefix_array is not None: - self.prefix_array = prefix_array # noqa: E501 + self.prefix_array = ( + prefix_array + ) if prefix_wrapped_array is not None: - self.prefix_wrapped_array = prefix_wrapped_array # noqa: E501 + self.prefix_wrapped_array = ( + prefix_wrapped_array + ) if namespace_string is not None: - self.namespace_string = namespace_string # noqa: E501 + self.namespace_string = ( + namespace_string + ) if namespace_number is not None: - self.namespace_number = namespace_number # noqa: E501 + self.namespace_number = ( + namespace_number + ) if namespace_integer is not None: - self.namespace_integer = namespace_integer # noqa: E501 + self.namespace_integer = ( + namespace_integer + ) if namespace_boolean is not None: - self.namespace_boolean = namespace_boolean # noqa: E501 + self.namespace_boolean = ( + namespace_boolean + ) if namespace_array is not None: - self.namespace_array = namespace_array # noqa: E501 + self.namespace_array = ( + namespace_array + ) if namespace_wrapped_array is not None: - self.namespace_wrapped_array = namespace_wrapped_array # noqa: E501 + self.namespace_wrapped_array = ( + namespace_wrapped_array + ) if prefix_ns_string is not None: - self.prefix_ns_string = prefix_ns_string # noqa: E501 + self.prefix_ns_string = ( + prefix_ns_string + ) if prefix_ns_number is not None: - self.prefix_ns_number = prefix_ns_number # noqa: E501 + self.prefix_ns_number = ( + prefix_ns_number + ) if prefix_ns_integer is not None: - self.prefix_ns_integer = prefix_ns_integer # noqa: E501 + self.prefix_ns_integer = ( + prefix_ns_integer + ) if prefix_ns_boolean is not None: - self.prefix_ns_boolean = prefix_ns_boolean # noqa: E501 + self.prefix_ns_boolean = ( + prefix_ns_boolean + ) if prefix_ns_array is not None: - self.prefix_ns_array = prefix_ns_array # noqa: E501 + self.prefix_ns_array = ( + prefix_ns_array + ) if prefix_ns_wrapped_array is not None: - self.prefix_ns_wrapped_array = prefix_ns_wrapped_array # noqa: E501 + self.prefix_ns_wrapped_array = ( + prefix_ns_wrapped_array + ) @property def attribute_string(self): @@ -232,9 +280,7 @@ def attribute_string(self): return self._attribute_string @attribute_string.setter - def attribute_string( - self, - attribute_string): + def attribute_string(self, attribute_string): # noqa: E501 """Sets the attribute_string of this XmlItem. @@ -243,7 +289,8 @@ def attribute_string( """ self._attribute_string = ( - attribute_string) + attribute_string + ) @property def attribute_number(self): @@ -256,9 +303,7 @@ def attribute_number(self): return self._attribute_number @attribute_number.setter - def attribute_number( - self, - attribute_number): + def attribute_number(self, attribute_number): # noqa: E501 """Sets the attribute_number of this XmlItem. @@ -267,7 +312,8 @@ def attribute_number( """ self._attribute_number = ( - attribute_number) + attribute_number + ) @property def attribute_integer(self): @@ -280,9 +326,7 @@ def attribute_integer(self): return self._attribute_integer @attribute_integer.setter - def attribute_integer( - self, - attribute_integer): + def attribute_integer(self, attribute_integer): # noqa: E501 """Sets the attribute_integer of this XmlItem. @@ -291,7 +335,8 @@ def attribute_integer( """ self._attribute_integer = ( - attribute_integer) + attribute_integer + ) @property def attribute_boolean(self): @@ -304,9 +349,7 @@ def attribute_boolean(self): return self._attribute_boolean @attribute_boolean.setter - def attribute_boolean( - self, - attribute_boolean): + def attribute_boolean(self, attribute_boolean): # noqa: E501 """Sets the attribute_boolean of this XmlItem. @@ -315,7 +358,8 @@ def attribute_boolean( """ self._attribute_boolean = ( - attribute_boolean) + attribute_boolean + ) @property def wrapped_array(self): @@ -328,9 +372,7 @@ def wrapped_array(self): return self._wrapped_array @wrapped_array.setter - def wrapped_array( - self, - wrapped_array): + def wrapped_array(self, wrapped_array): # noqa: E501 """Sets the wrapped_array of this XmlItem. @@ -339,7 +381,8 @@ def wrapped_array( """ self._wrapped_array = ( - wrapped_array) + wrapped_array + ) @property def name_string(self): @@ -352,9 +395,7 @@ def name_string(self): return self._name_string @name_string.setter - def name_string( - self, - name_string): + def name_string(self, name_string): # noqa: E501 """Sets the name_string of this XmlItem. @@ -363,7 +404,8 @@ def name_string( """ self._name_string = ( - name_string) + name_string + ) @property def name_number(self): @@ -376,9 +418,7 @@ def name_number(self): return self._name_number @name_number.setter - def name_number( - self, - name_number): + def name_number(self, name_number): # noqa: E501 """Sets the name_number of this XmlItem. @@ -387,7 +427,8 @@ def name_number( """ self._name_number = ( - name_number) + name_number + ) @property def name_integer(self): @@ -400,9 +441,7 @@ def name_integer(self): return self._name_integer @name_integer.setter - def name_integer( - self, - name_integer): + def name_integer(self, name_integer): # noqa: E501 """Sets the name_integer of this XmlItem. @@ -411,7 +450,8 @@ def name_integer( """ self._name_integer = ( - name_integer) + name_integer + ) @property def name_boolean(self): @@ -424,9 +464,7 @@ def name_boolean(self): return self._name_boolean @name_boolean.setter - def name_boolean( - self, - name_boolean): + def name_boolean(self, name_boolean): # noqa: E501 """Sets the name_boolean of this XmlItem. @@ -435,7 +473,8 @@ def name_boolean( """ self._name_boolean = ( - name_boolean) + name_boolean + ) @property def name_array(self): @@ -448,9 +487,7 @@ def name_array(self): return self._name_array @name_array.setter - def name_array( - self, - name_array): + def name_array(self, name_array): # noqa: E501 """Sets the name_array of this XmlItem. @@ -459,7 +496,8 @@ def name_array( """ self._name_array = ( - name_array) + name_array + ) @property def name_wrapped_array(self): @@ -472,9 +510,7 @@ def name_wrapped_array(self): return self._name_wrapped_array @name_wrapped_array.setter - def name_wrapped_array( - self, - name_wrapped_array): + def name_wrapped_array(self, name_wrapped_array): # noqa: E501 """Sets the name_wrapped_array of this XmlItem. @@ -483,7 +519,8 @@ def name_wrapped_array( """ self._name_wrapped_array = ( - name_wrapped_array) + name_wrapped_array + ) @property def prefix_string(self): @@ -496,9 +533,7 @@ def prefix_string(self): return self._prefix_string @prefix_string.setter - def prefix_string( - self, - prefix_string): + def prefix_string(self, prefix_string): # noqa: E501 """Sets the prefix_string of this XmlItem. @@ -507,7 +542,8 @@ def prefix_string( """ self._prefix_string = ( - prefix_string) + prefix_string + ) @property def prefix_number(self): @@ -520,9 +556,7 @@ def prefix_number(self): return self._prefix_number @prefix_number.setter - def prefix_number( - self, - prefix_number): + def prefix_number(self, prefix_number): # noqa: E501 """Sets the prefix_number of this XmlItem. @@ -531,7 +565,8 @@ def prefix_number( """ self._prefix_number = ( - prefix_number) + prefix_number + ) @property def prefix_integer(self): @@ -544,9 +579,7 @@ def prefix_integer(self): return self._prefix_integer @prefix_integer.setter - def prefix_integer( - self, - prefix_integer): + def prefix_integer(self, prefix_integer): # noqa: E501 """Sets the prefix_integer of this XmlItem. @@ -555,7 +588,8 @@ def prefix_integer( """ self._prefix_integer = ( - prefix_integer) + prefix_integer + ) @property def prefix_boolean(self): @@ -568,9 +602,7 @@ def prefix_boolean(self): return self._prefix_boolean @prefix_boolean.setter - def prefix_boolean( - self, - prefix_boolean): + def prefix_boolean(self, prefix_boolean): # noqa: E501 """Sets the prefix_boolean of this XmlItem. @@ -579,7 +611,8 @@ def prefix_boolean( """ self._prefix_boolean = ( - prefix_boolean) + prefix_boolean + ) @property def prefix_array(self): @@ -592,9 +625,7 @@ def prefix_array(self): return self._prefix_array @prefix_array.setter - def prefix_array( - self, - prefix_array): + def prefix_array(self, prefix_array): # noqa: E501 """Sets the prefix_array of this XmlItem. @@ -603,7 +634,8 @@ def prefix_array( """ self._prefix_array = ( - prefix_array) + prefix_array + ) @property def prefix_wrapped_array(self): @@ -616,9 +648,7 @@ def prefix_wrapped_array(self): return self._prefix_wrapped_array @prefix_wrapped_array.setter - def prefix_wrapped_array( - self, - prefix_wrapped_array): + def prefix_wrapped_array(self, prefix_wrapped_array): # noqa: E501 """Sets the prefix_wrapped_array of this XmlItem. @@ -627,7 +657,8 @@ def prefix_wrapped_array( """ self._prefix_wrapped_array = ( - prefix_wrapped_array) + prefix_wrapped_array + ) @property def namespace_string(self): @@ -640,9 +671,7 @@ def namespace_string(self): return self._namespace_string @namespace_string.setter - def namespace_string( - self, - namespace_string): + def namespace_string(self, namespace_string): # noqa: E501 """Sets the namespace_string of this XmlItem. @@ -651,7 +680,8 @@ def namespace_string( """ self._namespace_string = ( - namespace_string) + namespace_string + ) @property def namespace_number(self): @@ -664,9 +694,7 @@ def namespace_number(self): return self._namespace_number @namespace_number.setter - def namespace_number( - self, - namespace_number): + def namespace_number(self, namespace_number): # noqa: E501 """Sets the namespace_number of this XmlItem. @@ -675,7 +703,8 @@ def namespace_number( """ self._namespace_number = ( - namespace_number) + namespace_number + ) @property def namespace_integer(self): @@ -688,9 +717,7 @@ def namespace_integer(self): return self._namespace_integer @namespace_integer.setter - def namespace_integer( - self, - namespace_integer): + def namespace_integer(self, namespace_integer): # noqa: E501 """Sets the namespace_integer of this XmlItem. @@ -699,7 +726,8 @@ def namespace_integer( """ self._namespace_integer = ( - namespace_integer) + namespace_integer + ) @property def namespace_boolean(self): @@ -712,9 +740,7 @@ def namespace_boolean(self): return self._namespace_boolean @namespace_boolean.setter - def namespace_boolean( - self, - namespace_boolean): + def namespace_boolean(self, namespace_boolean): # noqa: E501 """Sets the namespace_boolean of this XmlItem. @@ -723,7 +749,8 @@ def namespace_boolean( """ self._namespace_boolean = ( - namespace_boolean) + namespace_boolean + ) @property def namespace_array(self): @@ -736,9 +763,7 @@ def namespace_array(self): return self._namespace_array @namespace_array.setter - def namespace_array( - self, - namespace_array): + def namespace_array(self, namespace_array): # noqa: E501 """Sets the namespace_array of this XmlItem. @@ -747,7 +772,8 @@ def namespace_array( """ self._namespace_array = ( - namespace_array) + namespace_array + ) @property def namespace_wrapped_array(self): @@ -760,9 +786,7 @@ def namespace_wrapped_array(self): return self._namespace_wrapped_array @namespace_wrapped_array.setter - def namespace_wrapped_array( - self, - namespace_wrapped_array): + def namespace_wrapped_array(self, namespace_wrapped_array): # noqa: E501 """Sets the namespace_wrapped_array of this XmlItem. @@ -771,7 +795,8 @@ def namespace_wrapped_array( """ self._namespace_wrapped_array = ( - namespace_wrapped_array) + namespace_wrapped_array + ) @property def prefix_ns_string(self): @@ -784,9 +809,7 @@ def prefix_ns_string(self): return self._prefix_ns_string @prefix_ns_string.setter - def prefix_ns_string( - self, - prefix_ns_string): + def prefix_ns_string(self, prefix_ns_string): # noqa: E501 """Sets the prefix_ns_string of this XmlItem. @@ -795,7 +818,8 @@ def prefix_ns_string( """ self._prefix_ns_string = ( - prefix_ns_string) + prefix_ns_string + ) @property def prefix_ns_number(self): @@ -808,9 +832,7 @@ def prefix_ns_number(self): return self._prefix_ns_number @prefix_ns_number.setter - def prefix_ns_number( - self, - prefix_ns_number): + def prefix_ns_number(self, prefix_ns_number): # noqa: E501 """Sets the prefix_ns_number of this XmlItem. @@ -819,7 +841,8 @@ def prefix_ns_number( """ self._prefix_ns_number = ( - prefix_ns_number) + prefix_ns_number + ) @property def prefix_ns_integer(self): @@ -832,9 +855,7 @@ def prefix_ns_integer(self): return self._prefix_ns_integer @prefix_ns_integer.setter - def prefix_ns_integer( - self, - prefix_ns_integer): + def prefix_ns_integer(self, prefix_ns_integer): # noqa: E501 """Sets the prefix_ns_integer of this XmlItem. @@ -843,7 +864,8 @@ def prefix_ns_integer( """ self._prefix_ns_integer = ( - prefix_ns_integer) + prefix_ns_integer + ) @property def prefix_ns_boolean(self): @@ -856,9 +878,7 @@ def prefix_ns_boolean(self): return self._prefix_ns_boolean @prefix_ns_boolean.setter - def prefix_ns_boolean( - self, - prefix_ns_boolean): + def prefix_ns_boolean(self, prefix_ns_boolean): # noqa: E501 """Sets the prefix_ns_boolean of this XmlItem. @@ -867,7 +887,8 @@ def prefix_ns_boolean( """ self._prefix_ns_boolean = ( - prefix_ns_boolean) + prefix_ns_boolean + ) @property def prefix_ns_array(self): @@ -880,9 +901,7 @@ def prefix_ns_array(self): return self._prefix_ns_array @prefix_ns_array.setter - def prefix_ns_array( - self, - prefix_ns_array): + def prefix_ns_array(self, prefix_ns_array): # noqa: E501 """Sets the prefix_ns_array of this XmlItem. @@ -891,7 +910,8 @@ def prefix_ns_array( """ self._prefix_ns_array = ( - prefix_ns_array) + prefix_ns_array + ) @property def prefix_ns_wrapped_array(self): @@ -904,9 +924,7 @@ def prefix_ns_wrapped_array(self): return self._prefix_ns_wrapped_array @prefix_ns_wrapped_array.setter - def prefix_ns_wrapped_array( - self, - prefix_ns_wrapped_array): + def prefix_ns_wrapped_array(self, prefix_ns_wrapped_array): # noqa: E501 """Sets the prefix_ns_wrapped_array of this XmlItem. @@ -915,7 +933,8 @@ def prefix_ns_wrapped_array( """ self._prefix_ns_wrapped_array = ( - prefix_ns_wrapped_array) + prefix_ns_wrapped_array + ) def to_dict(self): """Returns the model properties as a dict""" diff --git a/samples/client/petstore/python-experimental/setup.py b/samples/client/petstore/python-experimental/setup.py index 86988b6d42e0..1d5e7c2915ef 100644 --- a/samples/client/petstore/python-experimental/setup.py +++ b/samples/client/petstore/python-experimental/setup.py @@ -31,7 +31,7 @@ url="", keywords=["OpenAPI", "OpenAPI-Generator", "OpenAPI Petstore"], install_requires=REQUIRES, - packages=find_packages(), + packages=find_packages(exclude=["test", "tests"]), include_package_data=True, long_description="""\ 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 diff --git a/samples/client/petstore/python-experimental/test/test_fake_api.py b/samples/client/petstore/python-experimental/test/test_fake_api.py index fc2cbef35f1c..e8877b915ec1 100644 --- a/samples/client/petstore/python-experimental/test/test_fake_api.py +++ b/samples/client/petstore/python-experimental/test/test_fake_api.py @@ -40,11 +40,23 @@ def test_fake_outer_composite_serialize(self): """ pass + def test_fake_outer_enum_serialize(self): + """Test case for fake_outer_enum_serialize + + """ + # verify that the input and output are type OuterEnum + endpoint = self.api.fake_outer_enum_serialize + assert endpoint.openapi_types['body'] == 'OuterEnum' + assert endpoint.settings['response_type'] == 'OuterEnum' + def test_fake_outer_number_serialize(self): """Test case for fake_outer_number_serialize """ - pass + # verify that the input and output are the correct type + endpoint = self.api.fake_outer_number_serialize + assert endpoint.openapi_types['body'] == 'OuterNumber' + assert endpoint.settings['response_type'] == 'OuterNumber' def test_fake_outer_string_serialize(self): """Test case for fake_outer_string_serialize @@ -70,14 +82,38 @@ def test_test_endpoint_parameters(self): Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # noqa: E501 """ - pass + # check that we can access the endpoint's validations + endpoint = self.api.test_endpoint_parameters + assert endpoint.validations[('number',)] == { + 'inclusive_maximum': 543.2, + 'inclusive_minimum': 32.1, + } + # make sure that an exception is thrown on an invalid value + keyword_args = dict( + number=544, # invalid + double=100, + pattern_without_delimiter="abc", + byte='sample string' + ) + with self.assertRaises(petstore_api.ApiValueError): + self.api.test_endpoint_parameters(**keyword_args) def test_test_enum_parameters(self): """Test case for test_enum_parameters To test enum parameters # noqa: E501 """ - pass + # check that we can access the endpoint's allowed_values + endpoint = self.api.test_enum_parameters + assert endpoint.allowed_values[('enum_query_string',)] == { + "_ABC": "_abc", + "-EFG": "-efg", + "(XYZ)": "(xyz)" + } + # make sure that an exception is thrown on an invalid value + keyword_args = dict(enum_query_string="bad value") + with self.assertRaises(petstore_api.ApiValueError): + self.api.test_enum_parameters(**keyword_args) def test_test_inline_additional_properties(self): """Test case for test_inline_additional_properties diff --git a/samples/client/petstore/python-experimental/test/test_format_test.py b/samples/client/petstore/python-experimental/test/test_format_test.py index 46707c77b708..ba20d7f811b8 100644 --- a/samples/client/petstore/python-experimental/test/test_format_test.py +++ b/samples/client/petstore/python-experimental/test/test_format_test.py @@ -2,9 +2,7 @@ """ 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 - OpenAPI spec version: 1.0.0 Generated by: https://openapi-generator.tech """ @@ -16,24 +14,139 @@ import petstore_api from petstore_api.models.format_test import FormatTest # noqa: E501 -from petstore_api.rest import ApiException +from petstore_api import ApiValueError class TestFormatTest(unittest.TestCase): """FormatTest unit test stubs""" def setUp(self): - pass + self.required_named_args = dict( + number=40.1, + byte='what', + date='2019-03-23', + password='rainbowtable' + ) + + def test_integer(self): + var_name = 'integer' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_int32(self): + var_name = 'int32' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_number(self): + var_name = 'number' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_float(self): + var_name = 'float' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_double(self): + var_name = 'double' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('inclusive_maximum', 1), ('inclusive_minimum', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(ApiValueError): + keyword_args[var_name] = validations[key] + adder + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + validations[key]) + + def test_password(self): + var_name = 'password' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + key_adder_pairs = [('max_length', 1), ('min_length', -1)] + for key, adder in key_adder_pairs: + # value outside the bounds throws an error + with self.assertRaises(ApiValueError): + keyword_args[var_name] = 'a'*(validations[key] + adder) + FormatTest(**keyword_args) + + # value inside the bounds works + keyword_args[var_name] = 'a'*validations[key] + assert (getattr(FormatTest(**keyword_args), var_name) == + 'a'*validations[key]) - def tearDown(self): - pass + def test_string(self): + var_name = 'string' + validations = FormatTest.validations[(var_name,)] + keyword_args = {} + keyword_args.update(self.required_named_args) + values_invalid = ['abc3', '1', '.', ' ', 'مرحبا', ''] + for value_invalid in values_invalid: + # invalid values throw exceptions + with self.assertRaises(ApiValueError): + keyword_args[var_name] = value_invalid + FormatTest(**keyword_args) - def testFormatTest(self): - """Test FormatTest""" - # FIXME: construct object with mandatory attributes with example values - # model = petstore_api.models.format_test.FormatTest() # noqa: E501 - pass + # valid value works + value_valid = 'abcdz' + keyword_args[var_name] = value_valid + assert getattr(FormatTest(**keyword_args), var_name) == value_valid if __name__ == '__main__': - unittest.main() + unittest.main() \ No newline at end of file diff --git a/samples/client/petstore/python-experimental/test/test_outer_enum.py b/samples/client/petstore/python-experimental/test/test_outer_enum.py index 472e36e16821..50bfff0869b7 100644 --- a/samples/client/petstore/python-experimental/test/test_outer_enum.py +++ b/samples/client/petstore/python-experimental/test/test_outer_enum.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 """ @@ -30,10 +30,18 @@ def tearDown(self): def testOuterEnum(self): """Test OuterEnum""" - # FIXME: construct object with mandatory attributes with example values - # model = petstore_api.models.outer_enum.OuterEnum() # noqa: E501 - pass - + # make sure that we can access its allowed_values + assert OuterEnum.allowed_values[('value',)] == { + 'PLACED': "placed", + 'APPROVED': "approved", + 'DELIVERED': "delivered" + } + # make sure that an exception is thrown on an invalid value + with self.assertRaises(petstore_api.ApiValueError): + OuterEnum('bad_value') + # make sure valid value works + valid_value = OuterEnum.allowed_values[('value',)]['PLACED'] + assert valid_value == OuterEnum(valid_value).value if __name__ == '__main__': unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_outer_number.py b/samples/client/petstore/python-experimental/test/test_outer_number.py new file mode 100644 index 000000000000..31c9c41755dc --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_outer_number.py @@ -0,0 +1,39 @@ +# 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 +from petstore_api.models.outer_number import OuterNumber # noqa: E501 +from petstore_api.rest import ApiException + + +class TestOuterNumber(unittest.TestCase): + """OuterNumber unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testOuterNumber(self): + """Test OuterNumber""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.models.outer_number.OuterNumber() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_string_boolean_map.py b/samples/client/petstore/python-experimental/test/test_string_boolean_map.py new file mode 100644 index 000000000000..31c1ebeec5db --- /dev/null +++ b/samples/client/petstore/python-experimental/test/test_string_boolean_map.py @@ -0,0 +1,39 @@ +# 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 +from petstore_api.models.string_boolean_map import StringBooleanMap # noqa: E501 +from petstore_api.rest import ApiException + + +class TestStringBooleanMap(unittest.TestCase): + """StringBooleanMap unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testStringBooleanMap(self): + """Test StringBooleanMap""" + # FIXME: construct object with mandatory attributes with example values + # model = petstore_api.models.string_boolean_map.StringBooleanMap() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/samples/client/petstore/python-experimental/test/test_type_holder_default.py b/samples/client/petstore/python-experimental/test/test_type_holder_default.py index 4cb90d0ed92b..08a201b854d0 100644 --- a/samples/client/petstore/python-experimental/test/test_type_holder_default.py +++ b/samples/client/petstore/python-experimental/test/test_type_holder_default.py @@ -32,10 +32,8 @@ def testTypeHolderDefault(self): """Test TypeHolderDefault""" # required_vars are set to None now until swagger-parser/swagger-core fixes # https://github.com/swagger-api/swagger-parser/issues/971 - with self.assertRaises(TypeError): - model = TypeHolderDefault() array_item = [1, 2, 3] - model = TypeHolderDefault(array_item) + model = TypeHolderDefault(array_item=array_item) self.assertEqual(model.string_item, 'what') self.assertEqual(model.bool_item, True) 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 75bf81a8de07..a05c3e902c58 100644 --- a/samples/client/petstore/python-experimental/tests/test_api_exception.py +++ b/samples/client/petstore/python-experimental/tests/test_api_exception.py @@ -58,15 +58,13 @@ def test_500_error(self): with self.checkRaiseRegex(ApiException, "Internal Server Error"): self.pet_api.upload_file( pet_id=self.pet.id, - additional_metadata="special", - file=None + additional_metadata="special" ) try: self.pet_api.upload_file( pet_id=self.pet.id, - additional_metadata="special", - file=None + additional_metadata="special" ) except ApiException as e: self.assertEqual(e.status, 500) diff --git a/samples/client/petstore/python-experimental/tests/test_deserialization.py b/samples/client/petstore/python-experimental/tests/test_deserialization.py index 6c4e083d1cd7..10c5ecef4239 100644 --- a/samples/client/petstore/python-experimental/tests/test_deserialization.py +++ b/samples/client/petstore/python-experimental/tests/test_deserialization.py @@ -42,13 +42,19 @@ def test_enum_test(self): deserialized = self.deserialize(response, 'dict(str, EnumTest)') self.assertTrue(isinstance(deserialized, dict)) - self.assertTrue(isinstance(deserialized['enum_test'], petstore_api.EnumTest)) - self.assertEqual(deserialized['enum_test'], - petstore_api.EnumTest(enum_string="UPPER", - enum_string_required="lower", - enum_integer=1, - enum_number=1.1, - outer_enum=petstore_api.OuterEnum.PLACED)) + self.assertTrue( + isinstance(deserialized['enum_test'], petstore_api.EnumTest)) + outer_enum_value = ( + petstore_api.OuterEnum.allowed_values[('value',)]["PLACED"]) + outer_enum = petstore_api.OuterEnum(outer_enum_value) + sample_instance = petstore_api.EnumTest( + enum_string="UPPER", + enum_string_required="lower", + enum_integer=1, + enum_number=1.1, + outer_enum=outer_enum + ) + self.assertEqual(deserialized['enum_test'], sample_instance) def test_deserialize_dict_str_pet(self): """ deserialize dict(str, Pet) """ @@ -239,3 +245,44 @@ def test_deserialize_none(self): deserialized = self.deserialize(response, "datetime") self.assertIsNone(deserialized) + + def test_deserialize_OuterEnum(self): + """ deserialize OuterEnum """ + # make sure that an exception is thrown on an invalid value + with self.assertRaises(petstore_api.ApiValueError): + self.deserialize( + MockResponse(data=json.dumps("test str")), + "OuterEnum" + ) + + # valid value works + placed_str = ( + petstore_api.OuterEnum.allowed_values[('value',)]["PLACED"] + ) + response = MockResponse(data=json.dumps(placed_str)) + outer_enum = self.deserialize(response, "OuterEnum") + self.assertTrue(isinstance(outer_enum, petstore_api.OuterEnum)) + self.assertTrue(outer_enum.value == placed_str) + + def test_deserialize_OuterNumber(self): + """ deserialize OuterNumber """ + # make sure that an exception is thrown on an invalid type value + with self.assertRaises(petstore_api.ApiValueError): + deserialized = self.deserialize( + MockResponse(data=json.dumps("test str")), + "OuterNumber" + ) + + # make sure that an exception is thrown on an invalid value + with self.assertRaises(petstore_api.ApiValueError): + deserialized = self.deserialize( + MockResponse(data=json.dumps(21)), + "OuterNumber" + ) + + # valid value works + number_val = 11 + response = MockResponse(data=json.dumps(number_val)) + outer_number = self.deserialize(response, "OuterNumber") + self.assertTrue(isinstance(outer_number, petstore_api.OuterNumber)) + self.assertTrue(outer_number.value == number_val) \ No newline at end of file diff --git a/samples/client/petstore/python-experimental/tests/test_pet_api.py b/samples/client/petstore/python-experimental/tests/test_pet_api.py index 4f38fbd6e176..f536f5ca288e 100644 --- a/samples/client/petstore/python-experimental/tests/test_pet_api.py +++ b/samples/client/petstore/python-experimental/tests/test_pet_api.py @@ -163,7 +163,8 @@ def test_async_with_result(self): def test_async_with_http_info(self): self.pet_api.add_pet(self.pet) - thread = self.pet_api.get_pet_by_id_with_http_info(self.pet.id, async_req=True) + thread = self.pet_api.get_pet_by_id(self.pet.id, async_req=True, + _return_http_data_only=False) data, status, headers = thread.get() self.assertIsInstance(data, petstore_api.Pet) @@ -195,7 +196,10 @@ def test_add_pet_and_get_pet_by_id(self): def test_add_pet_and_get_pet_by_id_with_http_info(self): self.pet_api.add_pet(self.pet) - fetched = self.pet_api.get_pet_by_id_with_http_info(pet_id=self.pet.id) + fetched = self.pet_api.get_pet_by_id( + pet_id=self.pet.id, + _return_http_data_only=False + ) self.assertIsNotNone(fetched) self.assertEqual(self.pet.id, fetched[0].id) self.assertIsNotNone(fetched[0].category)