forked from loafle/openapi-generator-original
[Python-experimental] types now classes, adds additionalProperties handling (#4154)
* Changes python-experimental types to classes, adds additionalalproperties handling Adds model_utils update, updates model.mustache Updates api.mustache and uses model_to_dict in model_normal.mustache Updates requirements.mustache for PythonClientExperimental Passes through check_type when deserializing models Converts types from strings to classes in PythonClientExperimentalCodegen.java and PythonTest.java Creates PythonClientExperimentalTest.java Updates toInstantiationType to use ModelUtils.xxx Corrects docstring descriptions of response_type Updates python-experimental typing, partially fixes deserialization tests Adds fixes for some of the deserialization tests Fixes deserialization tests Switches model teplates to use allVars so allof props will be included Fixes tests.test_enum_arrays Fixes test_to_str Adds additional_properties_type, fixes teast_todict in test_map_test.py Correctly check the type of _request_timeout values Fixes test_upload_file test Turns off coercion when instantiating model types with client data Updates file handling to input and output an open file object Fixes linting errors Adds fixes for python2 tests, linting fixes Adds additionalproperties to docs + tests Regenerates python-experimatal client * Regenerates python-experimental client * Updates windows python-experimental bat file * Fixes addModelImport so client generation will work with the v2 spec * Reverts PythonClientCodegen.java * Acutally revert PythonClientCodegen.java * Updates the sample example for file_type in docs * Silences line too long error for python models so CI tests pass * Fixes handling of file uploads, adds tests for uploading files * Removes comment * Fixes mock installation in python2 * Limit mock addition to python-experimental test requirements only * Removes SmartBear copyright line
This commit is contained in:
committed by
William Cheng
parent
c0bc8b4934
commit
73c55c11dd
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g python-experimental -o samples\client\petstore\python-experimental -DpackageName=petstore_api
|
||||
set ags=generate -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%
|
||||
|
||||
@@ -3624,7 +3624,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
co.baseName = tag;
|
||||
}
|
||||
|
||||
private void addParentContainer(CodegenModel model, String name, Schema schema) {
|
||||
protected void addParentContainer(CodegenModel model, String name, Schema schema) {
|
||||
final CodegenProperty property = fromProperty(name, schema);
|
||||
addImport(model, property.complexType);
|
||||
model.parent = toInstantiationType(schema);
|
||||
|
||||
@@ -50,6 +50,9 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
public PythonClientExperimentalCodegen() {
|
||||
super();
|
||||
|
||||
// this may set datatype right for additional properties
|
||||
instantiationTypes.put("map", "dict");
|
||||
|
||||
apiTemplateFiles.remove("api.mustache");
|
||||
apiTemplateFiles.put("python-experimental/api.mustache", ".py");
|
||||
|
||||
@@ -76,6 +79,20 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
|
||||
supportingFiles.add(new SupportingFile("python-experimental/model_utils.mustache", packagePath(), "model_utils.py"));
|
||||
|
||||
Boolean generateSourceCodeOnly = false;
|
||||
if (additionalProperties.containsKey(CodegenConstants.SOURCECODEONLY_GENERATION)) {
|
||||
generateSourceCodeOnly = Boolean.valueOf(additionalProperties.get(CodegenConstants.SOURCECODEONLY_GENERATION).toString());
|
||||
}
|
||||
|
||||
if (!generateSourceCodeOnly) {
|
||||
supportingFiles.remove(new SupportingFile("setup.mustache", "", "setup.py"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/setup.mustache", "", "setup.py"));
|
||||
supportingFiles.remove(new SupportingFile("requirements.mustache", "", "requirements.txt"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/requirements.mustache", "", "requirements.txt"));
|
||||
supportingFiles.remove(new SupportingFile("test-requirements.mustache", "", "test-requirements.txt"));
|
||||
supportingFiles.add(new SupportingFile("python-experimental/test-requirements.mustache", "", "test-requirements.txt"));
|
||||
}
|
||||
|
||||
// default this to true so the python ModelSimple models will be generated
|
||||
ModelUtils.setGenerateAliasAsModel(true);
|
||||
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");
|
||||
@@ -196,10 +213,20 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
// add regex information to property
|
||||
postProcessPattern(property.pattern, property.vendorExtensions);
|
||||
public void addModelImport(Map<String, Object> objs, CodegenModel cm, String otherModelName) {
|
||||
// adds the absolute path to otherModelName as an import in CodegenModel cm
|
||||
HashMap referencedModel = (HashMap) objs.get(otherModelName);
|
||||
if (referencedModel == null) {
|
||||
// this happens with a model where type=string and format=number which is a non-standard format
|
||||
return;
|
||||
}
|
||||
ArrayList myModel = (ArrayList) referencedModel.get("models");
|
||||
HashMap modelData = (HashMap) myModel.get(0);
|
||||
String importPath = (String) modelData.get("importPath");
|
||||
// only add importPath to parameters if it isn't in importPaths
|
||||
if (!cm.imports.contains(importPath)) {
|
||||
cm.imports.add(importPath);
|
||||
}
|
||||
}
|
||||
|
||||
// override with any special post-processing for all models
|
||||
@@ -213,6 +240,41 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
||||
for (Map<String, Object> mo : models) {
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
|
||||
// fix the imports that each model has, change them to absolute
|
||||
// imports
|
||||
// clear out imports so we will only include full path imports
|
||||
cm.imports.clear();
|
||||
CodegenDiscriminator discriminator = cm.discriminator;
|
||||
if (discriminator != null) {
|
||||
Set<CodegenDiscriminator.MappedModel> mappedModels = discriminator.getMappedModels();
|
||||
for (CodegenDiscriminator.MappedModel mappedModel : mappedModels) {
|
||||
String otherModelName = mappedModel.getModelName();
|
||||
addModelImport(objs, cm, otherModelName);
|
||||
}
|
||||
}
|
||||
ArrayList<List<CodegenProperty>> listOfLists= new ArrayList<List<CodegenProperty>>();
|
||||
listOfLists.add(cm.allVars);
|
||||
listOfLists.add(cm.requiredVars);
|
||||
listOfLists.add(cm.optionalVars);
|
||||
listOfLists.add(cm.vars);
|
||||
for (List<CodegenProperty> varList : listOfLists) {
|
||||
for (CodegenProperty cp : varList) {
|
||||
String otherModelName = null;
|
||||
if (cp.complexType != null) {
|
||||
otherModelName = cp.complexType;
|
||||
}
|
||||
if (cp.mostInnerItems != null) {
|
||||
if (cp.mostInnerItems.complexType != null) {
|
||||
otherModelName = cp.mostInnerItems.complexType;
|
||||
}
|
||||
}
|
||||
if (otherModelName != null) {
|
||||
addModelImport(objs, cm, otherModelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
|
||||
CodegenProperty modelProperty = fromProperty("value", modelSchema);
|
||||
if (cm.isEnum || cm.isAlias) {
|
||||
@@ -491,11 +553,6 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert OAS Model object to Codegen Model object
|
||||
*
|
||||
@@ -559,11 +616,7 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
// return all models which don't need their properties connected to non-object models
|
||||
if (propertyToModelName.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// set regex values, before it was only done on model.vars
|
||||
// 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<List<CodegenProperty>> listOfLists = new ArrayList<List<CodegenProperty>>();
|
||||
@@ -575,6 +628,9 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
listOfLists.add(result.readWriteVars);
|
||||
for (List<CodegenProperty> cpList : listOfLists) {
|
||||
for (CodegenProperty cp : cpList) {
|
||||
// set regex values, before it was only done on model.vars
|
||||
postProcessModelProperty(result, cp);
|
||||
// fix references to non-object models
|
||||
if (!propertyToModelName.containsKey(cp.name)) {
|
||||
continue;
|
||||
}
|
||||
@@ -589,4 +645,147 @@ public class PythonClientExperimentalCodegen extends PythonClientCodegen {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the type declaration of the property
|
||||
*
|
||||
* @param schema property schema
|
||||
* @return a string presentation of the property type
|
||||
*/
|
||||
public String getSimpleTypeDeclaration(Schema schema) {
|
||||
String oasType = getSchemaType(schema);
|
||||
if (typeMapping.containsKey(oasType)) {
|
||||
return typeMapping.get(oasType);
|
||||
}
|
||||
return oasType;
|
||||
}
|
||||
|
||||
public String getTypeString(Schema p, String prefix, String suffix) {
|
||||
// this is used to set dataType, which defines a python tuple of classes
|
||||
String fullSuffix = suffix;
|
||||
if (")".equals(suffix)) {
|
||||
fullSuffix = "," + suffix;
|
||||
}
|
||||
if (ModelUtils.isNullable(p)) {
|
||||
fullSuffix = ", none_type" + suffix;
|
||||
}
|
||||
if (ModelUtils.isFreeFormObject(p) && ModelUtils.getAdditionalProperties(p) == null) {
|
||||
return prefix + "bool, date, datetime, dict, float, int, list, str" + fullSuffix;
|
||||
}
|
||||
if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
return prefix + "{str: " + getTypeString(inner, "(", ")") + "}" + fullSuffix;
|
||||
} else if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
return prefix + "[" + getTypeString(inner, "", "") + "]" + fullSuffix;
|
||||
}
|
||||
String baseType = getSimpleTypeDeclaration(p);
|
||||
if (ModelUtils.isFileSchema(p)) {
|
||||
baseType = "file_type";
|
||||
}
|
||||
return prefix + baseType + fullSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the type declaration of a given name
|
||||
*
|
||||
* @param p property schema
|
||||
* @return a string presentation of the type
|
||||
*/
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
// this is used to set dataType, which defines a python tuple of classes
|
||||
// in Python we will wrap this in () to make it a tuple but here we
|
||||
// will omit the parens so the generated documentaion will not include
|
||||
// them
|
||||
return getTypeString(p, "", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toInstantiationType(Schema property) {
|
||||
if (ModelUtils.isArraySchema(property) || ModelUtils.isMapSchema(property) || property.getAdditionalProperties() != null) {
|
||||
return getSchemaType(property);
|
||||
}
|
||||
return super.toInstantiationType(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, Schema schema) {
|
||||
Schema addProps = ModelUtils.getAdditionalProperties(schema);
|
||||
if (addProps != null && addProps.get$ref() == null) {
|
||||
// if AdditionalProperties exists and is an inline definition, get its datatype and store it in m.parent
|
||||
String typeString = getTypeDeclaration(addProps);
|
||||
codegenModel.additionalPropertiesType = typeString;
|
||||
} else {
|
||||
addParentContainer(codegenModel, codegenModel.name, schema);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameterExampleValue(CodegenParameter p) {
|
||||
// we have a custom version of this function so we can set the file
|
||||
// type example value
|
||||
String example;
|
||||
|
||||
if (p.defaultValue == null) {
|
||||
example = p.example;
|
||||
} else {
|
||||
p.example = p.defaultValue;
|
||||
return;
|
||||
}
|
||||
|
||||
String type = p.baseType;
|
||||
if (type == null) {
|
||||
type = p.dataType;
|
||||
}
|
||||
|
||||
if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = p.paramName + "_example";
|
||||
}
|
||||
example = "'" + escapeText(example) + "'";
|
||||
} else if ("Integer".equals(type) || "int".equals(type)) {
|
||||
if (example == null) {
|
||||
example = "56";
|
||||
}
|
||||
} else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = "3.4";
|
||||
}
|
||||
} else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = "True";
|
||||
}
|
||||
} else if ("file".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = "/path/to/file";
|
||||
}
|
||||
example = "open('"+example+"', 'rb')";
|
||||
} else if ("Date".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = "2013-10-20";
|
||||
}
|
||||
example = "'" + escapeText(example) + "'";
|
||||
} else if ("DateTime".equalsIgnoreCase(type)) {
|
||||
if (example == null) {
|
||||
example = "2013-10-20T19:20:30+01:00";
|
||||
}
|
||||
example = "'" + escapeText(example) + "'";
|
||||
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||
// type is a model class, e.g. User
|
||||
example = this.packageName + "." + type + "()";
|
||||
} else {
|
||||
LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue");
|
||||
}
|
||||
|
||||
if (example == null) {
|
||||
example = "None";
|
||||
} else if (Boolean.TRUE.equals(p.isListContainer)) {
|
||||
example = "[" + example + "]";
|
||||
} else if (Boolean.TRUE.equals(p.isMapContainer)) {
|
||||
example = "{'key': " + example + "}";
|
||||
}
|
||||
|
||||
p.example = example;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,20 @@ from {{packageName}}.exceptions import (
|
||||
ApiTypeError,
|
||||
ApiValueError
|
||||
)
|
||||
from {{packageName}}.model_utils import (
|
||||
from {{packageName}}.model_utils import ( # noqa: F401
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
int,
|
||||
none_type,
|
||||
str,
|
||||
validate_and_convert_types
|
||||
)
|
||||
{{#imports}}
|
||||
{{{import}}}
|
||||
{{/imports}}
|
||||
|
||||
|
||||
{{#operations}}
|
||||
@@ -51,24 +61,51 @@ class {{classname}}(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
{{#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
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}None{{/returnType}}
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
{{#requiredParams}}
|
||||
kwargs['{{paramName}}'] = {{paramName}}
|
||||
{{/requiredParams}}
|
||||
@@ -76,7 +113,7 @@ class {{classname}}(object):
|
||||
|
||||
self.{{operationId}} = Endpoint(
|
||||
settings={
|
||||
'response_type': {{#returnType}}'{{returnType}}'{{/returnType}}{{^returnType}}None{{/returnType}},
|
||||
'response_type': {{#returnType}}({{{returnType}}},){{/returnType}}{{^returnType}}None{{/returnType}},
|
||||
{{#authMethods}}
|
||||
{{#-first}}
|
||||
'auth': [
|
||||
@@ -178,7 +215,7 @@ class {{classname}}(object):
|
||||
},
|
||||
'openapi_types': {
|
||||
{{#allParams}}
|
||||
'{{paramName}}': '{{dataType}}',
|
||||
'{{paramName}}': ({{{dataType}}},),
|
||||
{{/allParams}}
|
||||
},
|
||||
'attribute_map': {
|
||||
@@ -237,7 +274,7 @@ class Endpoint(object):
|
||||
|
||||
Args:
|
||||
settings (dict): see below key value pairs
|
||||
'response_type' (str): response type
|
||||
'response_type' (tuple/None): response type
|
||||
'auth' (list): a list of auth type keys
|
||||
'endpoint_path' (str): the endpoint path
|
||||
'operation_id' (str): endpoint string identifier
|
||||
@@ -273,11 +310,24 @@ class Endpoint(object):
|
||||
'_host_index',
|
||||
'_preload_content',
|
||||
'_request_timeout',
|
||||
'_return_http_data_only'
|
||||
'_return_http_data_only',
|
||||
'_check_input_type',
|
||||
'_check_return_type'
|
||||
])
|
||||
self.params_map['nullable'].extend(['_request_timeout'])
|
||||
self.validations = root_map['validations']
|
||||
self.allowed_values = root_map['allowed_values']
|
||||
self.openapi_types = root_map['openapi_types']
|
||||
extra_types = {
|
||||
'async_req': (bool,),
|
||||
'_host_index': (int,),
|
||||
'_preload_content': (bool,),
|
||||
'_request_timeout': (none_type, int, (int,), [int]),
|
||||
'_return_http_data_only': (bool,),
|
||||
'_check_input_type': (bool,),
|
||||
'_check_return_type': (bool,)
|
||||
}
|
||||
self.openapi_types.update(extra_types)
|
||||
self.attribute_map = root_map['attribute_map']
|
||||
self.location_map = root_map['location_map']
|
||||
self.collection_format_map = root_map['collection_format_map']
|
||||
@@ -291,8 +341,7 @@ class Endpoint(object):
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(param,),
|
||||
kwargs[param],
|
||||
self.validations
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
for param in self.params_map['validation']:
|
||||
@@ -303,6 +352,20 @@ class Endpoint(object):
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
if kwargs['_check_input_type'] is False:
|
||||
return
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
fixed_val = validate_and_convert_types(
|
||||
value,
|
||||
self.openapi_types[key],
|
||||
[key],
|
||||
False,
|
||||
kwargs['_check_input_type'],
|
||||
configuration=self.api_client.configuration
|
||||
)
|
||||
kwargs[key] = fixed_val
|
||||
|
||||
def __gather_params(self, kwargs):
|
||||
params = {
|
||||
'body': None,
|
||||
@@ -316,14 +379,20 @@ class Endpoint(object):
|
||||
|
||||
for param_name, param_value in six.iteritems(kwargs):
|
||||
param_location = self.location_map.get(param_name)
|
||||
if param_location is None:
|
||||
continue
|
||||
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'
|
||||
self.openapi_types[param_name] == (file_type,)):
|
||||
params['file'][param_name] = [param_value]
|
||||
elif (param_location == 'form' and
|
||||
self.openapi_types[param_name] == ([file_type],)):
|
||||
# param_value is already a list
|
||||
params['file'][param_name] = param_value
|
||||
elif param_location in {'form', 'query'}:
|
||||
param_value_full = (base_name, param_value)
|
||||
params[param_location].append(param_value_full)
|
||||
@@ -348,20 +417,15 @@ class Endpoint(object):
|
||||
|
||||
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:
|
||||
try:
|
||||
_host = self.settings['servers'][kwargs['_host_index']]
|
||||
except IndexError:
|
||||
if self.settings['servers']:
|
||||
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
|
||||
_host = None
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
if key not in self.params_map['all']:
|
||||
@@ -370,7 +434,11 @@ class Endpoint(object):
|
||||
" to method `%s`" %
|
||||
(key, self.settings['operation_id'])
|
||||
)
|
||||
if key not in self.params_map['nullable'] and value is None:
|
||||
# only throw this nullable ApiValueError if _check_input_type
|
||||
# is False, if _check_input_type==True we catch this case
|
||||
# in self.__validate_inputs
|
||||
if (key not in self.params_map['nullable'] and value is None
|
||||
and kwargs['_check_input_type'] is False):
|
||||
raise ApiValueError(
|
||||
"Value may not be None for non-nullable parameter `%s`"
|
||||
" when calling `%s`" %
|
||||
@@ -409,9 +477,10 @@ class Endpoint(object):
|
||||
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'),
|
||||
async_req=kwargs['async_req'],
|
||||
_check_type=kwargs['_check_return_type'],
|
||||
_return_http_data_only=kwargs['_return_http_data_only'],
|
||||
_preload_content=kwargs['_preload_content'],
|
||||
_request_timeout=kwargs['_request_timeout'],
|
||||
_host=_host,
|
||||
collection_formats=params['collection_format'])
|
||||
|
||||
@@ -2,14 +2,10 @@
|
||||
{{>partial_header}}
|
||||
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
|
||||
@@ -18,14 +14,20 @@ from six.moves.urllib.parse import quote
|
||||
import tornado.gen
|
||||
{{/tornado}}
|
||||
|
||||
import {{modelPackage}}
|
||||
from {{packageName}} import rest
|
||||
from {{packageName}}.configuration import Configuration
|
||||
from {{packageName}}.exceptions import ApiValueError
|
||||
from {{packageName}}.model_utils import (
|
||||
ModelNormal,
|
||||
ModelSimple
|
||||
ModelSimple,
|
||||
date,
|
||||
datetime,
|
||||
deserialize_file,
|
||||
file_type,
|
||||
model_to_dict,
|
||||
str,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from {{packageName}}.exceptions import ApiValueError
|
||||
|
||||
|
||||
class ApiClient(object):
|
||||
@@ -50,17 +52,11 @@ class ApiClient(object):
|
||||
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,
|
||||
}
|
||||
# six.binary_type python2=str, python3=bytes
|
||||
# six.text_type python2=unicode, python3=str
|
||||
PRIMITIVE_TYPES = (
|
||||
(float, bool, six.binary_type, six.text_type) + six.integer_types
|
||||
)
|
||||
_pool = None
|
||||
|
||||
def __init__(self, configuration=None, header_name=None, header_value=None,
|
||||
@@ -113,7 +109,8 @@ class ApiClient(object):
|
||||
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):
|
||||
_preload_content=True, _request_timeout=None, _host=None,
|
||||
_check_type=None):
|
||||
|
||||
config = self.configuration
|
||||
|
||||
@@ -180,7 +177,11 @@ class ApiClient(object):
|
||||
if _preload_content:
|
||||
# deserialize response data
|
||||
if response_type:
|
||||
return_data = self.deserialize(response_data, response_type)
|
||||
return_data = self.deserialize(
|
||||
response_data,
|
||||
response_type,
|
||||
_check_type
|
||||
)
|
||||
else:
|
||||
return_data = None
|
||||
|
||||
@@ -223,93 +224,73 @@ class ApiClient(object):
|
||||
elif isinstance(obj, tuple):
|
||||
return tuple(self.sanitize_for_serialization(sub_obj)
|
||||
for sub_obj in obj)
|
||||
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
||||
elif isinstance(obj, (datetime, date)):
|
||||
return obj.isoformat()
|
||||
|
||||
if isinstance(obj, dict):
|
||||
obj_dict = obj
|
||||
elif isinstance(obj, ModelNormal):
|
||||
# Convert model obj to dict except
|
||||
# attributes `openapi_types`, `attribute_map`
|
||||
# and attributes which value is not None.
|
||||
# Convert model obj to dict
|
||||
# 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}
|
||||
# model definition for request
|
||||
obj_dict = model_to_dict(obj, serialize=True)
|
||||
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)}
|
||||
|
||||
def deserialize(self, response, response_type):
|
||||
def deserialize(self, response, response_type, _check_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.
|
||||
:param response_type: For the response, a tuple containing:
|
||||
valid classes
|
||||
a list containing valid classes (for list schemas)
|
||||
a dict containing a tuple of valid classes as the value
|
||||
Example values:
|
||||
(str,)
|
||||
(Pet,)
|
||||
(float, none_type)
|
||||
([int, none_type],)
|
||||
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
||||
:param _check_type: boolean, whether to check the types of the data
|
||||
received from the server
|
||||
|
||||
: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)
|
||||
if response_type == (file_type,):
|
||||
content_disposition = response.getheader("Content-Disposition")
|
||||
return deserialize_file(response.data, self.configuration,
|
||||
content_disposition=content_disposition)
|
||||
|
||||
# fetch data from response object
|
||||
try:
|
||||
data = json.loads(response.data)
|
||||
received_data = json.loads(response.data)
|
||||
except ValueError:
|
||||
data = response.data
|
||||
received_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({{modelPackage}}, 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)
|
||||
# store our data under the key of 'received_data' so users have some
|
||||
# context if they are deserializing a string and the data type is wrong
|
||||
deserialized_data = validate_and_convert_types(
|
||||
received_data,
|
||||
response_type,
|
||||
['received_data'],
|
||||
True,
|
||||
_check_type,
|
||||
configuration=self.configuration
|
||||
)
|
||||
return deserialized_data
|
||||
|
||||
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):
|
||||
_preload_content=True, _request_timeout=None, _host=None,
|
||||
_check_type=None):
|
||||
"""Makes the HTTP request (synchronous) and returns deserialized data.
|
||||
|
||||
To make an async_req request, set the async_req parameter.
|
||||
@@ -324,9 +305,18 @@ class ApiClient(object):
|
||||
: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 response_type: For the response, a tuple containing:
|
||||
valid classes
|
||||
a list containing valid classes (for list schemas)
|
||||
a dict containing a tuple of valid classes as the value
|
||||
Example values:
|
||||
(str,)
|
||||
(Pet,)
|
||||
(float, none_type)
|
||||
([int, none_type],)
|
||||
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
||||
:param files dict: key -> field name, value -> a list of open file
|
||||
objects for `multipart/form-data`.
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param _return_http_data_only: response data without head status code
|
||||
and headers
|
||||
@@ -339,6 +329,8 @@ class ApiClient(object):
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
:param _check_type: boolean describing if the data back from the server
|
||||
should have its type checked.
|
||||
:return:
|
||||
If async_req parameter is True,
|
||||
the request will be called asynchronously.
|
||||
@@ -352,7 +344,8 @@ class ApiClient(object):
|
||||
body, post_params, files,
|
||||
response_type, auth_settings,
|
||||
_return_http_data_only, collection_formats,
|
||||
_preload_content, _request_timeout, _host)
|
||||
_preload_content, _request_timeout, _host,
|
||||
_check_type)
|
||||
else:
|
||||
thread = self.pool.apply_async(self.__call_api, (resource_path,
|
||||
method, path_params, query_params,
|
||||
@@ -363,7 +356,7 @@ class ApiClient(object):
|
||||
collection_formats,
|
||||
_preload_content,
|
||||
_request_timeout,
|
||||
_host))
|
||||
_host, _check_type))
|
||||
return thread
|
||||
|
||||
def request(self, method, url, query_params=None, headers=None,
|
||||
@@ -460,24 +453,34 @@ class ApiClient(object):
|
||||
def files_parameters(self, files=None):
|
||||
"""Builds form parameters.
|
||||
|
||||
:param files: File parameters.
|
||||
:return: Form parameters with files.
|
||||
:param files: None or a dict with key=param_name and
|
||||
value is a list of open file objects
|
||||
:return: List of tuples of form parameters with file data
|
||||
"""
|
||||
params = []
|
||||
if files is None:
|
||||
return []
|
||||
|
||||
if files:
|
||||
for k, v in six.iteritems(files):
|
||||
if not v:
|
||||
params = []
|
||||
for param_name, file_instances in six.iteritems(files):
|
||||
if file_instances is None:
|
||||
# if the file field is nullable, skip None values
|
||||
continue
|
||||
for file_instance in file_instances:
|
||||
if file_instance is None:
|
||||
# if the file field is nullable, skip None values
|
||||
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])]))
|
||||
if file_instance.closed is True:
|
||||
raise ApiValueError(
|
||||
"Cannot read a closed file. The passed in file_type "
|
||||
"for %s must be open." % param_name
|
||||
)
|
||||
filename = os.path.basename(file_instance.name)
|
||||
filedata = file_instance.read()
|
||||
mimetype = (mimetypes.guess_type(filename)[0] or
|
||||
'application/octet-stream')
|
||||
params.append(
|
||||
tuple([param_name, tuple([filename, filedata, mimetype])]))
|
||||
file_instance.close()
|
||||
|
||||
return params
|
||||
|
||||
@@ -538,133 +541,3 @@ class ApiClient(object):
|
||||
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
|
||||
except ValueError as exc:
|
||||
raise ApiValueError(str(exc))
|
||||
|
||||
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, ModelSimple or ModelNormal
|
||||
:return: model object.
|
||||
"""
|
||||
|
||||
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]
|
||||
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
|
||||
|
||||
@@ -7,14 +7,29 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from {{packageName}}.exceptions import ApiValueError # noqa: F401
|
||||
from {{packageName}}.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from {{packageName}}.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
{{#models}}{{#model}}{{#imports}}{{.}}
|
||||
{{/imports}}{{/model}}{{/models}}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
|
||||
@@ -3,10 +3,22 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#requiredVars}}{{^defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}}
|
||||
{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}}
|
||||
{{/defaultValue}}{{/requiredVars}}{{#optionalVars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}
|
||||
{{#requiredVars}}
|
||||
{{^defaultValue}}
|
||||
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{#isReadOnly}}[readonly] {{/isReadOnly}}
|
||||
{{/defaultValue}}
|
||||
{{/requiredVars}}
|
||||
{{#requiredVars}}
|
||||
{{#defaultValue}}
|
||||
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}defaults to {{{.}}}{{/defaultValue}}
|
||||
{{/defaultValue}}
|
||||
{{/requiredVars}}
|
||||
{{#optionalVars}}
|
||||
**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | [optional] {{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}} if omitted the server will use the default value of {{{.}}}{{/defaultValue}}
|
||||
{{/optionalVars}}
|
||||
{{#additionalPropertiesType}}
|
||||
**any string name** | **{{additionalPropertiesType}}** | any string name can be used but the value must be the correct type | [optional]
|
||||
{{/additionalPropertiesType}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
allowed_values = {
|
||||
{{#vars}}
|
||||
{{#allVars}}
|
||||
{{#isEnum}}
|
||||
('{{name}}',): {
|
||||
{{#isNullable}}
|
||||
@@ -7,10 +7,10 @@
|
||||
{{/isNullable}}
|
||||
{{#allowableValues}}
|
||||
{{#enumVars}}
|
||||
'{{name}}': {{{value}}}{{^-last}},{{/-last}}
|
||||
'{{name}}': {{{value}}},
|
||||
{{/enumVars}}
|
||||
{{/allowableValues}}
|
||||
},
|
||||
{{/isEnum}}
|
||||
{{/vars}}
|
||||
{{/allVars}}
|
||||
}
|
||||
@@ -1,25 +1,42 @@
|
||||
openapi_types = {
|
||||
{{#vars}}
|
||||
'{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}}
|
||||
{{/vars}}
|
||||
{{#allVars}}
|
||||
'{{name}}': ({{{dataType}}},), # noqa: E501
|
||||
{{/allVars}}
|
||||
}
|
||||
|
||||
validations = {
|
||||
{{#vars}}
|
||||
{{#allVars}}
|
||||
{{#hasValidation}}
|
||||
('{{name}}',): {
|
||||
{{#maxLength}}
|
||||
'max_length': {{maxLength}},{{/maxLength}}{{#minLength}}
|
||||
'min_length': {{minLength}},{{/minLength}}{{#maxItems}}
|
||||
'max_items': {{maxItems}},{{/maxItems}}{{#minItems}}
|
||||
'min_items': {{minItems}},{{/minItems}}{{#maximum}}
|
||||
{{#exclusiveMaximum}}'exclusive_maximum'{{/exclusiveMaximum}}'inclusive_maximum'{{^exclusiveMaximum}}{{/exclusiveMaximum}}: {{maximum}},{{/maximum}}{{#minimum}}
|
||||
{{#exclusiveMinimum}}'exclusive_minimum'{{/exclusiveMinimum}}'inclusive_minimum'{{^exclusiveMinimum}}{{/exclusiveMinimum}}: {{minimum}},{{/minimum}}{{#pattern}}
|
||||
'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}}
|
||||
},
|
||||
{{/pattern}}
|
||||
},
|
||||
{{/hasValidation}}
|
||||
{{/vars}}
|
||||
}
|
||||
{{/allVars}}
|
||||
}
|
||||
|
||||
additional_properties_type = {{#additionalPropertiesType}}({{{additionalPropertiesType}}},) # noqa: E501{{/additionalPropertiesType}}{{^additionalPropertiesType}}None{{/additionalPropertiesType}}
|
||||
|
||||
discriminator = {{#discriminator}}'{{{discriminatorName}}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}}
|
||||
@@ -4,4 +4,6 @@
|
||||
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.
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
@@ -1,76 +1,126 @@
|
||||
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}}
|
||||
def __init__(self{{#requiredVars}}{{^defaultValue}}, {{name}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{#defaultValue}}, {{name}}={{{defaultValue}}}{{/defaultValue}}{{/requiredVars}}, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""{{classname}} - a model defined in OpenAPI
|
||||
|
||||
{{#requiredVars}}{{^hasMore}} Args:{{/hasMore}}{{/requiredVars}}{{#requiredVars}}{{^defaultValue}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}{{/description}}{{/defaultValue}}{{/requiredVars}}{{#requiredVars}}{{^hasMore}}
|
||||
{{/hasMore}}{{/requiredVars}}
|
||||
Keyword Args:{{#requiredVars}}{{#defaultValue}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} defaults to {{{defaultValue}}}, must be one of [{{{defaultValue}}}] # noqa: E501{{/defaultValue}}{{/requiredVars}}
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.{{#optionalVars}}
|
||||
{{name}} ({{{dataType}}}):{{#description}} {{description}}.{{/description}} [optional]{{#defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/defaultValue}} # noqa: E501{{/optionalVars}}
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
{{#requiredVars}}
|
||||
self.__set_item('{{name}}', {{name}})
|
||||
{{/requiredVars}}
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
{{/isNullable}}
|
||||
{{/required}}
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
{{#allVars}}
|
||||
|
||||
@property
|
||||
def {{name}}(self):
|
||||
"""Gets the {{name}} of this {{classname}}. # noqa: E501
|
||||
|
||||
{{#description}}
|
||||
{{{description}}} # noqa: E501
|
||||
{{/description}}
|
||||
|
||||
:return: The {{name}} of this {{classname}}. # noqa: E501
|
||||
:rtype: {{dataType}}
|
||||
Returns:
|
||||
({{{dataType}}}): The {{name}} of this {{classname}}. # noqa: E501
|
||||
"""
|
||||
return self._{{name}}
|
||||
return self.__get_item('{{name}}')
|
||||
|
||||
@{{name}}.setter
|
||||
def {{name}}(self, {{name}}): # noqa: E501
|
||||
"""Sets the {{name}} of this {{classname}}.
|
||||
|
||||
def {{name}}(self, value):
|
||||
"""Sets the {{name}} of this {{classname}}. # noqa: E501
|
||||
{{#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}}
|
||||
return self.__set_item('{{name}}', value)
|
||||
{{/allVars}}
|
||||
@@ -16,14 +16,14 @@ class {{classname}}(ModelNormal):
|
||||
{{> python-experimental/model_templates/classvar_allowed }}
|
||||
|
||||
attribute_map = {
|
||||
{{#vars}}
|
||||
{{#allVars}}
|
||||
'{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}} # noqa: E501
|
||||
{{/vars}}
|
||||
{{/allVars}}
|
||||
}
|
||||
{{#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}},
|
||||
{{#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}}
|
||||
@@ -32,36 +32,19 @@ class {{classname}}(ModelNormal):
|
||||
|
||||
{{> 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]
|
||||
@classmethod
|
||||
def get_real_child_model(cls, data):
|
||||
"""Returns the real base class specified by the discriminator
|
||||
We assume that data has javascript keys
|
||||
"""
|
||||
discriminator_key = cls.attribute_map[cls.discriminator]
|
||||
discriminator_value = data[discriminator_key]
|
||||
return self.discriminator_value_class_map.get(discriminator_value)
|
||||
return cls.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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -76,7 +59,22 @@ class {{classname}}(ModelNormal):
|
||||
if not isinstance(other, {{classname}}):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -16,7 +16,7 @@ class {{classname}}(ModelSimple):
|
||||
{{> python-experimental/model_templates/methods_init_properties }}
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return str(self._value)
|
||||
return str(self.value)
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
@@ -27,7 +27,19 @@ class {{classname}}(ModelSimple):
|
||||
if not isinstance(other, {{classname}}):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
this_val = self._data_store['value']
|
||||
that_val = other._data_store['value']
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -1,13 +1,162 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import copy
|
||||
from datetime import date, datetime # noqa: F401
|
||||
import inspect
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
from {{packageName}}.exceptions import ApiValueError
|
||||
from dateutil.parser import parse
|
||||
import six
|
||||
|
||||
from {{packageName}}.exceptions import (
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
|
||||
none_type = type(None)
|
||||
if six.PY3:
|
||||
import io
|
||||
file_type = io.IOBase
|
||||
# these are needed for when other modules import str and int from here
|
||||
str = str
|
||||
int = int
|
||||
else:
|
||||
file_type = file # noqa: F821
|
||||
str_py2 = str
|
||||
unicode_py2 = unicode # noqa: F821
|
||||
long_py2 = long # noqa: F821
|
||||
int_py2 = int
|
||||
# this requires that the future library is installed
|
||||
from builtins import int, str
|
||||
|
||||
|
||||
def check_allowed_values(allowed_values, input_variable_path, input_values,
|
||||
validations):
|
||||
class OpenApiModel(object):
|
||||
"""The base class for all OpenAPIModels"""
|
||||
|
||||
|
||||
class ModelSimple(OpenApiModel):
|
||||
"""the parent class of models whose type != object in their
|
||||
swagger/openapi"""
|
||||
|
||||
|
||||
class ModelNormal(OpenApiModel):
|
||||
"""the parent class of models whose type == object in their
|
||||
swagger/openapi"""
|
||||
|
||||
|
||||
COERCION_INDEX_BY_TYPE = {
|
||||
ModelNormal: 0,
|
||||
ModelSimple: 1,
|
||||
none_type: 2,
|
||||
list: 3,
|
||||
dict: 4,
|
||||
float: 5,
|
||||
int: 6,
|
||||
bool: 7,
|
||||
datetime: 8,
|
||||
date: 9,
|
||||
str: 10,
|
||||
file_type: 11,
|
||||
}
|
||||
|
||||
# these are used to limit what type conversions we try to do
|
||||
# when we have a valid type already and we want to try converting
|
||||
# to another type
|
||||
UPCONVERSION_TYPE_PAIRS = (
|
||||
(str, datetime),
|
||||
(str, date),
|
||||
(list, ModelNormal),
|
||||
(dict, ModelNormal),
|
||||
(str, ModelSimple),
|
||||
(int, ModelSimple),
|
||||
(float, ModelSimple),
|
||||
(list, ModelSimple),
|
||||
)
|
||||
|
||||
COERCIBLE_TYPE_PAIRS = {
|
||||
False: ( # client instantiation of a model with client data
|
||||
# (dict, ModelNormal),
|
||||
# (list, ModelNormal),
|
||||
# (str, ModelSimple),
|
||||
# (int, ModelSimple),
|
||||
# (float, ModelSimple),
|
||||
# (list, ModelSimple),
|
||||
# (str, int),
|
||||
# (str, float),
|
||||
# (str, datetime),
|
||||
# (str, date),
|
||||
# (int, str),
|
||||
# (float, str),
|
||||
),
|
||||
True: ( # server -> client data
|
||||
(dict, ModelNormal),
|
||||
(list, ModelNormal),
|
||||
(str, ModelSimple),
|
||||
(int, ModelSimple),
|
||||
(float, ModelSimple),
|
||||
(list, ModelSimple),
|
||||
# (str, int),
|
||||
# (str, float),
|
||||
(str, datetime),
|
||||
(str, date),
|
||||
# (int, str),
|
||||
# (float, str),
|
||||
(str, file_type)
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def get_simple_class(input_value):
|
||||
"""Returns an input_value's simple class that we will use for type checking
|
||||
Python2:
|
||||
float and int will return int, where int is the python3 int backport
|
||||
str and unicode will return str, where str is the python3 str backport
|
||||
Note: float and int ARE both instances of int backport
|
||||
Note: str_py2 and unicode_py2 are NOT both instances of str backport
|
||||
|
||||
Args:
|
||||
input_value (class/class_instance): the item for which we will return
|
||||
the simple class
|
||||
"""
|
||||
if isinstance(input_value, type):
|
||||
# input_value is a class
|
||||
return input_value
|
||||
elif isinstance(input_value, tuple):
|
||||
return tuple
|
||||
elif isinstance(input_value, list):
|
||||
return list
|
||||
elif isinstance(input_value, dict):
|
||||
return dict
|
||||
elif isinstance(input_value, none_type):
|
||||
return none_type
|
||||
elif isinstance(input_value, file_type):
|
||||
return file_type
|
||||
elif isinstance(input_value, bool):
|
||||
# this must be higher than the int check because
|
||||
# isinstance(True, int) == True
|
||||
return bool
|
||||
elif isinstance(input_value, int):
|
||||
# for python2 input_value==long_instance -> return int
|
||||
# where int is the python3 int backport
|
||||
return int
|
||||
elif isinstance(input_value, datetime):
|
||||
# this must be higher than the date check because
|
||||
# isinstance(datetime_instance, date) == True
|
||||
return datetime
|
||||
elif isinstance(input_value, date):
|
||||
return date
|
||||
elif (six.PY2 and isinstance(input_value, (str_py2, unicode_py2, str)) or
|
||||
isinstance(input_value, str)):
|
||||
return str
|
||||
return type(input_value)
|
||||
|
||||
|
||||
def check_allowed_values(allowed_values, input_variable_path, input_values):
|
||||
"""Raises an exception if the input_values are not allowed
|
||||
|
||||
Args:
|
||||
@@ -15,14 +164,9 @@ def check_allowed_values(allowed_values, input_variable_path, input_values,
|
||||
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(
|
||||
@@ -36,7 +180,6 @@ def check_allowed_values(allowed_values, input_variable_path, input_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(
|
||||
@@ -111,8 +254,21 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
)
|
||||
|
||||
items = ('exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum',
|
||||
'inclusive_minimum')
|
||||
if (any(item in current_validations for item in items)):
|
||||
if isinstance(input_values, list):
|
||||
max_val = max(input_values)
|
||||
min_val = min(input_values)
|
||||
elif isinstance(input_values, dict):
|
||||
max_val = max(input_values.values())
|
||||
min_val = min(input_values.values())
|
||||
else:
|
||||
max_val = input_values
|
||||
min_val = input_values
|
||||
|
||||
if ('exclusive_maximum' in current_validations and
|
||||
input_values >= current_validations['exclusive_maximum']):
|
||||
max_val >= current_validations['exclusive_maximum']):
|
||||
raise ApiValueError(
|
||||
"Invalid value for `%s`, must be a value less than `%s`" % (
|
||||
input_variable_path[0],
|
||||
@@ -121,7 +277,7 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
|
||||
if ('inclusive_maximum' in current_validations and
|
||||
input_values > current_validations['inclusive_maximum']):
|
||||
max_val > current_validations['inclusive_maximum']):
|
||||
raise ApiValueError(
|
||||
"Invalid value for `%s`, must be a value less than or equal to "
|
||||
"`%s`" % (
|
||||
@@ -131,7 +287,7 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
|
||||
if ('exclusive_minimum' in current_validations and
|
||||
input_values <= current_validations['exclusive_minimum']):
|
||||
min_val <= current_validations['exclusive_minimum']):
|
||||
raise ApiValueError(
|
||||
"Invalid value for `%s`, must be a value greater than `%s`" %
|
||||
(
|
||||
@@ -141,7 +297,7 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
|
||||
if ('inclusive_minimum' in current_validations and
|
||||
input_values < current_validations['inclusive_minimum']):
|
||||
min_val < current_validations['inclusive_minimum']):
|
||||
raise ApiValueError(
|
||||
"Invalid value for `%s`, must be a value greater than or equal "
|
||||
"to `%s`" % (
|
||||
@@ -163,13 +319,550 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
|
||||
|
||||
class ModelSimple(object):
|
||||
# the parent class of models whose type != object in their swagger/openapi
|
||||
# spec
|
||||
pass
|
||||
def order_response_types(required_types):
|
||||
"""Returns the required types sorted in coercion order
|
||||
|
||||
Args:
|
||||
required_types (list/tuple): collection of classes or instance of
|
||||
list or dict with classs information inside it
|
||||
|
||||
Returns:
|
||||
(list): coercion order sorted collection of classes or instance
|
||||
of list or dict with classs information inside it
|
||||
"""
|
||||
|
||||
def index_getter(class_or_instance):
|
||||
if isinstance(class_or_instance, list):
|
||||
return COERCION_INDEX_BY_TYPE[list]
|
||||
elif isinstance(class_or_instance, dict):
|
||||
return COERCION_INDEX_BY_TYPE[dict]
|
||||
elif (inspect.isclass(class_or_instance)
|
||||
and issubclass(class_or_instance, ModelNormal)):
|
||||
return COERCION_INDEX_BY_TYPE[ModelNormal]
|
||||
elif (inspect.isclass(class_or_instance)
|
||||
and issubclass(class_or_instance, ModelSimple)):
|
||||
return COERCION_INDEX_BY_TYPE[ModelSimple]
|
||||
return COERCION_INDEX_BY_TYPE[class_or_instance]
|
||||
|
||||
sorted_types = sorted(
|
||||
required_types,
|
||||
key=lambda class_or_instance: index_getter(class_or_instance)
|
||||
)
|
||||
return sorted_types
|
||||
|
||||
|
||||
class ModelNormal(object):
|
||||
# the parent class of models whose type == object in their swagger/openapi
|
||||
# spec
|
||||
pass
|
||||
def remove_uncoercible(required_types_classes, current_item, from_server,
|
||||
must_convert=True):
|
||||
"""Only keeps the type conversions that are possible
|
||||
|
||||
Args:
|
||||
required_types_classes (tuple): tuple of classes that are required
|
||||
these should be ordered by COERCION_INDEX_BY_TYPE
|
||||
from_server (bool): a boolean of whether the data is from the server
|
||||
if false, the data is from the client
|
||||
current_item (any): the current item to be converted
|
||||
|
||||
Keyword Args:
|
||||
must_convert (bool): if True the item to convert is of the wrong
|
||||
type and we want a big list of coercibles
|
||||
if False, we want a limited list of coercibles
|
||||
|
||||
Returns:
|
||||
(list): the remaining coercible required types, classes only
|
||||
"""
|
||||
current_type_simple = get_simple_class(current_item)
|
||||
|
||||
results_classes = []
|
||||
for required_type_class in required_types_classes:
|
||||
# convert our models to OpenApiModel
|
||||
required_type_class_simplified = required_type_class
|
||||
if isinstance(required_type_class_simplified, type):
|
||||
if issubclass(required_type_class_simplified, ModelNormal):
|
||||
required_type_class_simplified = ModelNormal
|
||||
elif issubclass(required_type_class_simplified, ModelSimple):
|
||||
required_type_class_simplified = ModelSimple
|
||||
|
||||
if required_type_class_simplified == current_type_simple:
|
||||
# don't consider converting to one's own class
|
||||
continue
|
||||
|
||||
class_pair = (current_type_simple, required_type_class_simplified)
|
||||
if must_convert and class_pair in COERCIBLE_TYPE_PAIRS[from_server]:
|
||||
results_classes.append(required_type_class)
|
||||
elif class_pair in UPCONVERSION_TYPE_PAIRS:
|
||||
results_classes.append(required_type_class)
|
||||
return results_classes
|
||||
|
||||
|
||||
def get_required_type_classes(required_types_mixed):
|
||||
"""Converts the tuple required_types into a tuple and a dict described
|
||||
below
|
||||
|
||||
Args:
|
||||
required_types_mixed (tuple/list): will contain either classes or
|
||||
instance of list or dict
|
||||
|
||||
Returns:
|
||||
(valid_classes, dict_valid_class_to_child_types_mixed):
|
||||
valid_classes (tuple): the valid classes that the current item
|
||||
should be
|
||||
dict_valid_class_to_child_types_mixed (doct):
|
||||
valid_class (class): this is the key
|
||||
child_types_mixed (list/dict/tuple): describes the valid child
|
||||
types
|
||||
"""
|
||||
valid_classes = []
|
||||
child_req_types_by_current_type = {}
|
||||
for required_type in required_types_mixed:
|
||||
if isinstance(required_type, list):
|
||||
valid_classes.append(list)
|
||||
child_req_types_by_current_type[list] = required_type
|
||||
elif isinstance(required_type, tuple):
|
||||
valid_classes.append(tuple)
|
||||
child_req_types_by_current_type[tuple] = required_type
|
||||
elif isinstance(required_type, dict):
|
||||
valid_classes.append(dict)
|
||||
child_req_types_by_current_type[dict] = required_type[str]
|
||||
else:
|
||||
valid_classes.append(required_type)
|
||||
return tuple(valid_classes), child_req_types_by_current_type
|
||||
|
||||
|
||||
def change_keys_js_to_python(input_dict, model_class):
|
||||
"""
|
||||
Converts from javascript_key keys in the input_dict to python_keys in
|
||||
the output dict using the mapping in model_class
|
||||
"""
|
||||
|
||||
output_dict = {}
|
||||
reversed_attr_map = {value: key for key, value in
|
||||
six.iteritems(model_class.attribute_map)}
|
||||
for javascript_key, value in six.iteritems(input_dict):
|
||||
python_key = reversed_attr_map.get(javascript_key)
|
||||
if python_key is None:
|
||||
# if the key is unknown, it is in error or it is an
|
||||
# additionalProperties variable
|
||||
python_key = javascript_key
|
||||
output_dict[python_key] = value
|
||||
return output_dict
|
||||
|
||||
|
||||
def get_type_error(var_value, path_to_item, valid_classes, key_type=False):
|
||||
error_msg = type_error_message(
|
||||
var_name=path_to_item[-1],
|
||||
var_value=var_value,
|
||||
valid_classes=valid_classes,
|
||||
key_type=key_type
|
||||
)
|
||||
return ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=valid_classes,
|
||||
key_type=key_type
|
||||
)
|
||||
|
||||
|
||||
def deserialize_primitive(data, klass, path_to_item):
|
||||
"""Deserializes string to primitive type.
|
||||
|
||||
:param data: str/int/float
|
||||
:param klass: str/class the class to convert to
|
||||
|
||||
:return: int, float, str, bool, date, datetime
|
||||
"""
|
||||
additional_message = ""
|
||||
try:
|
||||
if klass in {datetime, date}:
|
||||
additional_message = (
|
||||
"If you need your parameter to have a fallback "
|
||||
"string value, please set its type as `type: {}` in your "
|
||||
"spec. That allows the value to be any type. "
|
||||
)
|
||||
if klass == datetime:
|
||||
if len(data) < 8:
|
||||
raise ValueError("This is not a datetime")
|
||||
# The string should be in iso8601 datetime format.
|
||||
parsed_datetime = parse(data)
|
||||
date_only = (
|
||||
parsed_datetime.hour == 0 and
|
||||
parsed_datetime.minute == 0 and
|
||||
parsed_datetime.second == 0 and
|
||||
parsed_datetime.tzinfo is None and
|
||||
8 <= len(data) <= 10
|
||||
)
|
||||
if date_only:
|
||||
raise ValueError("This is a date, not a datetime")
|
||||
return parsed_datetime
|
||||
elif klass == date:
|
||||
if len(data) < 8:
|
||||
raise ValueError("This is not a date")
|
||||
return parse(data).date()
|
||||
else:
|
||||
converted_value = klass(data)
|
||||
if isinstance(data, str) and klass == float:
|
||||
if str(converted_value) != data:
|
||||
# '7' -> 7.0 -> '7.0' != '7'
|
||||
raise ValueError('This is not a float')
|
||||
return converted_value
|
||||
except (OverflowError, ValueError):
|
||||
# parse can raise OverflowError
|
||||
raise ApiValueError(
|
||||
"{0}Failed to parse {1} as {2}".format(
|
||||
additional_message, repr(data), get_py3_class_name(klass)
|
||||
),
|
||||
path_to_item=path_to_item
|
||||
)
|
||||
|
||||
|
||||
def deserialize_model(model_data, model_class, path_to_item, check_type,
|
||||
configuration, from_server):
|
||||
"""Deserializes model_data to model instance.
|
||||
|
||||
Args:
|
||||
model_data (list/dict): data to instantiate the model
|
||||
model_class (OpenApiModel): the model class
|
||||
path_to_item (list): path to the model in the received data
|
||||
check_type (bool): whether to check the data tupe for the values in
|
||||
the model
|
||||
configuration (Configuration): the instance to use to convert files
|
||||
from_server (bool): True if the data is from the server
|
||||
False if the data is from the client
|
||||
|
||||
Returns:
|
||||
model instance
|
||||
|
||||
Raise:
|
||||
ApiTypeError
|
||||
ApiValueError
|
||||
ApiKeyError
|
||||
"""
|
||||
fixed_model_data = copy.deepcopy(model_data)
|
||||
|
||||
if isinstance(fixed_model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(fixed_model_data,
|
||||
model_class)
|
||||
|
||||
kw_args = dict(_check_type=check_type,
|
||||
_path_to_item=path_to_item,
|
||||
_configuration=configuration,
|
||||
_from_server=from_server)
|
||||
|
||||
if hasattr(model_class, 'get_real_child_model'):
|
||||
# discriminator case
|
||||
discriminator_class = model_class.get_real_child_model(model_data)
|
||||
if discriminator_class:
|
||||
if isinstance(model_data, list):
|
||||
instance = discriminator_class(*model_data, **kw_args)
|
||||
elif isinstance(model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(
|
||||
fixed_model_data,
|
||||
discriminator_class
|
||||
)
|
||||
kw_args.update(fixed_model_data)
|
||||
instance = discriminator_class(**kw_args)
|
||||
else:
|
||||
# all other cases
|
||||
if isinstance(model_data, list):
|
||||
instance = model_class(*model_data, **kw_args)
|
||||
if isinstance(model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(fixed_model_data,
|
||||
model_class)
|
||||
kw_args.update(fixed_model_data)
|
||||
instance = model_class(**kw_args)
|
||||
else:
|
||||
instance = model_class(model_data, **kw_args)
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
def deserialize_file(response_data, configuration, content_disposition=None):
|
||||
"""Deserializes body to file
|
||||
|
||||
Saves response body into a file in a temporary folder,
|
||||
using the filename from the `Content-Disposition` header if provided.
|
||||
|
||||
Args:
|
||||
param response_data (str): the file data to write
|
||||
configuration (Configuration): the instance to use to convert files
|
||||
|
||||
Keyword Args:
|
||||
content_disposition (str): the value of the Content-Disposition
|
||||
header
|
||||
|
||||
Returns:
|
||||
(file_type): the deserialized file which is open
|
||||
The user is responsible for closing and reading the file
|
||||
"""
|
||||
fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path)
|
||||
os.close(fd)
|
||||
os.remove(path)
|
||||
|
||||
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:
|
||||
if six.PY3 and isinstance(response_data, str):
|
||||
# in python3 change str to bytes so we can write it
|
||||
response_data = response_data.encode('utf-8')
|
||||
f.write(response_data)
|
||||
|
||||
f = open(path, "rb")
|
||||
return f
|
||||
|
||||
|
||||
def attempt_convert_item(input_value, valid_classes, path_to_item,
|
||||
configuration, from_server, key_type=False,
|
||||
must_convert=False, check_type=True):
|
||||
"""
|
||||
Args:
|
||||
input_value (any): the data to convert
|
||||
valid_classes (any): the classes that are valid
|
||||
path_to_item (list): the path to the item to convert
|
||||
configuration (Configuration): the instance to use to convert files
|
||||
from_server (bool): True if data is from the server, False is data is
|
||||
from the client
|
||||
key_type (bool): if True we need to convert a key type (not supported)
|
||||
must_convert (bool): if True we must convert
|
||||
check_type (bool): if True we check the type or the returned data in
|
||||
ModelNormal and ModelSimple instances
|
||||
|
||||
Returns:
|
||||
instance (any) the fixed item
|
||||
|
||||
Raises:
|
||||
ApiTypeError
|
||||
ApiValueError
|
||||
ApiKeyError
|
||||
"""
|
||||
valid_classes_ordered = order_response_types(valid_classes)
|
||||
valid_classes_coercible = remove_uncoercible(
|
||||
valid_classes_ordered, input_value, from_server)
|
||||
if not valid_classes_coercible or key_type:
|
||||
# we do not handle keytype errors, json will take care
|
||||
# of this for us
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=key_type)
|
||||
for valid_class in valid_classes_coercible:
|
||||
try:
|
||||
if issubclass(valid_class, OpenApiModel):
|
||||
return deserialize_model(input_value, valid_class,
|
||||
path_to_item, check_type,
|
||||
configuration, from_server)
|
||||
elif valid_class == file_type:
|
||||
return deserialize_file(input_value, configuration)
|
||||
return deserialize_primitive(input_value, valid_class,
|
||||
path_to_item)
|
||||
except (ApiTypeError, ApiValueError, ApiKeyError) as conversion_exc:
|
||||
if must_convert:
|
||||
raise conversion_exc
|
||||
# if we have conversion errors when must_convert == False
|
||||
# we ignore the exception and move on to the next class
|
||||
continue
|
||||
# we were unable to convert, must_convert == False
|
||||
return input_value
|
||||
|
||||
|
||||
def validate_and_convert_types(input_value, required_types_mixed, path_to_item,
|
||||
from_server, _check_type, configuration=None):
|
||||
"""Raises a TypeError is there is a problem, otherwise returns value
|
||||
|
||||
Args:
|
||||
input_value (any): the data to validate/convert
|
||||
required_types_mixed (list/dict/tuple): A list of
|
||||
valid classes, or a list tuples of valid classes, or a dict where
|
||||
the value is a tuple of value classes
|
||||
path_to_item: (list) the path to the data being validated
|
||||
this stores a list of keys or indices to get to the data being
|
||||
validated
|
||||
from_server (bool): True if data is from the server
|
||||
False if data is from the client
|
||||
_check_type: (boolean) if true, type will be checked and conversion
|
||||
will be attempted.
|
||||
configuration: (Configuration): the configuration class to use
|
||||
when converting file_type items.
|
||||
If passed, conversion will be attempted when possible
|
||||
If not passed, no conversions will be attempted and
|
||||
exceptions will be raised
|
||||
|
||||
Returns:
|
||||
the correctly typed value
|
||||
|
||||
Raises:
|
||||
ApiTypeError
|
||||
"""
|
||||
results = get_required_type_classes(required_types_mixed)
|
||||
valid_classes, child_req_types_by_current_type = results
|
||||
|
||||
input_class_simple = get_simple_class(input_value)
|
||||
valid_type = input_class_simple in set(valid_classes)
|
||||
if not valid_type:
|
||||
if configuration:
|
||||
# if input_value is not valid_type try to convert it
|
||||
converted_instance = attempt_convert_item(
|
||||
input_value,
|
||||
valid_classes,
|
||||
path_to_item,
|
||||
configuration,
|
||||
from_server,
|
||||
key_type=False,
|
||||
must_convert=True
|
||||
)
|
||||
return converted_instance
|
||||
else:
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=False)
|
||||
|
||||
# input_value's type is in valid_classes
|
||||
if len(valid_classes) > 1 and configuration:
|
||||
# there are valid classes which are not the current class
|
||||
valid_classes_coercible = remove_uncoercible(
|
||||
valid_classes, input_value, from_server, must_convert=False)
|
||||
if valid_classes_coercible:
|
||||
converted_instance = attempt_convert_item(
|
||||
input_value,
|
||||
valid_classes_coercible,
|
||||
path_to_item,
|
||||
configuration,
|
||||
from_server,
|
||||
key_type=False,
|
||||
must_convert=False
|
||||
)
|
||||
return converted_instance
|
||||
|
||||
if child_req_types_by_current_type == {}:
|
||||
# all types are of the required types and there are no more inner
|
||||
# variables left to look at
|
||||
return input_value
|
||||
inner_required_types = child_req_types_by_current_type.get(
|
||||
type(input_value)
|
||||
)
|
||||
if inner_required_types is None:
|
||||
# for this type, there are not more inner variables left to look at
|
||||
return input_value
|
||||
if isinstance(input_value, list):
|
||||
if input_value == []:
|
||||
# allow an empty list
|
||||
return input_value
|
||||
for index, inner_value in enumerate(input_value):
|
||||
inner_path = list(path_to_item)
|
||||
inner_path.append(index)
|
||||
input_value[index] = validate_and_convert_types(
|
||||
inner_value,
|
||||
inner_required_types,
|
||||
inner_path,
|
||||
from_server,
|
||||
_check_type,
|
||||
configuration=configuration
|
||||
)
|
||||
elif isinstance(input_value, dict):
|
||||
if input_value == {}:
|
||||
# allow an empty dict
|
||||
return input_value
|
||||
for inner_key, inner_val in six.iteritems(input_value):
|
||||
inner_path = list(path_to_item)
|
||||
inner_path.append(inner_key)
|
||||
if get_simple_class(inner_key) != str:
|
||||
raise get_type_error(inner_key, inner_path, valid_classes,
|
||||
key_type=True)
|
||||
input_value[inner_key] = validate_and_convert_types(
|
||||
inner_val,
|
||||
inner_required_types,
|
||||
inner_path,
|
||||
from_server,
|
||||
_check_type,
|
||||
configuration=configuration
|
||||
)
|
||||
return input_value
|
||||
|
||||
|
||||
def model_to_dict(model_instance, serialize=True):
|
||||
"""Returns the model properties as a dict
|
||||
|
||||
Args:
|
||||
model_instance (one of your model instances): the model instance that
|
||||
will be converted to a dict.
|
||||
|
||||
Keyword Args:
|
||||
serialize (bool): if True, the keys in the dict will be values from
|
||||
attribute_map
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, value in six.iteritems(model_instance._data_store):
|
||||
if serialize:
|
||||
# we use get here because additional property key names do not
|
||||
# exist in attribute_map
|
||||
attr = model_instance.attribute_map.get(attr, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: model_to_dict(x, serialize=serialize)
|
||||
if hasattr(x, '_data_store') else x, value
|
||||
))
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0],
|
||||
model_to_dict(item[1], serialize=serialize))
|
||||
if hasattr(item[1], '_data_store') else item,
|
||||
value.items()
|
||||
))
|
||||
elif hasattr(value, '_data_store'):
|
||||
result[attr] = model_to_dict(value, serialize=serialize)
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def type_error_message(var_value=None, var_name=None, valid_classes=None,
|
||||
key_type=None):
|
||||
"""
|
||||
Keyword Args:
|
||||
var_value (any): the variable which has the type_error
|
||||
var_name (str): the name of the variable which has the typ error
|
||||
valid_classes (tuple): the accepted classes for current_item's
|
||||
value
|
||||
key_type (bool): False if our value is a value in a dict
|
||||
True if it is a key in a dict
|
||||
False if our item is an item in a list
|
||||
"""
|
||||
key_or_value = 'value'
|
||||
if key_type:
|
||||
key_or_value = 'key'
|
||||
valid_classes_phrase = get_valid_classes_phrase(valid_classes)
|
||||
msg = (
|
||||
"Invalid type for variable '{0}'. Required {1} type {2} and "
|
||||
"passed type was {3}".format(
|
||||
var_name,
|
||||
key_or_value,
|
||||
valid_classes_phrase,
|
||||
type(var_value).__name__,
|
||||
)
|
||||
)
|
||||
return msg
|
||||
|
||||
|
||||
def get_valid_classes_phrase(input_classes):
|
||||
"""Returns a string phrase describing what types are allowed
|
||||
Note: Adds the extra valid classes in python2
|
||||
"""
|
||||
all_classes = list(input_classes)
|
||||
if six.PY2 and str in input_classes:
|
||||
all_classes.extend([str_py2, unicode_py2])
|
||||
if six.PY2 and int in input_classes:
|
||||
all_classes.extend([int_py2, long_py2])
|
||||
all_classes = sorted(all_classes, key=lambda cls: cls.__name__)
|
||||
all_class_names = [cls.__name__ for cls in all_classes]
|
||||
if len(all_class_names) == 1:
|
||||
return 'is {0}'.format(all_class_names[0])
|
||||
return "is one of [{0}]".format(", ".join(all_class_names))
|
||||
|
||||
|
||||
def get_py3_class_name(input_class):
|
||||
if six.PY2:
|
||||
if input_class == str:
|
||||
return 'str'
|
||||
elif input_class == int:
|
||||
return 'int'
|
||||
return input_class.__name__
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
certifi >= 14.05.14
|
||||
future; python_version<="2.7"
|
||||
six >= 1.10
|
||||
python_dateutil >= 2.5.3
|
||||
setuptools >= 21.0.0
|
||||
urllib3 >= 1.15.1
|
||||
45
modules/openapi-generator/src/main/resources/python/python-experimental/setup.mustache
vendored
Normal file
45
modules/openapi-generator/src/main/resources/python/python-experimental/setup.mustache
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from setuptools import setup, find_packages # noqa: H301
|
||||
|
||||
NAME = "{{{projectName}}}"
|
||||
VERSION = "{{packageVersion}}"
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{^hasMore}}
|
||||
# To install the library, run the following
|
||||
#
|
||||
# python setup.py install
|
||||
#
|
||||
# prerequisite: setuptools
|
||||
# http://pypi.python.org/pypi/setuptools
|
||||
|
||||
REQUIRES = ["urllib3 >= 1.15", "six >= 1.10", "certifi", "python-dateutil"]
|
||||
{{#asyncio}}
|
||||
REQUIRES.append("aiohttp >= 3.0.0")
|
||||
{{/asyncio}}
|
||||
{{#tornado}}
|
||||
REQUIRES.append("tornado>=4.2,<5")
|
||||
{{/tornado}}
|
||||
EXTRAS = {':python_version <= "2.7"': ['future']}
|
||||
|
||||
setup(
|
||||
name=NAME,
|
||||
version=VERSION,
|
||||
description="{{appName}}",
|
||||
author_email="{{infoEmail}}",
|
||||
url="{{packageUrl}}",
|
||||
keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"],
|
||||
install_requires=REQUIRES,
|
||||
extras_require=EXTRAS,
|
||||
packages=find_packages(exclude=["test", "tests"]),
|
||||
include_package_data=True,
|
||||
long_description="""\
|
||||
{{appDescription}} # noqa: E501
|
||||
"""
|
||||
)
|
||||
{{/hasMore}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
@@ -0,0 +1,13 @@
|
||||
{{^asyncio}}
|
||||
coverage>=4.0.3
|
||||
nose>=1.3.7
|
||||
{{/asyncio}}
|
||||
{{#asyncio}}
|
||||
pytest>=3.6.0
|
||||
pytest-cov>=2.6.1
|
||||
{{/asyncio}}
|
||||
pluggy>=0.3.1
|
||||
py>=1.4.31
|
||||
randomize>=0.13
|
||||
mock; python_version<="2.7"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
certifi >= 14.05.14
|
||||
future; python_version<="2.7"
|
||||
six >= 1.10
|
||||
python_dateutil >= 2.5.3
|
||||
setuptools >= 21.0.0
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.python;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.languages.PythonClientExperimentalCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public class PythonClientExperimentalTest {
|
||||
|
||||
@Test(description = "convert a python model with dots")
|
||||
public void modelTest() {
|
||||
final OpenAPI openAPI= TestUtils.parseSpec("src/test/resources/2_0/v1beta3.json");
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
codegen.setOpenAPI(openAPI);
|
||||
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel simpleName = codegen.fromModel("v1beta3.Binding", openAPI.getComponents().getSchemas().get("v1beta3.Binding"));
|
||||
Assert.assertEquals(simpleName.name, "v1beta3.Binding");
|
||||
Assert.assertEquals(simpleName.classname, "V1beta3Binding");
|
||||
Assert.assertEquals(simpleName.classVarName, "v1beta3_binding");
|
||||
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel compoundName = codegen.fromModel("v1beta3.ComponentStatus", openAPI.getComponents().getSchemas().get("v1beta3.ComponentStatus"));
|
||||
Assert.assertEquals(compoundName.name, "v1beta3.ComponentStatus");
|
||||
Assert.assertEquals(compoundName.classname, "V1beta3ComponentStatus");
|
||||
Assert.assertEquals(compoundName.classVarName, "v1beta3_component_status");
|
||||
|
||||
final String path = "/api/v1beta3/namespaces/{namespaces}/bindings";
|
||||
final Operation operation = openAPI.getPaths().get(path).getPost();
|
||||
final CodegenOperation codegenOperation = codegen.fromOperation(path, "get", operation, null);
|
||||
Assert.assertEquals(codegenOperation.returnType, "V1beta3Binding");
|
||||
Assert.assertEquals(codegenOperation.returnBaseType, "V1beta3Binding");
|
||||
}
|
||||
|
||||
@Test(description = "convert a simple java model")
|
||||
public void simpleModelTest() {
|
||||
final Schema schema = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("name", new StringSchema())
|
||||
.addProperties("createdAt", new DateTimeSchema())
|
||||
.addRequiredItem("id")
|
||||
.addRequiredItem("name");
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", schema);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 3);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.dataType, "int");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertNull(property1.defaultValue);
|
||||
Assert.assertEquals(property1.baseType, "int");
|
||||
Assert.assertTrue(property1.hasMore);
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "name");
|
||||
Assert.assertEquals(property2.dataType, "str");
|
||||
Assert.assertEquals(property2.name, "name");
|
||||
Assert.assertNull(property2.defaultValue);
|
||||
Assert.assertEquals(property2.baseType, "str");
|
||||
Assert.assertTrue(property2.hasMore);
|
||||
Assert.assertTrue(property2.required);
|
||||
Assert.assertTrue(property2.isPrimitiveType);
|
||||
|
||||
final CodegenProperty property3 = cm.vars.get(2);
|
||||
Assert.assertEquals(property3.baseName, "createdAt");
|
||||
Assert.assertEquals(property3.dataType, "datetime");
|
||||
Assert.assertEquals(property3.name, "created_at");
|
||||
Assert.assertNull(property3.defaultValue);
|
||||
Assert.assertEquals(property3.baseType, "datetime");
|
||||
Assert.assertFalse(property3.hasMore);
|
||||
Assert.assertFalse(property3.required);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with list property")
|
||||
public void listPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("id", new IntegerSchema().format(SchemaTypeUtil.INTEGER64_FORMAT))
|
||||
.addProperties("urls", new ArraySchema()
|
||||
.items(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 2);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "id");
|
||||
Assert.assertEquals(property1.dataType, "int");
|
||||
Assert.assertEquals(property1.name, "id");
|
||||
Assert.assertNull(property1.defaultValue);
|
||||
Assert.assertEquals(property1.baseType, "int");
|
||||
Assert.assertTrue(property1.hasMore);
|
||||
Assert.assertTrue(property1.required);
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
|
||||
final CodegenProperty property2 = cm.vars.get(1);
|
||||
Assert.assertEquals(property2.baseName, "urls");
|
||||
Assert.assertEquals(property2.dataType, "[str]");
|
||||
Assert.assertEquals(property2.name, "urls");
|
||||
Assert.assertNull(property2.defaultValue);
|
||||
Assert.assertEquals(property2.baseType, "list");
|
||||
Assert.assertFalse(property2.hasMore);
|
||||
Assert.assertEquals(property2.containerType, "array");
|
||||
Assert.assertFalse(property2.required);
|
||||
Assert.assertTrue(property2.isPrimitiveType);
|
||||
Assert.assertTrue(property2.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with a map property")
|
||||
public void mapPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("translations", new MapSchema()
|
||||
.additionalProperties(new StringSchema()))
|
||||
.addRequiredItem("id");
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "translations");
|
||||
Assert.assertEquals(property1.dataType, "{str: (str,)}");
|
||||
Assert.assertEquals(property1.name, "translations");
|
||||
Assert.assertEquals(property1.baseType, "dict");
|
||||
Assert.assertEquals(property1.containerType, "map");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertTrue(property1.isContainer);
|
||||
Assert.assertTrue(property1.isPrimitiveType);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex property")
|
||||
public void complexPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new Schema().$ref("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.dataType, "Children");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "Children");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertFalse(property1.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex list property")
|
||||
public void complexListPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new ArraySchema()
|
||||
.items(new Schema().$ref("#/definitions/Children")));
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.complexType, "Children");
|
||||
Assert.assertEquals(property1.dataType, "[Children]");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "list");
|
||||
Assert.assertEquals(property1.containerType, "array");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertTrue(property1.isContainer);
|
||||
}
|
||||
|
||||
@Test(description = "convert a model with complex map property")
|
||||
public void complexMapPropertyTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a sample model")
|
||||
.addProperties("children", new MapSchema()
|
||||
.additionalProperties(new Schema().$ref("#/definitions/Children")));
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a sample model");
|
||||
Assert.assertEquals(cm.vars.size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
|
||||
|
||||
final CodegenProperty property1 = cm.vars.get(0);
|
||||
Assert.assertEquals(property1.baseName, "children");
|
||||
Assert.assertEquals(property1.complexType, "Children");
|
||||
Assert.assertEquals(property1.dataType, "{str: (Children,)}");
|
||||
Assert.assertEquals(property1.name, "children");
|
||||
Assert.assertEquals(property1.baseType, "dict");
|
||||
Assert.assertEquals(property1.containerType, "map");
|
||||
Assert.assertFalse(property1.required);
|
||||
Assert.assertTrue(property1.isContainer);
|
||||
}
|
||||
|
||||
|
||||
// should not start with 'null'. need help from the community to investigate further
|
||||
@Test(description = "convert an array model")
|
||||
public void arrayModelTest() {
|
||||
final Schema model = new ArraySchema()
|
||||
//.description()
|
||||
.items(new Schema().$ref("#/definitions/Children"))
|
||||
.description("an array model");
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "an array model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
Assert.assertEquals(cm.parent, "list");
|
||||
Assert.assertEquals(cm.imports.size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
|
||||
}
|
||||
|
||||
// should not start with 'null'. need help from the community to investigate further
|
||||
@Test(description = "convert a map model")
|
||||
public void mapModelTest() {
|
||||
final Schema model = new Schema()
|
||||
.description("a map model")
|
||||
.additionalProperties(new Schema().$ref("#/definitions/Children"));
|
||||
final DefaultCodegen codegen = new PythonClientExperimentalCodegen();
|
||||
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
|
||||
codegen.setOpenAPI(openAPI);
|
||||
final CodegenModel cm = codegen.fromModel("sample", model);
|
||||
|
||||
Assert.assertEquals(cm.name, "sample");
|
||||
Assert.assertEquals(cm.classname, "Sample");
|
||||
Assert.assertEquals(cm.description, "a map model");
|
||||
Assert.assertEquals(cm.vars.size(), 0);
|
||||
Assert.assertEquals(cm.parent, "dict");
|
||||
Assert.assertEquals(cm.imports.size(), 1);
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -294,4 +294,4 @@ public class PythonTest {
|
||||
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -269,6 +269,13 @@ paths:
|
||||
description: file to upload
|
||||
required: false
|
||||
type: file
|
||||
- name: files
|
||||
in: formData
|
||||
description: files to upload
|
||||
required: false
|
||||
type: array
|
||||
items:
|
||||
type: file
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
certifi >= 14.05.14
|
||||
future; python_version<="2.7"
|
||||
six >= 1.10
|
||||
python_dateutil >= 2.5.3
|
||||
setuptools >= 21.0.0
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
**any string name** | **[bool, date, datetime, dict, float, int, list, str]** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**map_string** | **dict(str, str)** | | [optional]
|
||||
**map_number** | **dict(str, float)** | | [optional]
|
||||
**map_integer** | **dict(str, int)** | | [optional]
|
||||
**map_boolean** | **dict(str, bool)** | | [optional]
|
||||
**map_array_integer** | **dict(str, list[int])** | | [optional]
|
||||
**map_array_anytype** | **dict(str, list[object])** | | [optional]
|
||||
**map_map_string** | **dict(str, dict(str, str))** | | [optional]
|
||||
**map_map_anytype** | **dict(str, dict(str, object))** | | [optional]
|
||||
**anytype_1** | [**object**](.md) | | [optional]
|
||||
**anytype_2** | [**object**](.md) | | [optional]
|
||||
**anytype_3** | [**object**](.md) | | [optional]
|
||||
**map_string** | **{str: (str,)}** | | [optional]
|
||||
**map_number** | **{str: (float,)}** | | [optional]
|
||||
**map_integer** | **{str: (int,)}** | | [optional]
|
||||
**map_boolean** | **{str: (bool,)}** | | [optional]
|
||||
**map_array_integer** | **{str: ([int],)}** | | [optional]
|
||||
**map_array_anytype** | **{str: ([bool, date, datetime, dict, float, int, list, str],)}** | | [optional]
|
||||
**map_map_string** | **{str: ({str: (str,)},)}** | | [optional]
|
||||
**map_map_anytype** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)}** | | [optional]
|
||||
**anytype_1** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional]
|
||||
**anytype_2** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional]
|
||||
**anytype_3** | [**bool, date, datetime, dict, float, int, list, str**](.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
**any string name** | **int** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
**any string name** | **float** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
**any string name** | **{str: (bool, date, datetime, dict, float, int, list, str,)}** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
**any string name** | **str** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_array_number** | **list[list[float]]** | | [optional]
|
||||
**array_array_number** | **[[float]]** | | [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)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_number** | **list[float]** | | [optional]
|
||||
**array_number** | **[float]** | | [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)
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_of_string** | **list[str]** | | [optional]
|
||||
**array_array_of_integer** | **list[list[int]]** | | [optional]
|
||||
**array_array_of_model** | **list[list[ReadOnlyFirst]]** | | [optional]
|
||||
**array_of_string** | **[str]** | | [optional]
|
||||
**array_array_of_integer** | **[[int]]** | | [optional]
|
||||
**array_array_of_model** | **[[ReadOnlyFirst]]** | | [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)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**just_symbol** | **str** | | [optional]
|
||||
**array_enum** | **list[str]** | | [optional]
|
||||
**array_enum** | **[str]** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -591,7 +591,7 @@ int32 = 56 # int | None (optional)
|
||||
int64 = 56 # int | None (optional)
|
||||
float = 3.4 # float | None (optional)
|
||||
string = 'string_example' # str | None (optional)
|
||||
binary = '/path/to/file' # file | None (optional)
|
||||
binary = open('/path/to/file', 'rb') # file_type | None (optional)
|
||||
date = '2013-10-20' # date | None (optional)
|
||||
date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
|
||||
password = 'password_example' # str | None (optional)
|
||||
@@ -617,7 +617,7 @@ Name | Type | Description | Notes
|
||||
**int64** | **int**| None | [optional]
|
||||
**float** | **float**| None | [optional]
|
||||
**string** | **str**| None | [optional]
|
||||
**binary** | **file**| None | [optional]
|
||||
**binary** | **file_type**| None | [optional]
|
||||
**date** | **date**| None | [optional]
|
||||
**date_time** | **datetime**| None | [optional]
|
||||
**password** | **str**| None | [optional]
|
||||
@@ -662,13 +662,13 @@ from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # list[str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string_array = ['enum_header_string_array_example'] # [str] | Header parameter enum test (string array) (optional)
|
||||
enum_header_string = '-efg' # str | Header parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # list[str] | Query parameter enum test (string array) (optional)
|
||||
enum_query_string_array = ['enum_query_string_array_example'] # [str] | Query parameter enum test (string array) (optional)
|
||||
enum_query_string = '-efg' # str | Query parameter enum test (string) (optional) (default to '-efg')
|
||||
enum_query_integer = 56 # int | Query parameter enum test (double) (optional)
|
||||
enum_query_double = 3.4 # float | Query parameter enum test (double) (optional)
|
||||
enum_form_string_array = '$' # list[str] | Form parameter enum test (string array) (optional) (default to '$')
|
||||
enum_form_string_array = '$' # [str] | Form parameter enum test (string array) (optional) (default to '$')
|
||||
enum_form_string = '-efg' # str | Form parameter enum test (string) (optional) (default to '-efg')
|
||||
|
||||
try:
|
||||
@@ -682,13 +682,13 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**enum_header_string_array** | [**list[str]**](str.md)| Header parameter enum test (string array) | [optional]
|
||||
**enum_header_string_array** | [**[str]**](str.md)| 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]**](str.md)| Query parameter enum test (string array) | [optional]
|
||||
**enum_query_string_array** | [**[str]**](str.md)| 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]**](str.md)| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$'
|
||||
**enum_form_string_array** | [**[str]**](str.md)| Form parameter enum test (string array) | [optional] if omitted the server will use the default value of '$'
|
||||
**enum_form_string** | **str**| Form parameter enum test (string) | [optional] if omitted the server will use the default value of '-efg'
|
||||
|
||||
### Return type
|
||||
@@ -791,7 +791,7 @@ from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.FakeApi()
|
||||
param = {'key': 'param_example'} # dict(str, str) | request body
|
||||
param = {'key': 'param_example'} # {str: (str,)} | request body
|
||||
|
||||
try:
|
||||
# test inline additionalProperties
|
||||
@@ -804,7 +804,7 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**param** | [**dict(str, str)**](str.md)| request body |
|
||||
**param** | [**{str: (str,)}**](str.md)| request body |
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**file** | [**File**](File.md) | | [optional]
|
||||
**files** | [**list[File]**](File.md) | | [optional]
|
||||
**files** | [**[File]**](File.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ Name | Type | Description | Notes
|
||||
**float** | **float** | | [optional]
|
||||
**double** | **float** | | [optional]
|
||||
**string** | **str** | | [optional]
|
||||
**binary** | **file** | | [optional]
|
||||
**binary** | **file_type** | | [optional]
|
||||
**date_time** | **datetime** | | [optional]
|
||||
**uuid** | **str** | | [optional]
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
## Properties
|
||||
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]
|
||||
**map_map_of_string** | **{str: ({str: (str,)},)}** | | [optional]
|
||||
**map_of_enum_string** | **{str: (str,)}** | | [optional]
|
||||
**direct_map** | **{str: (bool,)}** | | [optional]
|
||||
**indirect_map** | [**StringBooleanMap**](StringBooleanMap.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
@@ -5,7 +5,7 @@ Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**uuid** | **str** | | [optional]
|
||||
**date_time** | **datetime** | | [optional]
|
||||
**map** | [**dict(str, Animal)**](Animal.md) | | [optional]
|
||||
**map** | [**{str: (Animal,)}**](Animal.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | |
|
||||
**photo_urls** | **list[str]** | |
|
||||
**photo_urls** | **[str]** | |
|
||||
**id** | **int** | | [optional]
|
||||
**category** | [**Category**](Category.md) | | [optional]
|
||||
**tags** | [**list[Tag]**](Tag.md) | | [optional]
|
||||
**tags** | [**[Tag]**](Tag.md) | | [optional]
|
||||
**status** | **str** | pet status in the store | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
@@ -134,7 +134,7 @@ void (empty response body)
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **find_pets_by_status**
|
||||
> list[Pet] find_pets_by_status(status)
|
||||
> [Pet] find_pets_by_status(status)
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
@@ -157,7 +157,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
status = ['status_example'] # list[str] | Status values that need to be considered for filter
|
||||
status = ['status_example'] # [str] | Status values that need to be considered for filter
|
||||
|
||||
try:
|
||||
# Finds Pets by status
|
||||
@@ -171,11 +171,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**list[str]**](str.md)| Status values that need to be considered for filter |
|
||||
**status** | [**[str]**](str.md)| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**list[Pet]**](Pet.md)
|
||||
[**[Pet]**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -195,7 +195,7 @@ Name | Type | Description | Notes
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **find_pets_by_tags**
|
||||
> list[Pet] find_pets_by_tags(tags)
|
||||
> [Pet] find_pets_by_tags(tags)
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
@@ -218,7 +218,7 @@ configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
tags = ['tags_example'] # list[str] | Tags to filter by
|
||||
tags = ['tags_example'] # [str] | Tags to filter by
|
||||
|
||||
try:
|
||||
# Finds Pets by tags
|
||||
@@ -232,11 +232,11 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**list[str]**](str.md)| Tags to filter by |
|
||||
**tags** | [**[str]**](str.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**list[Pet]**](Pet.md)
|
||||
[**[Pet]**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -464,11 +464,12 @@ configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
file = '/path/to/file' # file | file to upload (optional)
|
||||
file = open('/path/to/file', 'rb') # file_type | file to upload (optional)
|
||||
files = open('/path/to/file', 'rb') # [file_type] | files to upload (optional)
|
||||
|
||||
try:
|
||||
# uploads an image
|
||||
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file)
|
||||
api_response = api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file, files=files)
|
||||
pprint(api_response)
|
||||
except ApiException as e:
|
||||
print("Exception when calling PetApi->upload_file: %s\n" % e)
|
||||
@@ -480,7 +481,8 @@ Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **int**| ID of pet to update |
|
||||
**additional_metadata** | **str**| Additional data to pass to server | [optional]
|
||||
**file** | **file**| file to upload | [optional]
|
||||
**file** | **file_type**| file to upload | [optional]
|
||||
**files** | [**[file_type]**](file_type.md)| files to upload | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -525,7 +527,7 @@ configuration.host = "http://petstore.swagger.io:80/v2"
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(petstore_api.ApiClient(configuration))
|
||||
pet_id = 56 # int | ID of pet to update
|
||||
required_file = '/path/to/file' # file | file to upload
|
||||
required_file = open('/path/to/file', 'rb') # file_type | file to upload
|
||||
additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional)
|
||||
|
||||
try:
|
||||
@@ -541,7 +543,7 @@ except ApiException as e:
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **int**| ID of pet to update |
|
||||
**required_file** | **file**| file to upload |
|
||||
**required_file** | **file_type**| file to upload |
|
||||
**additional_metadata** | **str**| Additional data to pass to server | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -65,7 +65,7 @@ No authorization required
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **get_inventory**
|
||||
> dict(str, int) get_inventory()
|
||||
> {str: (int,)} get_inventory()
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
@@ -104,7 +104,7 @@ This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**dict(str, int)**
|
||||
**{str: (int,)}**
|
||||
|
||||
### Authorization
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**any string name** | **bool** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_item** | **list[int]** | |
|
||||
**array_item** | **[int]** | |
|
||||
**string_item** | **str** | | defaults to 'what'
|
||||
**number_item** | **float** | | defaults to 1.234
|
||||
**integer_item** | **int** | | defaults to -2
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bool_item** | **bool** | |
|
||||
**array_item** | **list[int]** | |
|
||||
**array_item** | **[int]** | |
|
||||
**string_item** | **str** | | defaults to 'what'
|
||||
**number_item** | **float** | | defaults to 1.234
|
||||
**integer_item** | **int** | | defaults to -2
|
||||
|
||||
@@ -83,7 +83,7 @@ from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
body = [petstore_api.User()] # list[User] | List of user object
|
||||
body = [petstore_api.User()] # [User] | List of user object
|
||||
|
||||
try:
|
||||
# Creates list of users with given input array
|
||||
@@ -96,7 +96,7 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**list[User]**](User.md)| List of user object |
|
||||
**body** | [**[User]**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
@@ -134,7 +134,7 @@ from pprint import pprint
|
||||
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.UserApi()
|
||||
body = [petstore_api.User()] # list[User] | List of user object
|
||||
body = [petstore_api.User()] # [User] | List of user object
|
||||
|
||||
try:
|
||||
# Creates list of users with given input array
|
||||
@@ -147,7 +147,7 @@ except ApiException as e:
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**list[User]**](User.md)| List of user object |
|
||||
**body** | [**[User]**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
|
||||
@@ -7,31 +7,31 @@ Name | Type | Description | Notes
|
||||
**attribute_number** | **float** | | [optional]
|
||||
**attribute_integer** | **int** | | [optional]
|
||||
**attribute_boolean** | **bool** | | [optional]
|
||||
**wrapped_array** | **list[int]** | | [optional]
|
||||
**wrapped_array** | **[int]** | | [optional]
|
||||
**name_string** | **str** | | [optional]
|
||||
**name_number** | **float** | | [optional]
|
||||
**name_integer** | **int** | | [optional]
|
||||
**name_boolean** | **bool** | | [optional]
|
||||
**name_array** | **list[int]** | | [optional]
|
||||
**name_wrapped_array** | **list[int]** | | [optional]
|
||||
**name_array** | **[int]** | | [optional]
|
||||
**name_wrapped_array** | **[int]** | | [optional]
|
||||
**prefix_string** | **str** | | [optional]
|
||||
**prefix_number** | **float** | | [optional]
|
||||
**prefix_integer** | **int** | | [optional]
|
||||
**prefix_boolean** | **bool** | | [optional]
|
||||
**prefix_array** | **list[int]** | | [optional]
|
||||
**prefix_wrapped_array** | **list[int]** | | [optional]
|
||||
**prefix_array** | **[int]** | | [optional]
|
||||
**prefix_wrapped_array** | **[int]** | | [optional]
|
||||
**namespace_string** | **str** | | [optional]
|
||||
**namespace_number** | **float** | | [optional]
|
||||
**namespace_integer** | **int** | | [optional]
|
||||
**namespace_boolean** | **bool** | | [optional]
|
||||
**namespace_array** | **list[int]** | | [optional]
|
||||
**namespace_wrapped_array** | **list[int]** | | [optional]
|
||||
**namespace_array** | **[int]** | | [optional]
|
||||
**namespace_wrapped_array** | **[int]** | | [optional]
|
||||
**prefix_ns_string** | **str** | | [optional]
|
||||
**prefix_ns_number** | **float** | | [optional]
|
||||
**prefix_ns_integer** | **int** | | [optional]
|
||||
**prefix_ns_boolean** | **bool** | | [optional]
|
||||
**prefix_ns_array** | **list[int]** | | [optional]
|
||||
**prefix_ns_wrapped_array** | **list[int]** | | [optional]
|
||||
**prefix_ns_array** | **[int]** | | [optional]
|
||||
**prefix_ns_wrapped_array** | **[int]** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
||||
@@ -22,10 +22,18 @@ from petstore_api.exceptions import (
|
||||
ApiTypeError,
|
||||
ApiValueError
|
||||
)
|
||||
from petstore_api.model_utils import (
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
int,
|
||||
none_type,
|
||||
str,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.client import Client
|
||||
|
||||
|
||||
class AnotherFakeApi(object):
|
||||
@@ -50,28 +58,55 @@ class AnotherFakeApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param Client body: client model (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: Client
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.call_123_test_special_tags = Endpoint(
|
||||
settings={
|
||||
'response_type': 'Client',
|
||||
'response_type': (Client,),
|
||||
'auth': [],
|
||||
'endpoint_path': '/another-fake/dummy',
|
||||
'operation_id': 'call_123_test_special_tags',
|
||||
@@ -98,7 +133,7 @@ class AnotherFakeApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'body': 'Client',
|
||||
'body': (Client,),
|
||||
},
|
||||
'attribute_map': {
|
||||
},
|
||||
@@ -128,7 +163,7 @@ class Endpoint(object):
|
||||
|
||||
Args:
|
||||
settings (dict): see below key value pairs
|
||||
'response_type' (str): response type
|
||||
'response_type' (tuple/None): response type
|
||||
'auth' (list): a list of auth type keys
|
||||
'endpoint_path' (str): the endpoint path
|
||||
'operation_id' (str): endpoint string identifier
|
||||
@@ -164,11 +199,24 @@ class Endpoint(object):
|
||||
'_host_index',
|
||||
'_preload_content',
|
||||
'_request_timeout',
|
||||
'_return_http_data_only'
|
||||
'_return_http_data_only',
|
||||
'_check_input_type',
|
||||
'_check_return_type'
|
||||
])
|
||||
self.params_map['nullable'].extend(['_request_timeout'])
|
||||
self.validations = root_map['validations']
|
||||
self.allowed_values = root_map['allowed_values']
|
||||
self.openapi_types = root_map['openapi_types']
|
||||
extra_types = {
|
||||
'async_req': (bool,),
|
||||
'_host_index': (int,),
|
||||
'_preload_content': (bool,),
|
||||
'_request_timeout': (none_type, int, (int,), [int]),
|
||||
'_return_http_data_only': (bool,),
|
||||
'_check_input_type': (bool,),
|
||||
'_check_return_type': (bool,)
|
||||
}
|
||||
self.openapi_types.update(extra_types)
|
||||
self.attribute_map = root_map['attribute_map']
|
||||
self.location_map = root_map['location_map']
|
||||
self.collection_format_map = root_map['collection_format_map']
|
||||
@@ -182,8 +230,7 @@ class Endpoint(object):
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(param,),
|
||||
kwargs[param],
|
||||
self.validations
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
for param in self.params_map['validation']:
|
||||
@@ -194,6 +241,20 @@ class Endpoint(object):
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
if kwargs['_check_input_type'] is False:
|
||||
return
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
fixed_val = validate_and_convert_types(
|
||||
value,
|
||||
self.openapi_types[key],
|
||||
[key],
|
||||
False,
|
||||
kwargs['_check_input_type'],
|
||||
configuration=self.api_client.configuration
|
||||
)
|
||||
kwargs[key] = fixed_val
|
||||
|
||||
def __gather_params(self, kwargs):
|
||||
params = {
|
||||
'body': None,
|
||||
@@ -207,14 +268,20 @@ class Endpoint(object):
|
||||
|
||||
for param_name, param_value in six.iteritems(kwargs):
|
||||
param_location = self.location_map.get(param_name)
|
||||
if param_location is None:
|
||||
continue
|
||||
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'
|
||||
self.openapi_types[param_name] == (file_type,)):
|
||||
params['file'][param_name] = [param_value]
|
||||
elif (param_location == 'form' and
|
||||
self.openapi_types[param_name] == ([file_type],)):
|
||||
# param_value is already a list
|
||||
params['file'][param_name] = param_value
|
||||
elif param_location in {'form', 'query'}:
|
||||
param_value_full = (base_name, param_value)
|
||||
params[param_location].append(param_value_full)
|
||||
@@ -239,20 +306,15 @@ class Endpoint(object):
|
||||
|
||||
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:
|
||||
try:
|
||||
_host = self.settings['servers'][kwargs['_host_index']]
|
||||
except IndexError:
|
||||
if self.settings['servers']:
|
||||
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
|
||||
_host = None
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
if key not in self.params_map['all']:
|
||||
@@ -261,7 +323,11 @@ class Endpoint(object):
|
||||
" to method `%s`" %
|
||||
(key, self.settings['operation_id'])
|
||||
)
|
||||
if key not in self.params_map['nullable'] and value is None:
|
||||
# only throw this nullable ApiValueError if _check_input_type
|
||||
# is False, if _check_input_type==True we catch this case
|
||||
# in self.__validate_inputs
|
||||
if (key not in self.params_map['nullable'] and value is None
|
||||
and kwargs['_check_input_type'] is False):
|
||||
raise ApiValueError(
|
||||
"Value may not be None for non-nullable parameter `%s`"
|
||||
" when calling `%s`" %
|
||||
@@ -300,9 +366,10 @@ class Endpoint(object):
|
||||
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'),
|
||||
async_req=kwargs['async_req'],
|
||||
_check_type=kwargs['_check_return_type'],
|
||||
_return_http_data_only=kwargs['_return_http_data_only'],
|
||||
_preload_content=kwargs['_preload_content'],
|
||||
_request_timeout=kwargs['_request_timeout'],
|
||||
_host=_host,
|
||||
collection_formats=params['collection_format'])
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,10 +22,18 @@ from petstore_api.exceptions import (
|
||||
ApiTypeError,
|
||||
ApiValueError
|
||||
)
|
||||
from petstore_api.model_utils import (
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
int,
|
||||
none_type,
|
||||
str,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.client import Client
|
||||
|
||||
|
||||
class FakeClassnameTags123Api(object):
|
||||
@@ -50,28 +58,55 @@ class FakeClassnameTags123Api(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param Client body: client model (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: Client
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.test_classname = Endpoint(
|
||||
settings={
|
||||
'response_type': 'Client',
|
||||
'response_type': (Client,),
|
||||
'auth': [
|
||||
'api_key_query'
|
||||
],
|
||||
@@ -100,7 +135,7 @@ class FakeClassnameTags123Api(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'body': 'Client',
|
||||
'body': (Client,),
|
||||
},
|
||||
'attribute_map': {
|
||||
},
|
||||
@@ -130,7 +165,7 @@ class Endpoint(object):
|
||||
|
||||
Args:
|
||||
settings (dict): see below key value pairs
|
||||
'response_type' (str): response type
|
||||
'response_type' (tuple/None): response type
|
||||
'auth' (list): a list of auth type keys
|
||||
'endpoint_path' (str): the endpoint path
|
||||
'operation_id' (str): endpoint string identifier
|
||||
@@ -166,11 +201,24 @@ class Endpoint(object):
|
||||
'_host_index',
|
||||
'_preload_content',
|
||||
'_request_timeout',
|
||||
'_return_http_data_only'
|
||||
'_return_http_data_only',
|
||||
'_check_input_type',
|
||||
'_check_return_type'
|
||||
])
|
||||
self.params_map['nullable'].extend(['_request_timeout'])
|
||||
self.validations = root_map['validations']
|
||||
self.allowed_values = root_map['allowed_values']
|
||||
self.openapi_types = root_map['openapi_types']
|
||||
extra_types = {
|
||||
'async_req': (bool,),
|
||||
'_host_index': (int,),
|
||||
'_preload_content': (bool,),
|
||||
'_request_timeout': (none_type, int, (int,), [int]),
|
||||
'_return_http_data_only': (bool,),
|
||||
'_check_input_type': (bool,),
|
||||
'_check_return_type': (bool,)
|
||||
}
|
||||
self.openapi_types.update(extra_types)
|
||||
self.attribute_map = root_map['attribute_map']
|
||||
self.location_map = root_map['location_map']
|
||||
self.collection_format_map = root_map['collection_format_map']
|
||||
@@ -184,8 +232,7 @@ class Endpoint(object):
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(param,),
|
||||
kwargs[param],
|
||||
self.validations
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
for param in self.params_map['validation']:
|
||||
@@ -196,6 +243,20 @@ class Endpoint(object):
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
if kwargs['_check_input_type'] is False:
|
||||
return
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
fixed_val = validate_and_convert_types(
|
||||
value,
|
||||
self.openapi_types[key],
|
||||
[key],
|
||||
False,
|
||||
kwargs['_check_input_type'],
|
||||
configuration=self.api_client.configuration
|
||||
)
|
||||
kwargs[key] = fixed_val
|
||||
|
||||
def __gather_params(self, kwargs):
|
||||
params = {
|
||||
'body': None,
|
||||
@@ -209,14 +270,20 @@ class Endpoint(object):
|
||||
|
||||
for param_name, param_value in six.iteritems(kwargs):
|
||||
param_location = self.location_map.get(param_name)
|
||||
if param_location is None:
|
||||
continue
|
||||
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'
|
||||
self.openapi_types[param_name] == (file_type,)):
|
||||
params['file'][param_name] = [param_value]
|
||||
elif (param_location == 'form' and
|
||||
self.openapi_types[param_name] == ([file_type],)):
|
||||
# param_value is already a list
|
||||
params['file'][param_name] = param_value
|
||||
elif param_location in {'form', 'query'}:
|
||||
param_value_full = (base_name, param_value)
|
||||
params[param_location].append(param_value_full)
|
||||
@@ -241,20 +308,15 @@ class Endpoint(object):
|
||||
|
||||
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:
|
||||
try:
|
||||
_host = self.settings['servers'][kwargs['_host_index']]
|
||||
except IndexError:
|
||||
if self.settings['servers']:
|
||||
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
|
||||
_host = None
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
if key not in self.params_map['all']:
|
||||
@@ -263,7 +325,11 @@ class Endpoint(object):
|
||||
" to method `%s`" %
|
||||
(key, self.settings['operation_id'])
|
||||
)
|
||||
if key not in self.params_map['nullable'] and value is None:
|
||||
# only throw this nullable ApiValueError if _check_input_type
|
||||
# is False, if _check_input_type==True we catch this case
|
||||
# in self.__validate_inputs
|
||||
if (key not in self.params_map['nullable'] and value is None
|
||||
and kwargs['_check_input_type'] is False):
|
||||
raise ApiValueError(
|
||||
"Value may not be None for non-nullable parameter `%s`"
|
||||
" when calling `%s`" %
|
||||
@@ -302,9 +368,10 @@ class Endpoint(object):
|
||||
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'),
|
||||
async_req=kwargs['async_req'],
|
||||
_check_type=kwargs['_check_return_type'],
|
||||
_return_http_data_only=kwargs['_return_http_data_only'],
|
||||
_preload_content=kwargs['_preload_content'],
|
||||
_request_timeout=kwargs['_request_timeout'],
|
||||
_host=_host,
|
||||
collection_formats=params['collection_format'])
|
||||
|
||||
@@ -22,10 +22,19 @@ from petstore_api.exceptions import (
|
||||
ApiTypeError,
|
||||
ApiValueError
|
||||
)
|
||||
from petstore_api.model_utils import (
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
int,
|
||||
none_type,
|
||||
str,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.api_response import ApiResponse
|
||||
from petstore_api.models.pet import Pet
|
||||
|
||||
|
||||
class PetApi(object):
|
||||
@@ -49,22 +58,49 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param Pet body: Pet object that needs to be added to the store (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -99,7 +135,7 @@ class PetApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'body': 'Pet',
|
||||
'body': (Pet,),
|
||||
},
|
||||
'attribute_map': {
|
||||
},
|
||||
@@ -129,23 +165,50 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
: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
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['pet_id'] = pet_id
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -181,8 +244,8 @@ class PetApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'pet_id': 'int',
|
||||
'api_key': 'str',
|
||||
'pet_id': (int,),
|
||||
'api_key': (str,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'pet_id': 'petId',
|
||||
@@ -213,28 +276,55 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param list[str] status: Status values that need to be considered for filter (required)
|
||||
Default is False.
|
||||
:param [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
|
||||
code and headers. Default is True.
|
||||
: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: list[Pet]
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: [Pet]
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['status'] = status
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.find_pets_by_status = Endpoint(
|
||||
settings={
|
||||
'response_type': 'list[Pet]',
|
||||
'response_type': ([Pet],),
|
||||
'auth': [
|
||||
'petstore_auth'
|
||||
],
|
||||
@@ -270,7 +360,7 @@ class PetApi(object):
|
||||
},
|
||||
},
|
||||
'openapi_types': {
|
||||
'status': 'list[str]',
|
||||
'status': ([str],),
|
||||
},
|
||||
'attribute_map': {
|
||||
'status': 'status',
|
||||
@@ -303,28 +393,55 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param list[str] tags: Tags to filter by (required)
|
||||
Default is False.
|
||||
:param [str] tags: Tags to filter by (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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: list[Pet]
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: [Pet]
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['tags'] = tags
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.find_pets_by_tags = Endpoint(
|
||||
settings={
|
||||
'response_type': 'list[Pet]',
|
||||
'response_type': ([Pet],),
|
||||
'auth': [
|
||||
'petstore_auth'
|
||||
],
|
||||
@@ -353,7 +470,7 @@ class PetApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'tags': 'list[str]',
|
||||
'tags': ([str],),
|
||||
},
|
||||
'attribute_map': {
|
||||
'tags': 'tags',
|
||||
@@ -386,28 +503,55 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param int pet_id: ID of pet to return (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: Pet
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['pet_id'] = pet_id
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.get_pet_by_id = Endpoint(
|
||||
settings={
|
||||
'response_type': 'Pet',
|
||||
'response_type': (Pet,),
|
||||
'auth': [
|
||||
'api_key'
|
||||
],
|
||||
@@ -436,7 +580,7 @@ class PetApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'pet_id': 'int',
|
||||
'pet_id': (int,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'pet_id': 'petId',
|
||||
@@ -467,22 +611,49 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param Pet body: Pet object that needs to be added to the store (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -517,7 +688,7 @@ class PetApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'body': 'Pet',
|
||||
'body': (Pet,),
|
||||
},
|
||||
'attribute_map': {
|
||||
},
|
||||
@@ -547,24 +718,51 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
: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
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['pet_id'] = pet_id
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -601,9 +799,9 @@ class PetApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'pet_id': 'int',
|
||||
'name': 'str',
|
||||
'status': 'str',
|
||||
'pet_id': (int,),
|
||||
'name': (str,),
|
||||
'status': (str,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'pet_id': 'petId',
|
||||
@@ -637,30 +835,58 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
: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 file_type file: file to upload
|
||||
:param [file_type] files: files to upload
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: ApiResponse
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['pet_id'] = pet_id
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.upload_file = Endpoint(
|
||||
settings={
|
||||
'response_type': 'ApiResponse',
|
||||
'response_type': (ApiResponse,),
|
||||
'auth': [
|
||||
'petstore_auth'
|
||||
],
|
||||
@@ -674,6 +900,7 @@ class PetApi(object):
|
||||
'pet_id',
|
||||
'additional_metadata',
|
||||
'file',
|
||||
'files',
|
||||
],
|
||||
'required': [
|
||||
'pet_id',
|
||||
@@ -691,21 +918,25 @@ class PetApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'pet_id': 'int',
|
||||
'additional_metadata': 'str',
|
||||
'file': 'file',
|
||||
'pet_id': (int,),
|
||||
'additional_metadata': (str,),
|
||||
'file': (file_type,),
|
||||
'files': ([file_type],),
|
||||
},
|
||||
'attribute_map': {
|
||||
'pet_id': 'petId',
|
||||
'additional_metadata': 'additionalMetadata',
|
||||
'file': 'file',
|
||||
'files': 'files',
|
||||
},
|
||||
'location_map': {
|
||||
'pet_id': 'path',
|
||||
'additional_metadata': 'form',
|
||||
'file': 'form',
|
||||
'files': 'form',
|
||||
},
|
||||
'collection_format_map': {
|
||||
'files': 'csv',
|
||||
}
|
||||
},
|
||||
headers_map={
|
||||
@@ -729,31 +960,58 @@ class PetApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param int pet_id: ID of pet to update (required)
|
||||
:param file required_file: file to upload (required)
|
||||
:param file_type 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
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: ApiResponse
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
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',
|
||||
'response_type': (ApiResponse,),
|
||||
'auth': [
|
||||
'petstore_auth'
|
||||
],
|
||||
@@ -785,9 +1043,9 @@ class PetApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'pet_id': 'int',
|
||||
'required_file': 'file',
|
||||
'additional_metadata': 'str',
|
||||
'pet_id': (int,),
|
||||
'required_file': (file_type,),
|
||||
'additional_metadata': (str,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'pet_id': 'petId',
|
||||
@@ -822,7 +1080,7 @@ class Endpoint(object):
|
||||
|
||||
Args:
|
||||
settings (dict): see below key value pairs
|
||||
'response_type' (str): response type
|
||||
'response_type' (tuple/None): response type
|
||||
'auth' (list): a list of auth type keys
|
||||
'endpoint_path' (str): the endpoint path
|
||||
'operation_id' (str): endpoint string identifier
|
||||
@@ -858,11 +1116,24 @@ class Endpoint(object):
|
||||
'_host_index',
|
||||
'_preload_content',
|
||||
'_request_timeout',
|
||||
'_return_http_data_only'
|
||||
'_return_http_data_only',
|
||||
'_check_input_type',
|
||||
'_check_return_type'
|
||||
])
|
||||
self.params_map['nullable'].extend(['_request_timeout'])
|
||||
self.validations = root_map['validations']
|
||||
self.allowed_values = root_map['allowed_values']
|
||||
self.openapi_types = root_map['openapi_types']
|
||||
extra_types = {
|
||||
'async_req': (bool,),
|
||||
'_host_index': (int,),
|
||||
'_preload_content': (bool,),
|
||||
'_request_timeout': (none_type, int, (int,), [int]),
|
||||
'_return_http_data_only': (bool,),
|
||||
'_check_input_type': (bool,),
|
||||
'_check_return_type': (bool,)
|
||||
}
|
||||
self.openapi_types.update(extra_types)
|
||||
self.attribute_map = root_map['attribute_map']
|
||||
self.location_map = root_map['location_map']
|
||||
self.collection_format_map = root_map['collection_format_map']
|
||||
@@ -876,8 +1147,7 @@ class Endpoint(object):
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(param,),
|
||||
kwargs[param],
|
||||
self.validations
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
for param in self.params_map['validation']:
|
||||
@@ -888,6 +1158,20 @@ class Endpoint(object):
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
if kwargs['_check_input_type'] is False:
|
||||
return
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
fixed_val = validate_and_convert_types(
|
||||
value,
|
||||
self.openapi_types[key],
|
||||
[key],
|
||||
False,
|
||||
kwargs['_check_input_type'],
|
||||
configuration=self.api_client.configuration
|
||||
)
|
||||
kwargs[key] = fixed_val
|
||||
|
||||
def __gather_params(self, kwargs):
|
||||
params = {
|
||||
'body': None,
|
||||
@@ -901,14 +1185,20 @@ class Endpoint(object):
|
||||
|
||||
for param_name, param_value in six.iteritems(kwargs):
|
||||
param_location = self.location_map.get(param_name)
|
||||
if param_location is None:
|
||||
continue
|
||||
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'
|
||||
self.openapi_types[param_name] == (file_type,)):
|
||||
params['file'][param_name] = [param_value]
|
||||
elif (param_location == 'form' and
|
||||
self.openapi_types[param_name] == ([file_type],)):
|
||||
# param_value is already a list
|
||||
params['file'][param_name] = param_value
|
||||
elif param_location in {'form', 'query'}:
|
||||
param_value_full = (base_name, param_value)
|
||||
params[param_location].append(param_value_full)
|
||||
@@ -933,20 +1223,15 @@ class Endpoint(object):
|
||||
|
||||
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:
|
||||
try:
|
||||
_host = self.settings['servers'][kwargs['_host_index']]
|
||||
except IndexError:
|
||||
if self.settings['servers']:
|
||||
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
|
||||
_host = None
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
if key not in self.params_map['all']:
|
||||
@@ -955,7 +1240,11 @@ class Endpoint(object):
|
||||
" to method `%s`" %
|
||||
(key, self.settings['operation_id'])
|
||||
)
|
||||
if key not in self.params_map['nullable'] and value is None:
|
||||
# only throw this nullable ApiValueError if _check_input_type
|
||||
# is False, if _check_input_type==True we catch this case
|
||||
# in self.__validate_inputs
|
||||
if (key not in self.params_map['nullable'] and value is None
|
||||
and kwargs['_check_input_type'] is False):
|
||||
raise ApiValueError(
|
||||
"Value may not be None for non-nullable parameter `%s`"
|
||||
" when calling `%s`" %
|
||||
@@ -994,9 +1283,10 @@ class Endpoint(object):
|
||||
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'),
|
||||
async_req=kwargs['async_req'],
|
||||
_check_type=kwargs['_check_return_type'],
|
||||
_return_http_data_only=kwargs['_return_http_data_only'],
|
||||
_preload_content=kwargs['_preload_content'],
|
||||
_request_timeout=kwargs['_request_timeout'],
|
||||
_host=_host,
|
||||
collection_formats=params['collection_format'])
|
||||
|
||||
@@ -22,10 +22,18 @@ from petstore_api.exceptions import (
|
||||
ApiTypeError,
|
||||
ApiValueError
|
||||
)
|
||||
from petstore_api.model_utils import (
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
int,
|
||||
none_type,
|
||||
str,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.order import Order
|
||||
|
||||
|
||||
class StoreApi(object):
|
||||
@@ -50,22 +58,49 @@ class StoreApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
: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
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['order_id'] = order_id
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -98,7 +133,7 @@ class StoreApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'order_id': 'str',
|
||||
'order_id': (str,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'order_id': 'order_id',
|
||||
@@ -127,26 +162,53 @@ class StoreApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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: dict(str, int)
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: {str: (int,)}
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.get_inventory = Endpoint(
|
||||
settings={
|
||||
'response_type': 'dict(str, int)',
|
||||
'response_type': ({str: (int,)},),
|
||||
'auth': [
|
||||
'api_key'
|
||||
],
|
||||
@@ -200,28 +262,55 @@ class StoreApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
: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
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: Order
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['order_id'] = order_id
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.get_order_by_id = Endpoint(
|
||||
settings={
|
||||
'response_type': 'Order',
|
||||
'response_type': (Order,),
|
||||
'auth': [],
|
||||
'endpoint_path': '/store/order/{order_id}',
|
||||
'operation_id': 'get_order_by_id',
|
||||
@@ -254,7 +343,7 @@ class StoreApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'order_id': 'int',
|
||||
'order_id': (int,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'order_id': 'order_id',
|
||||
@@ -285,28 +374,55 @@ class StoreApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param Order body: order placed for purchasing the pet (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: Order
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.place_order = Endpoint(
|
||||
settings={
|
||||
'response_type': 'Order',
|
||||
'response_type': (Order,),
|
||||
'auth': [],
|
||||
'endpoint_path': '/store/order',
|
||||
'operation_id': 'place_order',
|
||||
@@ -333,7 +449,7 @@ class StoreApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'body': 'Order',
|
||||
'body': (Order,),
|
||||
},
|
||||
'attribute_map': {
|
||||
},
|
||||
@@ -362,7 +478,7 @@ class Endpoint(object):
|
||||
|
||||
Args:
|
||||
settings (dict): see below key value pairs
|
||||
'response_type' (str): response type
|
||||
'response_type' (tuple/None): response type
|
||||
'auth' (list): a list of auth type keys
|
||||
'endpoint_path' (str): the endpoint path
|
||||
'operation_id' (str): endpoint string identifier
|
||||
@@ -398,11 +514,24 @@ class Endpoint(object):
|
||||
'_host_index',
|
||||
'_preload_content',
|
||||
'_request_timeout',
|
||||
'_return_http_data_only'
|
||||
'_return_http_data_only',
|
||||
'_check_input_type',
|
||||
'_check_return_type'
|
||||
])
|
||||
self.params_map['nullable'].extend(['_request_timeout'])
|
||||
self.validations = root_map['validations']
|
||||
self.allowed_values = root_map['allowed_values']
|
||||
self.openapi_types = root_map['openapi_types']
|
||||
extra_types = {
|
||||
'async_req': (bool,),
|
||||
'_host_index': (int,),
|
||||
'_preload_content': (bool,),
|
||||
'_request_timeout': (none_type, int, (int,), [int]),
|
||||
'_return_http_data_only': (bool,),
|
||||
'_check_input_type': (bool,),
|
||||
'_check_return_type': (bool,)
|
||||
}
|
||||
self.openapi_types.update(extra_types)
|
||||
self.attribute_map = root_map['attribute_map']
|
||||
self.location_map = root_map['location_map']
|
||||
self.collection_format_map = root_map['collection_format_map']
|
||||
@@ -416,8 +545,7 @@ class Endpoint(object):
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(param,),
|
||||
kwargs[param],
|
||||
self.validations
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
for param in self.params_map['validation']:
|
||||
@@ -428,6 +556,20 @@ class Endpoint(object):
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
if kwargs['_check_input_type'] is False:
|
||||
return
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
fixed_val = validate_and_convert_types(
|
||||
value,
|
||||
self.openapi_types[key],
|
||||
[key],
|
||||
False,
|
||||
kwargs['_check_input_type'],
|
||||
configuration=self.api_client.configuration
|
||||
)
|
||||
kwargs[key] = fixed_val
|
||||
|
||||
def __gather_params(self, kwargs):
|
||||
params = {
|
||||
'body': None,
|
||||
@@ -441,14 +583,20 @@ class Endpoint(object):
|
||||
|
||||
for param_name, param_value in six.iteritems(kwargs):
|
||||
param_location = self.location_map.get(param_name)
|
||||
if param_location is None:
|
||||
continue
|
||||
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'
|
||||
self.openapi_types[param_name] == (file_type,)):
|
||||
params['file'][param_name] = [param_value]
|
||||
elif (param_location == 'form' and
|
||||
self.openapi_types[param_name] == ([file_type],)):
|
||||
# param_value is already a list
|
||||
params['file'][param_name] = param_value
|
||||
elif param_location in {'form', 'query'}:
|
||||
param_value_full = (base_name, param_value)
|
||||
params[param_location].append(param_value_full)
|
||||
@@ -473,20 +621,15 @@ class Endpoint(object):
|
||||
|
||||
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:
|
||||
try:
|
||||
_host = self.settings['servers'][kwargs['_host_index']]
|
||||
except IndexError:
|
||||
if self.settings['servers']:
|
||||
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
|
||||
_host = None
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
if key not in self.params_map['all']:
|
||||
@@ -495,7 +638,11 @@ class Endpoint(object):
|
||||
" to method `%s`" %
|
||||
(key, self.settings['operation_id'])
|
||||
)
|
||||
if key not in self.params_map['nullable'] and value is None:
|
||||
# only throw this nullable ApiValueError if _check_input_type
|
||||
# is False, if _check_input_type==True we catch this case
|
||||
# in self.__validate_inputs
|
||||
if (key not in self.params_map['nullable'] and value is None
|
||||
and kwargs['_check_input_type'] is False):
|
||||
raise ApiValueError(
|
||||
"Value may not be None for non-nullable parameter `%s`"
|
||||
" when calling `%s`" %
|
||||
@@ -534,9 +681,10 @@ class Endpoint(object):
|
||||
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'),
|
||||
async_req=kwargs['async_req'],
|
||||
_check_type=kwargs['_check_return_type'],
|
||||
_return_http_data_only=kwargs['_return_http_data_only'],
|
||||
_preload_content=kwargs['_preload_content'],
|
||||
_request_timeout=kwargs['_request_timeout'],
|
||||
_host=_host,
|
||||
collection_formats=params['collection_format'])
|
||||
|
||||
@@ -22,10 +22,18 @@ from petstore_api.exceptions import (
|
||||
ApiTypeError,
|
||||
ApiValueError
|
||||
)
|
||||
from petstore_api.model_utils import (
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
int,
|
||||
none_type,
|
||||
str,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.user import User
|
||||
|
||||
|
||||
class UserApi(object):
|
||||
@@ -50,22 +58,49 @@ class UserApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param User body: Created user object (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -98,7 +133,7 @@ class UserApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'body': 'User',
|
||||
'body': (User,),
|
||||
},
|
||||
'attribute_map': {
|
||||
},
|
||||
@@ -125,22 +160,49 @@ class UserApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param list[User] body: List of user object (required)
|
||||
Default is False.
|
||||
:param [User] body: List of user object (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -173,7 +235,7 @@ class UserApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'body': 'list[User]',
|
||||
'body': ([User],),
|
||||
},
|
||||
'attribute_map': {
|
||||
},
|
||||
@@ -200,22 +262,49 @@ class UserApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param list[User] body: List of user object (required)
|
||||
Default is False.
|
||||
:param [User] body: List of user object (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -248,7 +337,7 @@ class UserApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'body': 'list[User]',
|
||||
'body': ([User],),
|
||||
},
|
||||
'attribute_map': {
|
||||
},
|
||||
@@ -276,22 +365,49 @@ class UserApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param str username: The name that needs to be deleted (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['username'] = username
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
@@ -324,7 +440,7 @@ class UserApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'username': 'str',
|
||||
'username': (str,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'username': 'username',
|
||||
@@ -352,28 +468,55 @@ class UserApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
: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
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: User
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['username'] = username
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.get_user_by_name = Endpoint(
|
||||
settings={
|
||||
'response_type': 'User',
|
||||
'response_type': (User,),
|
||||
'auth': [],
|
||||
'endpoint_path': '/user/{username}',
|
||||
'operation_id': 'get_user_by_name',
|
||||
@@ -400,7 +543,7 @@ class UserApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'username': 'str',
|
||||
'username': (str,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'username': 'username',
|
||||
@@ -431,30 +574,57 @@ class UserApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
: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
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: str
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['username'] = username
|
||||
kwargs['password'] = password
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.login_user = Endpoint(
|
||||
settings={
|
||||
'response_type': 'str',
|
||||
'response_type': (str,),
|
||||
'auth': [],
|
||||
'endpoint_path': '/user/login',
|
||||
'operation_id': 'login_user',
|
||||
@@ -483,8 +653,8 @@ class UserApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'username': 'str',
|
||||
'password': 'str',
|
||||
'username': (str,),
|
||||
'password': (str,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'username': 'username',
|
||||
@@ -517,21 +687,48 @@ class UserApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
return self.call_with_http_info(**kwargs)
|
||||
|
||||
self.logout_user = Endpoint(
|
||||
@@ -586,23 +783,50 @@ class UserApi(object):
|
||||
>>> result = thread.get()
|
||||
|
||||
:param async_req bool: execute request asynchronously
|
||||
Default is False.
|
||||
:param str username: name that need to be deleted (required)
|
||||
:param User body: Updated user object (required)
|
||||
:param _return_http_data_only: response data without head status
|
||||
code and headers
|
||||
code and headers. Default is True.
|
||||
: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.
|
||||
Default is None.
|
||||
:param _check_input_type: boolean specifying if type checking
|
||||
should be done one the data sent to the server.
|
||||
Default is True.
|
||||
:param _check_return_type: boolean specifying if type checking
|
||||
should be done one the data received from the server.
|
||||
Default is True.
|
||||
:param _host_index: integer specifying the index of the server
|
||||
that we want to use.
|
||||
Default is 0.
|
||||
:return: None
|
||||
If the method is called asynchronously, returns the request
|
||||
thread.
|
||||
"""
|
||||
kwargs['async_req'] = kwargs.get(
|
||||
'async_req', False
|
||||
)
|
||||
kwargs['_return_http_data_only'] = kwargs.get(
|
||||
'_return_http_data_only', True
|
||||
)
|
||||
kwargs['_preload_content'] = kwargs.get(
|
||||
'_preload_content', True
|
||||
)
|
||||
kwargs['_request_timeout'] = kwargs.get(
|
||||
'_request_timeout', None
|
||||
)
|
||||
kwargs['_check_input_type'] = kwargs.get(
|
||||
'_check_input_type', True
|
||||
)
|
||||
kwargs['_check_return_type'] = kwargs.get(
|
||||
'_check_return_type', True
|
||||
)
|
||||
kwargs['_host_index'] = kwargs.get('_host_index', 0)
|
||||
kwargs['username'] = username
|
||||
kwargs['body'] = body
|
||||
return self.call_with_http_info(**kwargs)
|
||||
@@ -638,8 +862,8 @@ class UserApi(object):
|
||||
'allowed_values': {
|
||||
},
|
||||
'openapi_types': {
|
||||
'username': 'str',
|
||||
'body': 'User',
|
||||
'username': (str,),
|
||||
'body': (User,),
|
||||
},
|
||||
'attribute_map': {
|
||||
'username': 'username',
|
||||
@@ -667,7 +891,7 @@ class Endpoint(object):
|
||||
|
||||
Args:
|
||||
settings (dict): see below key value pairs
|
||||
'response_type' (str): response type
|
||||
'response_type' (tuple/None): response type
|
||||
'auth' (list): a list of auth type keys
|
||||
'endpoint_path' (str): the endpoint path
|
||||
'operation_id' (str): endpoint string identifier
|
||||
@@ -703,11 +927,24 @@ class Endpoint(object):
|
||||
'_host_index',
|
||||
'_preload_content',
|
||||
'_request_timeout',
|
||||
'_return_http_data_only'
|
||||
'_return_http_data_only',
|
||||
'_check_input_type',
|
||||
'_check_return_type'
|
||||
])
|
||||
self.params_map['nullable'].extend(['_request_timeout'])
|
||||
self.validations = root_map['validations']
|
||||
self.allowed_values = root_map['allowed_values']
|
||||
self.openapi_types = root_map['openapi_types']
|
||||
extra_types = {
|
||||
'async_req': (bool,),
|
||||
'_host_index': (int,),
|
||||
'_preload_content': (bool,),
|
||||
'_request_timeout': (none_type, int, (int,), [int]),
|
||||
'_return_http_data_only': (bool,),
|
||||
'_check_input_type': (bool,),
|
||||
'_check_return_type': (bool,)
|
||||
}
|
||||
self.openapi_types.update(extra_types)
|
||||
self.attribute_map = root_map['attribute_map']
|
||||
self.location_map = root_map['location_map']
|
||||
self.collection_format_map = root_map['collection_format_map']
|
||||
@@ -721,8 +958,7 @@ class Endpoint(object):
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(param,),
|
||||
kwargs[param],
|
||||
self.validations
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
for param in self.params_map['validation']:
|
||||
@@ -733,6 +969,20 @@ class Endpoint(object):
|
||||
kwargs[param]
|
||||
)
|
||||
|
||||
if kwargs['_check_input_type'] is False:
|
||||
return
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
fixed_val = validate_and_convert_types(
|
||||
value,
|
||||
self.openapi_types[key],
|
||||
[key],
|
||||
False,
|
||||
kwargs['_check_input_type'],
|
||||
configuration=self.api_client.configuration
|
||||
)
|
||||
kwargs[key] = fixed_val
|
||||
|
||||
def __gather_params(self, kwargs):
|
||||
params = {
|
||||
'body': None,
|
||||
@@ -746,14 +996,20 @@ class Endpoint(object):
|
||||
|
||||
for param_name, param_value in six.iteritems(kwargs):
|
||||
param_location = self.location_map.get(param_name)
|
||||
if param_location is None:
|
||||
continue
|
||||
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'
|
||||
self.openapi_types[param_name] == (file_type,)):
|
||||
params['file'][param_name] = [param_value]
|
||||
elif (param_location == 'form' and
|
||||
self.openapi_types[param_name] == ([file_type],)):
|
||||
# param_value is already a list
|
||||
params['file'][param_name] = param_value
|
||||
elif param_location in {'form', 'query'}:
|
||||
param_value_full = (base_name, param_value)
|
||||
params[param_location].append(param_value_full)
|
||||
@@ -778,20 +1034,15 @@ class Endpoint(object):
|
||||
|
||||
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:
|
||||
try:
|
||||
_host = self.settings['servers'][kwargs['_host_index']]
|
||||
except IndexError:
|
||||
if self.settings['servers']:
|
||||
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
|
||||
_host = None
|
||||
|
||||
for key, value in six.iteritems(kwargs):
|
||||
if key not in self.params_map['all']:
|
||||
@@ -800,7 +1051,11 @@ class Endpoint(object):
|
||||
" to method `%s`" %
|
||||
(key, self.settings['operation_id'])
|
||||
)
|
||||
if key not in self.params_map['nullable'] and value is None:
|
||||
# only throw this nullable ApiValueError if _check_input_type
|
||||
# is False, if _check_input_type==True we catch this case
|
||||
# in self.__validate_inputs
|
||||
if (key not in self.params_map['nullable'] and value is None
|
||||
and kwargs['_check_input_type'] is False):
|
||||
raise ApiValueError(
|
||||
"Value may not be None for non-nullable parameter `%s`"
|
||||
" when calling `%s`" %
|
||||
@@ -839,9 +1094,10 @@ class Endpoint(object):
|
||||
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'),
|
||||
async_req=kwargs['async_req'],
|
||||
_check_type=kwargs['_check_return_type'],
|
||||
_return_http_data_only=kwargs['_return_http_data_only'],
|
||||
_preload_content=kwargs['_preload_content'],
|
||||
_request_timeout=kwargs['_request_timeout'],
|
||||
_host=_host,
|
||||
collection_formats=params['collection_format'])
|
||||
|
||||
@@ -10,27 +10,29 @@
|
||||
|
||||
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
|
||||
|
||||
import petstore_api.models
|
||||
from petstore_api import rest
|
||||
from petstore_api.configuration import Configuration
|
||||
from petstore_api.exceptions import ApiValueError
|
||||
from petstore_api.model_utils import (
|
||||
ModelNormal,
|
||||
ModelSimple
|
||||
ModelSimple,
|
||||
date,
|
||||
datetime,
|
||||
deserialize_file,
|
||||
file_type,
|
||||
model_to_dict,
|
||||
str,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.exceptions import ApiValueError
|
||||
|
||||
|
||||
class ApiClient(object):
|
||||
@@ -55,17 +57,11 @@ class ApiClient(object):
|
||||
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,
|
||||
}
|
||||
# six.binary_type python2=str, python3=bytes
|
||||
# six.text_type python2=unicode, python3=str
|
||||
PRIMITIVE_TYPES = (
|
||||
(float, bool, six.binary_type, six.text_type) + six.integer_types
|
||||
)
|
||||
_pool = None
|
||||
|
||||
def __init__(self, configuration=None, header_name=None, header_value=None,
|
||||
@@ -115,7 +111,8 @@ class ApiClient(object):
|
||||
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):
|
||||
_preload_content=True, _request_timeout=None, _host=None,
|
||||
_check_type=None):
|
||||
|
||||
config = self.configuration
|
||||
|
||||
@@ -182,7 +179,11 @@ class ApiClient(object):
|
||||
if _preload_content:
|
||||
# deserialize response data
|
||||
if response_type:
|
||||
return_data = self.deserialize(response_data, response_type)
|
||||
return_data = self.deserialize(
|
||||
response_data,
|
||||
response_type,
|
||||
_check_type
|
||||
)
|
||||
else:
|
||||
return_data = None
|
||||
|
||||
@@ -216,93 +217,73 @@ class ApiClient(object):
|
||||
elif isinstance(obj, tuple):
|
||||
return tuple(self.sanitize_for_serialization(sub_obj)
|
||||
for sub_obj in obj)
|
||||
elif isinstance(obj, (datetime.datetime, datetime.date)):
|
||||
elif isinstance(obj, (datetime, date)):
|
||||
return obj.isoformat()
|
||||
|
||||
if isinstance(obj, dict):
|
||||
obj_dict = obj
|
||||
elif isinstance(obj, ModelNormal):
|
||||
# Convert model obj to dict except
|
||||
# attributes `openapi_types`, `attribute_map`
|
||||
# and attributes which value is not None.
|
||||
# Convert model obj to dict
|
||||
# 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}
|
||||
# model definition for request
|
||||
obj_dict = model_to_dict(obj, serialize=True)
|
||||
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)}
|
||||
|
||||
def deserialize(self, response, response_type):
|
||||
def deserialize(self, response, response_type, _check_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.
|
||||
:param response_type: For the response, a tuple containing:
|
||||
valid classes
|
||||
a list containing valid classes (for list schemas)
|
||||
a dict containing a tuple of valid classes as the value
|
||||
Example values:
|
||||
(str,)
|
||||
(Pet,)
|
||||
(float, none_type)
|
||||
([int, none_type],)
|
||||
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
||||
:param _check_type: boolean, whether to check the types of the data
|
||||
received from the server
|
||||
|
||||
: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)
|
||||
if response_type == (file_type,):
|
||||
content_disposition = response.getheader("Content-Disposition")
|
||||
return deserialize_file(response.data, self.configuration,
|
||||
content_disposition=content_disposition)
|
||||
|
||||
# fetch data from response object
|
||||
try:
|
||||
data = json.loads(response.data)
|
||||
received_data = json.loads(response.data)
|
||||
except ValueError:
|
||||
data = response.data
|
||||
received_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)
|
||||
# store our data under the key of 'received_data' so users have some
|
||||
# context if they are deserializing a string and the data type is wrong
|
||||
deserialized_data = validate_and_convert_types(
|
||||
received_data,
|
||||
response_type,
|
||||
['received_data'],
|
||||
True,
|
||||
_check_type,
|
||||
configuration=self.configuration
|
||||
)
|
||||
return deserialized_data
|
||||
|
||||
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):
|
||||
_preload_content=True, _request_timeout=None, _host=None,
|
||||
_check_type=None):
|
||||
"""Makes the HTTP request (synchronous) and returns deserialized data.
|
||||
|
||||
To make an async_req request, set the async_req parameter.
|
||||
@@ -317,9 +298,18 @@ class ApiClient(object):
|
||||
: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 response_type: For the response, a tuple containing:
|
||||
valid classes
|
||||
a list containing valid classes (for list schemas)
|
||||
a dict containing a tuple of valid classes as the value
|
||||
Example values:
|
||||
(str,)
|
||||
(Pet,)
|
||||
(float, none_type)
|
||||
([int, none_type],)
|
||||
({str: (bool, str, int, float, date, datetime, str, none_type)},)
|
||||
:param files dict: key -> field name, value -> a list of open file
|
||||
objects for `multipart/form-data`.
|
||||
:param async_req bool: execute request asynchronously
|
||||
:param _return_http_data_only: response data without head status code
|
||||
and headers
|
||||
@@ -332,6 +322,8 @@ class ApiClient(object):
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
:param _check_type: boolean describing if the data back from the server
|
||||
should have its type checked.
|
||||
:return:
|
||||
If async_req parameter is True,
|
||||
the request will be called asynchronously.
|
||||
@@ -345,7 +337,8 @@ class ApiClient(object):
|
||||
body, post_params, files,
|
||||
response_type, auth_settings,
|
||||
_return_http_data_only, collection_formats,
|
||||
_preload_content, _request_timeout, _host)
|
||||
_preload_content, _request_timeout, _host,
|
||||
_check_type)
|
||||
else:
|
||||
thread = self.pool.apply_async(self.__call_api, (resource_path,
|
||||
method, path_params, query_params,
|
||||
@@ -356,7 +349,7 @@ class ApiClient(object):
|
||||
collection_formats,
|
||||
_preload_content,
|
||||
_request_timeout,
|
||||
_host))
|
||||
_host, _check_type))
|
||||
return thread
|
||||
|
||||
def request(self, method, url, query_params=None, headers=None,
|
||||
@@ -453,24 +446,34 @@ class ApiClient(object):
|
||||
def files_parameters(self, files=None):
|
||||
"""Builds form parameters.
|
||||
|
||||
:param files: File parameters.
|
||||
:return: Form parameters with files.
|
||||
:param files: None or a dict with key=param_name and
|
||||
value is a list of open file objects
|
||||
:return: List of tuples of form parameters with file data
|
||||
"""
|
||||
params = []
|
||||
if files is None:
|
||||
return []
|
||||
|
||||
if files:
|
||||
for k, v in six.iteritems(files):
|
||||
if not v:
|
||||
params = []
|
||||
for param_name, file_instances in six.iteritems(files):
|
||||
if file_instances is None:
|
||||
# if the file field is nullable, skip None values
|
||||
continue
|
||||
for file_instance in file_instances:
|
||||
if file_instance is None:
|
||||
# if the file field is nullable, skip None values
|
||||
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])]))
|
||||
if file_instance.closed is True:
|
||||
raise ApiValueError(
|
||||
"Cannot read a closed file. The passed in file_type "
|
||||
"for %s must be open." % param_name
|
||||
)
|
||||
filename = os.path.basename(file_instance.name)
|
||||
filedata = file_instance.read()
|
||||
mimetype = (mimetypes.guess_type(filename)[0] or
|
||||
'application/octet-stream')
|
||||
params.append(
|
||||
tuple([param_name, tuple([filename, filedata, mimetype])]))
|
||||
file_instance.close()
|
||||
|
||||
return params
|
||||
|
||||
@@ -531,133 +534,3 @@ class ApiClient(object):
|
||||
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
|
||||
except ValueError as exc:
|
||||
raise ApiValueError(str(exc))
|
||||
|
||||
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, ModelSimple or ModelNormal
|
||||
:return: model object.
|
||||
"""
|
||||
|
||||
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]
|
||||
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
|
||||
|
||||
@@ -9,13 +9,162 @@
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
||||
|
||||
|
||||
import copy
|
||||
from datetime import date, datetime # noqa: F401
|
||||
import inspect
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
from petstore_api.exceptions import ApiValueError
|
||||
from dateutil.parser import parse
|
||||
import six
|
||||
|
||||
from petstore_api.exceptions import (
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
|
||||
none_type = type(None)
|
||||
if six.PY3:
|
||||
import io
|
||||
file_type = io.IOBase
|
||||
# these are needed for when other modules import str and int from here
|
||||
str = str
|
||||
int = int
|
||||
else:
|
||||
file_type = file # noqa: F821
|
||||
str_py2 = str
|
||||
unicode_py2 = unicode # noqa: F821
|
||||
long_py2 = long # noqa: F821
|
||||
int_py2 = int
|
||||
# this requires that the future library is installed
|
||||
from builtins import int, str
|
||||
|
||||
|
||||
def check_allowed_values(allowed_values, input_variable_path, input_values,
|
||||
validations):
|
||||
class OpenApiModel(object):
|
||||
"""The base class for all OpenAPIModels"""
|
||||
|
||||
|
||||
class ModelSimple(OpenApiModel):
|
||||
"""the parent class of models whose type != object in their
|
||||
swagger/openapi"""
|
||||
|
||||
|
||||
class ModelNormal(OpenApiModel):
|
||||
"""the parent class of models whose type == object in their
|
||||
swagger/openapi"""
|
||||
|
||||
|
||||
COERCION_INDEX_BY_TYPE = {
|
||||
ModelNormal: 0,
|
||||
ModelSimple: 1,
|
||||
none_type: 2,
|
||||
list: 3,
|
||||
dict: 4,
|
||||
float: 5,
|
||||
int: 6,
|
||||
bool: 7,
|
||||
datetime: 8,
|
||||
date: 9,
|
||||
str: 10,
|
||||
file_type: 11,
|
||||
}
|
||||
|
||||
# these are used to limit what type conversions we try to do
|
||||
# when we have a valid type already and we want to try converting
|
||||
# to another type
|
||||
UPCONVERSION_TYPE_PAIRS = (
|
||||
(str, datetime),
|
||||
(str, date),
|
||||
(list, ModelNormal),
|
||||
(dict, ModelNormal),
|
||||
(str, ModelSimple),
|
||||
(int, ModelSimple),
|
||||
(float, ModelSimple),
|
||||
(list, ModelSimple),
|
||||
)
|
||||
|
||||
COERCIBLE_TYPE_PAIRS = {
|
||||
False: ( # client instantiation of a model with client data
|
||||
# (dict, ModelNormal),
|
||||
# (list, ModelNormal),
|
||||
# (str, ModelSimple),
|
||||
# (int, ModelSimple),
|
||||
# (float, ModelSimple),
|
||||
# (list, ModelSimple),
|
||||
# (str, int),
|
||||
# (str, float),
|
||||
# (str, datetime),
|
||||
# (str, date),
|
||||
# (int, str),
|
||||
# (float, str),
|
||||
),
|
||||
True: ( # server -> client data
|
||||
(dict, ModelNormal),
|
||||
(list, ModelNormal),
|
||||
(str, ModelSimple),
|
||||
(int, ModelSimple),
|
||||
(float, ModelSimple),
|
||||
(list, ModelSimple),
|
||||
# (str, int),
|
||||
# (str, float),
|
||||
(str, datetime),
|
||||
(str, date),
|
||||
# (int, str),
|
||||
# (float, str),
|
||||
(str, file_type)
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def get_simple_class(input_value):
|
||||
"""Returns an input_value's simple class that we will use for type checking
|
||||
Python2:
|
||||
float and int will return int, where int is the python3 int backport
|
||||
str and unicode will return str, where str is the python3 str backport
|
||||
Note: float and int ARE both instances of int backport
|
||||
Note: str_py2 and unicode_py2 are NOT both instances of str backport
|
||||
|
||||
Args:
|
||||
input_value (class/class_instance): the item for which we will return
|
||||
the simple class
|
||||
"""
|
||||
if isinstance(input_value, type):
|
||||
# input_value is a class
|
||||
return input_value
|
||||
elif isinstance(input_value, tuple):
|
||||
return tuple
|
||||
elif isinstance(input_value, list):
|
||||
return list
|
||||
elif isinstance(input_value, dict):
|
||||
return dict
|
||||
elif isinstance(input_value, none_type):
|
||||
return none_type
|
||||
elif isinstance(input_value, file_type):
|
||||
return file_type
|
||||
elif isinstance(input_value, bool):
|
||||
# this must be higher than the int check because
|
||||
# isinstance(True, int) == True
|
||||
return bool
|
||||
elif isinstance(input_value, int):
|
||||
# for python2 input_value==long_instance -> return int
|
||||
# where int is the python3 int backport
|
||||
return int
|
||||
elif isinstance(input_value, datetime):
|
||||
# this must be higher than the date check because
|
||||
# isinstance(datetime_instance, date) == True
|
||||
return datetime
|
||||
elif isinstance(input_value, date):
|
||||
return date
|
||||
elif (six.PY2 and isinstance(input_value, (str_py2, unicode_py2, str)) or
|
||||
isinstance(input_value, str)):
|
||||
return str
|
||||
return type(input_value)
|
||||
|
||||
|
||||
def check_allowed_values(allowed_values, input_variable_path, input_values):
|
||||
"""Raises an exception if the input_values are not allowed
|
||||
|
||||
Args:
|
||||
@@ -23,14 +172,9 @@ def check_allowed_values(allowed_values, input_variable_path, input_values,
|
||||
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(
|
||||
@@ -44,7 +188,6 @@ def check_allowed_values(allowed_values, input_variable_path, input_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(
|
||||
@@ -119,8 +262,21 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
)
|
||||
|
||||
items = ('exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum',
|
||||
'inclusive_minimum')
|
||||
if (any(item in current_validations for item in items)):
|
||||
if isinstance(input_values, list):
|
||||
max_val = max(input_values)
|
||||
min_val = min(input_values)
|
||||
elif isinstance(input_values, dict):
|
||||
max_val = max(input_values.values())
|
||||
min_val = min(input_values.values())
|
||||
else:
|
||||
max_val = input_values
|
||||
min_val = input_values
|
||||
|
||||
if ('exclusive_maximum' in current_validations and
|
||||
input_values >= current_validations['exclusive_maximum']):
|
||||
max_val >= current_validations['exclusive_maximum']):
|
||||
raise ApiValueError(
|
||||
"Invalid value for `%s`, must be a value less than `%s`" % (
|
||||
input_variable_path[0],
|
||||
@@ -129,7 +285,7 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
|
||||
if ('inclusive_maximum' in current_validations and
|
||||
input_values > current_validations['inclusive_maximum']):
|
||||
max_val > current_validations['inclusive_maximum']):
|
||||
raise ApiValueError(
|
||||
"Invalid value for `%s`, must be a value less than or equal to "
|
||||
"`%s`" % (
|
||||
@@ -139,7 +295,7 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
|
||||
if ('exclusive_minimum' in current_validations and
|
||||
input_values <= current_validations['exclusive_minimum']):
|
||||
min_val <= current_validations['exclusive_minimum']):
|
||||
raise ApiValueError(
|
||||
"Invalid value for `%s`, must be a value greater than `%s`" %
|
||||
(
|
||||
@@ -149,7 +305,7 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
|
||||
if ('inclusive_minimum' in current_validations and
|
||||
input_values < current_validations['inclusive_minimum']):
|
||||
min_val < current_validations['inclusive_minimum']):
|
||||
raise ApiValueError(
|
||||
"Invalid value for `%s`, must be a value greater than or equal "
|
||||
"to `%s`" % (
|
||||
@@ -171,13 +327,550 @@ def check_validations(validations, input_variable_path, input_values):
|
||||
)
|
||||
|
||||
|
||||
class ModelSimple(object):
|
||||
# the parent class of models whose type != object in their swagger/openapi
|
||||
# spec
|
||||
pass
|
||||
def order_response_types(required_types):
|
||||
"""Returns the required types sorted in coercion order
|
||||
|
||||
Args:
|
||||
required_types (list/tuple): collection of classes or instance of
|
||||
list or dict with classs information inside it
|
||||
|
||||
Returns:
|
||||
(list): coercion order sorted collection of classes or instance
|
||||
of list or dict with classs information inside it
|
||||
"""
|
||||
|
||||
def index_getter(class_or_instance):
|
||||
if isinstance(class_or_instance, list):
|
||||
return COERCION_INDEX_BY_TYPE[list]
|
||||
elif isinstance(class_or_instance, dict):
|
||||
return COERCION_INDEX_BY_TYPE[dict]
|
||||
elif (inspect.isclass(class_or_instance)
|
||||
and issubclass(class_or_instance, ModelNormal)):
|
||||
return COERCION_INDEX_BY_TYPE[ModelNormal]
|
||||
elif (inspect.isclass(class_or_instance)
|
||||
and issubclass(class_or_instance, ModelSimple)):
|
||||
return COERCION_INDEX_BY_TYPE[ModelSimple]
|
||||
return COERCION_INDEX_BY_TYPE[class_or_instance]
|
||||
|
||||
sorted_types = sorted(
|
||||
required_types,
|
||||
key=lambda class_or_instance: index_getter(class_or_instance)
|
||||
)
|
||||
return sorted_types
|
||||
|
||||
|
||||
class ModelNormal(object):
|
||||
# the parent class of models whose type == object in their swagger/openapi
|
||||
# spec
|
||||
pass
|
||||
def remove_uncoercible(required_types_classes, current_item, from_server,
|
||||
must_convert=True):
|
||||
"""Only keeps the type conversions that are possible
|
||||
|
||||
Args:
|
||||
required_types_classes (tuple): tuple of classes that are required
|
||||
these should be ordered by COERCION_INDEX_BY_TYPE
|
||||
from_server (bool): a boolean of whether the data is from the server
|
||||
if false, the data is from the client
|
||||
current_item (any): the current item to be converted
|
||||
|
||||
Keyword Args:
|
||||
must_convert (bool): if True the item to convert is of the wrong
|
||||
type and we want a big list of coercibles
|
||||
if False, we want a limited list of coercibles
|
||||
|
||||
Returns:
|
||||
(list): the remaining coercible required types, classes only
|
||||
"""
|
||||
current_type_simple = get_simple_class(current_item)
|
||||
|
||||
results_classes = []
|
||||
for required_type_class in required_types_classes:
|
||||
# convert our models to OpenApiModel
|
||||
required_type_class_simplified = required_type_class
|
||||
if isinstance(required_type_class_simplified, type):
|
||||
if issubclass(required_type_class_simplified, ModelNormal):
|
||||
required_type_class_simplified = ModelNormal
|
||||
elif issubclass(required_type_class_simplified, ModelSimple):
|
||||
required_type_class_simplified = ModelSimple
|
||||
|
||||
if required_type_class_simplified == current_type_simple:
|
||||
# don't consider converting to one's own class
|
||||
continue
|
||||
|
||||
class_pair = (current_type_simple, required_type_class_simplified)
|
||||
if must_convert and class_pair in COERCIBLE_TYPE_PAIRS[from_server]:
|
||||
results_classes.append(required_type_class)
|
||||
elif class_pair in UPCONVERSION_TYPE_PAIRS:
|
||||
results_classes.append(required_type_class)
|
||||
return results_classes
|
||||
|
||||
|
||||
def get_required_type_classes(required_types_mixed):
|
||||
"""Converts the tuple required_types into a tuple and a dict described
|
||||
below
|
||||
|
||||
Args:
|
||||
required_types_mixed (tuple/list): will contain either classes or
|
||||
instance of list or dict
|
||||
|
||||
Returns:
|
||||
(valid_classes, dict_valid_class_to_child_types_mixed):
|
||||
valid_classes (tuple): the valid classes that the current item
|
||||
should be
|
||||
dict_valid_class_to_child_types_mixed (doct):
|
||||
valid_class (class): this is the key
|
||||
child_types_mixed (list/dict/tuple): describes the valid child
|
||||
types
|
||||
"""
|
||||
valid_classes = []
|
||||
child_req_types_by_current_type = {}
|
||||
for required_type in required_types_mixed:
|
||||
if isinstance(required_type, list):
|
||||
valid_classes.append(list)
|
||||
child_req_types_by_current_type[list] = required_type
|
||||
elif isinstance(required_type, tuple):
|
||||
valid_classes.append(tuple)
|
||||
child_req_types_by_current_type[tuple] = required_type
|
||||
elif isinstance(required_type, dict):
|
||||
valid_classes.append(dict)
|
||||
child_req_types_by_current_type[dict] = required_type[str]
|
||||
else:
|
||||
valid_classes.append(required_type)
|
||||
return tuple(valid_classes), child_req_types_by_current_type
|
||||
|
||||
|
||||
def change_keys_js_to_python(input_dict, model_class):
|
||||
"""
|
||||
Converts from javascript_key keys in the input_dict to python_keys in
|
||||
the output dict using the mapping in model_class
|
||||
"""
|
||||
|
||||
output_dict = {}
|
||||
reversed_attr_map = {value: key for key, value in
|
||||
six.iteritems(model_class.attribute_map)}
|
||||
for javascript_key, value in six.iteritems(input_dict):
|
||||
python_key = reversed_attr_map.get(javascript_key)
|
||||
if python_key is None:
|
||||
# if the key is unknown, it is in error or it is an
|
||||
# additionalProperties variable
|
||||
python_key = javascript_key
|
||||
output_dict[python_key] = value
|
||||
return output_dict
|
||||
|
||||
|
||||
def get_type_error(var_value, path_to_item, valid_classes, key_type=False):
|
||||
error_msg = type_error_message(
|
||||
var_name=path_to_item[-1],
|
||||
var_value=var_value,
|
||||
valid_classes=valid_classes,
|
||||
key_type=key_type
|
||||
)
|
||||
return ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=valid_classes,
|
||||
key_type=key_type
|
||||
)
|
||||
|
||||
|
||||
def deserialize_primitive(data, klass, path_to_item):
|
||||
"""Deserializes string to primitive type.
|
||||
|
||||
:param data: str/int/float
|
||||
:param klass: str/class the class to convert to
|
||||
|
||||
:return: int, float, str, bool, date, datetime
|
||||
"""
|
||||
additional_message = ""
|
||||
try:
|
||||
if klass in {datetime, date}:
|
||||
additional_message = (
|
||||
"If you need your parameter to have a fallback "
|
||||
"string value, please set its type as `type: {}` in your "
|
||||
"spec. That allows the value to be any type. "
|
||||
)
|
||||
if klass == datetime:
|
||||
if len(data) < 8:
|
||||
raise ValueError("This is not a datetime")
|
||||
# The string should be in iso8601 datetime format.
|
||||
parsed_datetime = parse(data)
|
||||
date_only = (
|
||||
parsed_datetime.hour == 0 and
|
||||
parsed_datetime.minute == 0 and
|
||||
parsed_datetime.second == 0 and
|
||||
parsed_datetime.tzinfo is None and
|
||||
8 <= len(data) <= 10
|
||||
)
|
||||
if date_only:
|
||||
raise ValueError("This is a date, not a datetime")
|
||||
return parsed_datetime
|
||||
elif klass == date:
|
||||
if len(data) < 8:
|
||||
raise ValueError("This is not a date")
|
||||
return parse(data).date()
|
||||
else:
|
||||
converted_value = klass(data)
|
||||
if isinstance(data, str) and klass == float:
|
||||
if str(converted_value) != data:
|
||||
# '7' -> 7.0 -> '7.0' != '7'
|
||||
raise ValueError('This is not a float')
|
||||
return converted_value
|
||||
except (OverflowError, ValueError):
|
||||
# parse can raise OverflowError
|
||||
raise ApiValueError(
|
||||
"{0}Failed to parse {1} as {2}".format(
|
||||
additional_message, repr(data), get_py3_class_name(klass)
|
||||
),
|
||||
path_to_item=path_to_item
|
||||
)
|
||||
|
||||
|
||||
def deserialize_model(model_data, model_class, path_to_item, check_type,
|
||||
configuration, from_server):
|
||||
"""Deserializes model_data to model instance.
|
||||
|
||||
Args:
|
||||
model_data (list/dict): data to instantiate the model
|
||||
model_class (OpenApiModel): the model class
|
||||
path_to_item (list): path to the model in the received data
|
||||
check_type (bool): whether to check the data tupe for the values in
|
||||
the model
|
||||
configuration (Configuration): the instance to use to convert files
|
||||
from_server (bool): True if the data is from the server
|
||||
False if the data is from the client
|
||||
|
||||
Returns:
|
||||
model instance
|
||||
|
||||
Raise:
|
||||
ApiTypeError
|
||||
ApiValueError
|
||||
ApiKeyError
|
||||
"""
|
||||
fixed_model_data = copy.deepcopy(model_data)
|
||||
|
||||
if isinstance(fixed_model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(fixed_model_data,
|
||||
model_class)
|
||||
|
||||
kw_args = dict(_check_type=check_type,
|
||||
_path_to_item=path_to_item,
|
||||
_configuration=configuration,
|
||||
_from_server=from_server)
|
||||
|
||||
if hasattr(model_class, 'get_real_child_model'):
|
||||
# discriminator case
|
||||
discriminator_class = model_class.get_real_child_model(model_data)
|
||||
if discriminator_class:
|
||||
if isinstance(model_data, list):
|
||||
instance = discriminator_class(*model_data, **kw_args)
|
||||
elif isinstance(model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(
|
||||
fixed_model_data,
|
||||
discriminator_class
|
||||
)
|
||||
kw_args.update(fixed_model_data)
|
||||
instance = discriminator_class(**kw_args)
|
||||
else:
|
||||
# all other cases
|
||||
if isinstance(model_data, list):
|
||||
instance = model_class(*model_data, **kw_args)
|
||||
if isinstance(model_data, dict):
|
||||
fixed_model_data = change_keys_js_to_python(fixed_model_data,
|
||||
model_class)
|
||||
kw_args.update(fixed_model_data)
|
||||
instance = model_class(**kw_args)
|
||||
else:
|
||||
instance = model_class(model_data, **kw_args)
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
def deserialize_file(response_data, configuration, content_disposition=None):
|
||||
"""Deserializes body to file
|
||||
|
||||
Saves response body into a file in a temporary folder,
|
||||
using the filename from the `Content-Disposition` header if provided.
|
||||
|
||||
Args:
|
||||
param response_data (str): the file data to write
|
||||
configuration (Configuration): the instance to use to convert files
|
||||
|
||||
Keyword Args:
|
||||
content_disposition (str): the value of the Content-Disposition
|
||||
header
|
||||
|
||||
Returns:
|
||||
(file_type): the deserialized file which is open
|
||||
The user is responsible for closing and reading the file
|
||||
"""
|
||||
fd, path = tempfile.mkstemp(dir=configuration.temp_folder_path)
|
||||
os.close(fd)
|
||||
os.remove(path)
|
||||
|
||||
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:
|
||||
if six.PY3 and isinstance(response_data, str):
|
||||
# in python3 change str to bytes so we can write it
|
||||
response_data = response_data.encode('utf-8')
|
||||
f.write(response_data)
|
||||
|
||||
f = open(path, "rb")
|
||||
return f
|
||||
|
||||
|
||||
def attempt_convert_item(input_value, valid_classes, path_to_item,
|
||||
configuration, from_server, key_type=False,
|
||||
must_convert=False, check_type=True):
|
||||
"""
|
||||
Args:
|
||||
input_value (any): the data to convert
|
||||
valid_classes (any): the classes that are valid
|
||||
path_to_item (list): the path to the item to convert
|
||||
configuration (Configuration): the instance to use to convert files
|
||||
from_server (bool): True if data is from the server, False is data is
|
||||
from the client
|
||||
key_type (bool): if True we need to convert a key type (not supported)
|
||||
must_convert (bool): if True we must convert
|
||||
check_type (bool): if True we check the type or the returned data in
|
||||
ModelNormal and ModelSimple instances
|
||||
|
||||
Returns:
|
||||
instance (any) the fixed item
|
||||
|
||||
Raises:
|
||||
ApiTypeError
|
||||
ApiValueError
|
||||
ApiKeyError
|
||||
"""
|
||||
valid_classes_ordered = order_response_types(valid_classes)
|
||||
valid_classes_coercible = remove_uncoercible(
|
||||
valid_classes_ordered, input_value, from_server)
|
||||
if not valid_classes_coercible or key_type:
|
||||
# we do not handle keytype errors, json will take care
|
||||
# of this for us
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=key_type)
|
||||
for valid_class in valid_classes_coercible:
|
||||
try:
|
||||
if issubclass(valid_class, OpenApiModel):
|
||||
return deserialize_model(input_value, valid_class,
|
||||
path_to_item, check_type,
|
||||
configuration, from_server)
|
||||
elif valid_class == file_type:
|
||||
return deserialize_file(input_value, configuration)
|
||||
return deserialize_primitive(input_value, valid_class,
|
||||
path_to_item)
|
||||
except (ApiTypeError, ApiValueError, ApiKeyError) as conversion_exc:
|
||||
if must_convert:
|
||||
raise conversion_exc
|
||||
# if we have conversion errors when must_convert == False
|
||||
# we ignore the exception and move on to the next class
|
||||
continue
|
||||
# we were unable to convert, must_convert == False
|
||||
return input_value
|
||||
|
||||
|
||||
def validate_and_convert_types(input_value, required_types_mixed, path_to_item,
|
||||
from_server, _check_type, configuration=None):
|
||||
"""Raises a TypeError is there is a problem, otherwise returns value
|
||||
|
||||
Args:
|
||||
input_value (any): the data to validate/convert
|
||||
required_types_mixed (list/dict/tuple): A list of
|
||||
valid classes, or a list tuples of valid classes, or a dict where
|
||||
the value is a tuple of value classes
|
||||
path_to_item: (list) the path to the data being validated
|
||||
this stores a list of keys or indices to get to the data being
|
||||
validated
|
||||
from_server (bool): True if data is from the server
|
||||
False if data is from the client
|
||||
_check_type: (boolean) if true, type will be checked and conversion
|
||||
will be attempted.
|
||||
configuration: (Configuration): the configuration class to use
|
||||
when converting file_type items.
|
||||
If passed, conversion will be attempted when possible
|
||||
If not passed, no conversions will be attempted and
|
||||
exceptions will be raised
|
||||
|
||||
Returns:
|
||||
the correctly typed value
|
||||
|
||||
Raises:
|
||||
ApiTypeError
|
||||
"""
|
||||
results = get_required_type_classes(required_types_mixed)
|
||||
valid_classes, child_req_types_by_current_type = results
|
||||
|
||||
input_class_simple = get_simple_class(input_value)
|
||||
valid_type = input_class_simple in set(valid_classes)
|
||||
if not valid_type:
|
||||
if configuration:
|
||||
# if input_value is not valid_type try to convert it
|
||||
converted_instance = attempt_convert_item(
|
||||
input_value,
|
||||
valid_classes,
|
||||
path_to_item,
|
||||
configuration,
|
||||
from_server,
|
||||
key_type=False,
|
||||
must_convert=True
|
||||
)
|
||||
return converted_instance
|
||||
else:
|
||||
raise get_type_error(input_value, path_to_item, valid_classes,
|
||||
key_type=False)
|
||||
|
||||
# input_value's type is in valid_classes
|
||||
if len(valid_classes) > 1 and configuration:
|
||||
# there are valid classes which are not the current class
|
||||
valid_classes_coercible = remove_uncoercible(
|
||||
valid_classes, input_value, from_server, must_convert=False)
|
||||
if valid_classes_coercible:
|
||||
converted_instance = attempt_convert_item(
|
||||
input_value,
|
||||
valid_classes_coercible,
|
||||
path_to_item,
|
||||
configuration,
|
||||
from_server,
|
||||
key_type=False,
|
||||
must_convert=False
|
||||
)
|
||||
return converted_instance
|
||||
|
||||
if child_req_types_by_current_type == {}:
|
||||
# all types are of the required types and there are no more inner
|
||||
# variables left to look at
|
||||
return input_value
|
||||
inner_required_types = child_req_types_by_current_type.get(
|
||||
type(input_value)
|
||||
)
|
||||
if inner_required_types is None:
|
||||
# for this type, there are not more inner variables left to look at
|
||||
return input_value
|
||||
if isinstance(input_value, list):
|
||||
if input_value == []:
|
||||
# allow an empty list
|
||||
return input_value
|
||||
for index, inner_value in enumerate(input_value):
|
||||
inner_path = list(path_to_item)
|
||||
inner_path.append(index)
|
||||
input_value[index] = validate_and_convert_types(
|
||||
inner_value,
|
||||
inner_required_types,
|
||||
inner_path,
|
||||
from_server,
|
||||
_check_type,
|
||||
configuration=configuration
|
||||
)
|
||||
elif isinstance(input_value, dict):
|
||||
if input_value == {}:
|
||||
# allow an empty dict
|
||||
return input_value
|
||||
for inner_key, inner_val in six.iteritems(input_value):
|
||||
inner_path = list(path_to_item)
|
||||
inner_path.append(inner_key)
|
||||
if get_simple_class(inner_key) != str:
|
||||
raise get_type_error(inner_key, inner_path, valid_classes,
|
||||
key_type=True)
|
||||
input_value[inner_key] = validate_and_convert_types(
|
||||
inner_val,
|
||||
inner_required_types,
|
||||
inner_path,
|
||||
from_server,
|
||||
_check_type,
|
||||
configuration=configuration
|
||||
)
|
||||
return input_value
|
||||
|
||||
|
||||
def model_to_dict(model_instance, serialize=True):
|
||||
"""Returns the model properties as a dict
|
||||
|
||||
Args:
|
||||
model_instance (one of your model instances): the model instance that
|
||||
will be converted to a dict.
|
||||
|
||||
Keyword Args:
|
||||
serialize (bool): if True, the keys in the dict will be values from
|
||||
attribute_map
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for attr, value in six.iteritems(model_instance._data_store):
|
||||
if serialize:
|
||||
# we use get here because additional property key names do not
|
||||
# exist in attribute_map
|
||||
attr = model_instance.attribute_map.get(attr, attr)
|
||||
if isinstance(value, list):
|
||||
result[attr] = list(map(
|
||||
lambda x: model_to_dict(x, serialize=serialize)
|
||||
if hasattr(x, '_data_store') else x, value
|
||||
))
|
||||
elif isinstance(value, dict):
|
||||
result[attr] = dict(map(
|
||||
lambda item: (item[0],
|
||||
model_to_dict(item[1], serialize=serialize))
|
||||
if hasattr(item[1], '_data_store') else item,
|
||||
value.items()
|
||||
))
|
||||
elif hasattr(value, '_data_store'):
|
||||
result[attr] = model_to_dict(value, serialize=serialize)
|
||||
else:
|
||||
result[attr] = value
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def type_error_message(var_value=None, var_name=None, valid_classes=None,
|
||||
key_type=None):
|
||||
"""
|
||||
Keyword Args:
|
||||
var_value (any): the variable which has the type_error
|
||||
var_name (str): the name of the variable which has the typ error
|
||||
valid_classes (tuple): the accepted classes for current_item's
|
||||
value
|
||||
key_type (bool): False if our value is a value in a dict
|
||||
True if it is a key in a dict
|
||||
False if our item is an item in a list
|
||||
"""
|
||||
key_or_value = 'value'
|
||||
if key_type:
|
||||
key_or_value = 'key'
|
||||
valid_classes_phrase = get_valid_classes_phrase(valid_classes)
|
||||
msg = (
|
||||
"Invalid type for variable '{0}'. Required {1} type {2} and "
|
||||
"passed type was {3}".format(
|
||||
var_name,
|
||||
key_or_value,
|
||||
valid_classes_phrase,
|
||||
type(var_value).__name__,
|
||||
)
|
||||
)
|
||||
return msg
|
||||
|
||||
|
||||
def get_valid_classes_phrase(input_classes):
|
||||
"""Returns a string phrase describing what types are allowed
|
||||
Note: Adds the extra valid classes in python2
|
||||
"""
|
||||
all_classes = list(input_classes)
|
||||
if six.PY2 and str in input_classes:
|
||||
all_classes.extend([str_py2, unicode_py2])
|
||||
if six.PY2 and int in input_classes:
|
||||
all_classes.extend([int_py2, long_py2])
|
||||
all_classes = sorted(all_classes, key=lambda cls: cls.__name__)
|
||||
all_class_names = [cls.__name__ for cls in all_classes]
|
||||
if len(all_class_names) == 1:
|
||||
return 'is {0}'.format(all_class_names[0])
|
||||
return "is one of [{0}]".format(", ".join(all_class_names))
|
||||
|
||||
|
||||
def get_py3_class_name(input_class):
|
||||
if six.PY2:
|
||||
if input_class == str:
|
||||
return 'str'
|
||||
elif input_class == int:
|
||||
return 'int'
|
||||
return input_class.__name__
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class AdditionalPropertiesAnyType(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class AdditionalPropertiesAnyType(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'str'
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None): # noqa: E501
|
||||
"""AdditionalPropertiesAnyType - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = (bool, date, datetime, dict, float, int, list, str,) # noqa: E501
|
||||
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""AdditionalPropertiesAnyType - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
name (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this AdditionalPropertiesAnyType. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this AdditionalPropertiesAnyType. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this AdditionalPropertiesAnyType. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this AdditionalPropertiesAnyType.
|
||||
|
||||
|
||||
:param name: The name of this AdditionalPropertiesAnyType. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this AdditionalPropertiesAnyType. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class AdditionalPropertiesAnyType(ModelNormal):
|
||||
if not isinstance(other, AdditionalPropertiesAnyType):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class AdditionalPropertiesArray(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class AdditionalPropertiesArray(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'str'
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None): # noqa: E501
|
||||
"""AdditionalPropertiesArray - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = ([bool, date, datetime, dict, float, int, list, str],) # noqa: E501
|
||||
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""AdditionalPropertiesArray - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
name (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this AdditionalPropertiesArray. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this AdditionalPropertiesArray. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this AdditionalPropertiesArray. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this AdditionalPropertiesArray.
|
||||
|
||||
|
||||
:param name: The name of this AdditionalPropertiesArray. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this AdditionalPropertiesArray. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class AdditionalPropertiesArray(ModelNormal):
|
||||
if not isinstance(other, AdditionalPropertiesArray):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class AdditionalPropertiesBoolean(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class AdditionalPropertiesBoolean(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'str'
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None): # noqa: E501
|
||||
"""AdditionalPropertiesBoolean - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = (bool,) # noqa: E501
|
||||
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""AdditionalPropertiesBoolean - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
name (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this AdditionalPropertiesBoolean. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this AdditionalPropertiesBoolean. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this AdditionalPropertiesBoolean. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this AdditionalPropertiesBoolean.
|
||||
|
||||
|
||||
:param name: The name of this AdditionalPropertiesBoolean. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this AdditionalPropertiesBoolean. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class AdditionalPropertiesBoolean(ModelNormal):
|
||||
if not isinstance(other, AdditionalPropertiesBoolean):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class AdditionalPropertiesClass(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -66,359 +82,302 @@ class AdditionalPropertiesClass(ModelNormal):
|
||||
}
|
||||
|
||||
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'
|
||||
'map_string': ({str: (str,)},), # noqa: E501
|
||||
'map_number': ({str: (float,)},), # noqa: E501
|
||||
'map_integer': ({str: (int,)},), # noqa: E501
|
||||
'map_boolean': ({str: (bool,)},), # noqa: E501
|
||||
'map_array_integer': ({str: ([int],)},), # noqa: E501
|
||||
'map_array_anytype': ({str: ([bool, date, datetime, dict, float, int, list, str],)},), # noqa: E501
|
||||
'map_map_string': ({str: ({str: (str,)},)},), # noqa: E501
|
||||
'map_map_anytype': ({str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)},), # noqa: E501
|
||||
'anytype_1': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501
|
||||
'anytype_2': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501
|
||||
'anytype_3': (bool, date, datetime, dict, float, int, list, str,), # noqa: E501
|
||||
}
|
||||
|
||||
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""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._map_string = None
|
||||
self._map_number = None
|
||||
self._map_integer = None
|
||||
self._map_boolean = None
|
||||
self._map_array_integer = None
|
||||
self._map_array_anytype = None
|
||||
self._map_map_string = None
|
||||
self._map_map_anytype = None
|
||||
self._anytype_1 = None
|
||||
self._anytype_2 = None
|
||||
self._anytype_3 = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if map_string is not None:
|
||||
self.map_string = (
|
||||
map_string
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""AdditionalPropertiesClass - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
map_string ({str: (str,)}): [optional] # noqa: E501
|
||||
map_number ({str: (float,)}): [optional] # noqa: E501
|
||||
map_integer ({str: (int,)}): [optional] # noqa: E501
|
||||
map_boolean ({str: (bool,)}): [optional] # noqa: E501
|
||||
map_array_integer ({str: ([int],)}): [optional] # noqa: E501
|
||||
map_array_anytype ({str: ([bool, date, datetime, dict, float, int, list, str],)}): [optional] # noqa: E501
|
||||
map_map_string ({str: ({str: (str,)},)}): [optional] # noqa: E501
|
||||
map_map_anytype ({str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)}): [optional] # noqa: E501
|
||||
anytype_1 (bool, date, datetime, dict, float, int, list, str): [optional] # noqa: E501
|
||||
anytype_2 (bool, date, datetime, dict, float, int, list, str): [optional] # noqa: E501
|
||||
anytype_3 (bool, date, datetime, dict, float, int, list, str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if map_number is not None:
|
||||
self.map_number = (
|
||||
map_number
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if map_integer is not None:
|
||||
self.map_integer = (
|
||||
map_integer
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if map_boolean is not None:
|
||||
self.map_boolean = (
|
||||
map_boolean
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if map_array_integer is not None:
|
||||
self.map_array_integer = (
|
||||
map_array_integer
|
||||
)
|
||||
if map_array_anytype is not None:
|
||||
self.map_array_anytype = (
|
||||
map_array_anytype
|
||||
)
|
||||
if map_map_string is not None:
|
||||
self.map_map_string = (
|
||||
map_map_string
|
||||
)
|
||||
if map_map_anytype is not None:
|
||||
self.map_map_anytype = (
|
||||
map_map_anytype
|
||||
)
|
||||
if anytype_1 is not None:
|
||||
self.anytype_1 = (
|
||||
anytype_1
|
||||
)
|
||||
if anytype_2 is not None:
|
||||
self.anytype_2 = (
|
||||
anytype_2
|
||||
)
|
||||
if anytype_3 is not None:
|
||||
self.anytype_3 = (
|
||||
anytype_3
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def map_string(self):
|
||||
"""Gets the map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, str)
|
||||
Returns:
|
||||
({str: (str,)}): The map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map_string
|
||||
return self.__get_item('map_string')
|
||||
|
||||
@map_string.setter
|
||||
def map_string(self, map_string): # noqa: E501
|
||||
"""Sets the map_string of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map_string: The map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, str)
|
||||
def map_string(self, value):
|
||||
"""Sets the map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_string = (
|
||||
map_string
|
||||
)
|
||||
return self.__set_item('map_string', value)
|
||||
|
||||
@property
|
||||
def map_number(self):
|
||||
"""Gets the map_number of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_number of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, float)
|
||||
Returns:
|
||||
({str: (float,)}): The map_number of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map_number
|
||||
return self.__get_item('map_number')
|
||||
|
||||
@map_number.setter
|
||||
def map_number(self, map_number): # noqa: E501
|
||||
"""Sets the map_number of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map_number: The map_number of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, float)
|
||||
def map_number(self, value):
|
||||
"""Sets the map_number of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_number = (
|
||||
map_number
|
||||
)
|
||||
return self.__set_item('map_number', value)
|
||||
|
||||
@property
|
||||
def map_integer(self):
|
||||
"""Gets the map_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, int)
|
||||
Returns:
|
||||
({str: (int,)}): The map_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map_integer
|
||||
return self.__get_item('map_integer')
|
||||
|
||||
@map_integer.setter
|
||||
def map_integer(self, map_integer): # noqa: E501
|
||||
"""Sets the map_integer of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map_integer: The map_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, int)
|
||||
def map_integer(self, value):
|
||||
"""Sets the map_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_integer = (
|
||||
map_integer
|
||||
)
|
||||
return self.__set_item('map_integer', value)
|
||||
|
||||
@property
|
||||
def map_boolean(self):
|
||||
"""Gets the map_boolean of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_boolean of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, bool)
|
||||
Returns:
|
||||
({str: (bool,)}): The map_boolean of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map_boolean
|
||||
return self.__get_item('map_boolean')
|
||||
|
||||
@map_boolean.setter
|
||||
def map_boolean(self, map_boolean): # noqa: E501
|
||||
"""Sets the map_boolean of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map_boolean: The map_boolean of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, bool)
|
||||
def map_boolean(self, value):
|
||||
"""Sets the map_boolean of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_boolean = (
|
||||
map_boolean
|
||||
)
|
||||
return self.__set_item('map_boolean', value)
|
||||
|
||||
@property
|
||||
def map_array_integer(self):
|
||||
"""Gets the map_array_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_array_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, list[int])
|
||||
Returns:
|
||||
({str: ([int],)}): The map_array_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map_array_integer
|
||||
return self.__get_item('map_array_integer')
|
||||
|
||||
@map_array_integer.setter
|
||||
def map_array_integer(self, map_array_integer): # noqa: E501
|
||||
"""Sets the map_array_integer of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map_array_integer: The map_array_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, list[int])
|
||||
def map_array_integer(self, value):
|
||||
"""Sets the map_array_integer of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_array_integer = (
|
||||
map_array_integer
|
||||
)
|
||||
return self.__set_item('map_array_integer', value)
|
||||
|
||||
@property
|
||||
def map_array_anytype(self):
|
||||
"""Gets the map_array_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_array_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, list[object])
|
||||
Returns:
|
||||
({str: ([bool, date, datetime, dict, float, int, list, str],)}): The map_array_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map_array_anytype
|
||||
return self.__get_item('map_array_anytype')
|
||||
|
||||
@map_array_anytype.setter
|
||||
def map_array_anytype(self, map_array_anytype): # noqa: E501
|
||||
"""Sets the map_array_anytype of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map_array_anytype: The map_array_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, list[object])
|
||||
def map_array_anytype(self, value):
|
||||
"""Sets the map_array_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_array_anytype = (
|
||||
map_array_anytype
|
||||
)
|
||||
return self.__set_item('map_array_anytype', value)
|
||||
|
||||
@property
|
||||
def map_map_string(self):
|
||||
"""Gets the map_map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, dict(str, str))
|
||||
Returns:
|
||||
({str: ({str: (str,)},)}): The map_map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map_map_string
|
||||
return self.__get_item('map_map_string')
|
||||
|
||||
@map_map_string.setter
|
||||
def map_map_string(self, map_map_string): # noqa: E501
|
||||
"""Sets the map_map_string of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map_map_string: The map_map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, dict(str, str))
|
||||
def map_map_string(self, value):
|
||||
"""Sets the map_map_string of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_map_string = (
|
||||
map_map_string
|
||||
)
|
||||
return self.__set_item('map_map_string', value)
|
||||
|
||||
@property
|
||||
def map_map_anytype(self):
|
||||
"""Gets the map_map_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_map_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, dict(str, object))
|
||||
Returns:
|
||||
({str: ({str: (bool, date, datetime, dict, float, int, list, str,)},)}): The map_map_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map_map_anytype
|
||||
return self.__get_item('map_map_anytype')
|
||||
|
||||
@map_map_anytype.setter
|
||||
def map_map_anytype(self, map_map_anytype): # noqa: E501
|
||||
"""Sets the map_map_anytype of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map_map_anytype: The map_map_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, dict(str, object))
|
||||
def map_map_anytype(self, value):
|
||||
"""Sets the map_map_anytype of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_map_anytype = (
|
||||
map_map_anytype
|
||||
)
|
||||
return self.__set_item('map_map_anytype', value)
|
||||
|
||||
@property
|
||||
def anytype_1(self):
|
||||
"""Gets the anytype_1 of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The anytype_1 of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: object
|
||||
Returns:
|
||||
(bool, date, datetime, dict, float, int, list, str): The anytype_1 of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._anytype_1
|
||||
return self.__get_item('anytype_1')
|
||||
|
||||
@anytype_1.setter
|
||||
def anytype_1(self, anytype_1): # noqa: E501
|
||||
"""Sets the anytype_1 of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param anytype_1: The anytype_1 of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: object
|
||||
def anytype_1(self, value):
|
||||
"""Sets the anytype_1 of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._anytype_1 = (
|
||||
anytype_1
|
||||
)
|
||||
return self.__set_item('anytype_1', value)
|
||||
|
||||
@property
|
||||
def anytype_2(self):
|
||||
"""Gets the anytype_2 of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The anytype_2 of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: object
|
||||
Returns:
|
||||
(bool, date, datetime, dict, float, int, list, str): The anytype_2 of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._anytype_2
|
||||
return self.__get_item('anytype_2')
|
||||
|
||||
@anytype_2.setter
|
||||
def anytype_2(self, anytype_2): # noqa: E501
|
||||
"""Sets the anytype_2 of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param anytype_2: The anytype_2 of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: object
|
||||
def anytype_2(self, value):
|
||||
"""Sets the anytype_2 of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._anytype_2 = (
|
||||
anytype_2
|
||||
)
|
||||
return self.__set_item('anytype_2', value)
|
||||
|
||||
@property
|
||||
def anytype_3(self):
|
||||
"""Gets the anytype_3 of this AdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The anytype_3 of this AdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: object
|
||||
Returns:
|
||||
(bool, date, datetime, dict, float, int, list, str): The anytype_3 of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._anytype_3
|
||||
return self.__get_item('anytype_3')
|
||||
|
||||
@anytype_3.setter
|
||||
def anytype_3(self, anytype_3): # noqa: E501
|
||||
"""Sets the anytype_3 of this AdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param anytype_3: The anytype_3 of this AdditionalPropertiesClass. # noqa: E501
|
||||
:type: object
|
||||
def anytype_3(self, value):
|
||||
"""Sets the anytype_3 of this AdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._anytype_3 = (
|
||||
anytype_3
|
||||
)
|
||||
return self.__set_item('anytype_3', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -433,7 +392,22 @@ class AdditionalPropertiesClass(ModelNormal):
|
||||
if not isinstance(other, AdditionalPropertiesClass):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class AdditionalPropertiesInteger(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class AdditionalPropertiesInteger(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'str'
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None): # noqa: E501
|
||||
"""AdditionalPropertiesInteger - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = (int,) # noqa: E501
|
||||
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""AdditionalPropertiesInteger - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
name (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this AdditionalPropertiesInteger. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this AdditionalPropertiesInteger. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this AdditionalPropertiesInteger. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this AdditionalPropertiesInteger.
|
||||
|
||||
|
||||
:param name: The name of this AdditionalPropertiesInteger. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this AdditionalPropertiesInteger. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class AdditionalPropertiesInteger(ModelNormal):
|
||||
if not isinstance(other, AdditionalPropertiesInteger):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class AdditionalPropertiesNumber(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class AdditionalPropertiesNumber(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'str'
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None): # noqa: E501
|
||||
"""AdditionalPropertiesNumber - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = (float,) # noqa: E501
|
||||
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""AdditionalPropertiesNumber - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
name (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this AdditionalPropertiesNumber. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this AdditionalPropertiesNumber. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this AdditionalPropertiesNumber. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this AdditionalPropertiesNumber.
|
||||
|
||||
|
||||
:param name: The name of this AdditionalPropertiesNumber. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this AdditionalPropertiesNumber. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class AdditionalPropertiesNumber(ModelNormal):
|
||||
if not isinstance(other, AdditionalPropertiesNumber):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class AdditionalPropertiesObject(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class AdditionalPropertiesObject(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'str'
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None): # noqa: E501
|
||||
"""AdditionalPropertiesObject - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = ({str: (bool, date, datetime, dict, float, int, list, str,)},) # noqa: E501
|
||||
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""AdditionalPropertiesObject - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
name (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this AdditionalPropertiesObject. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this AdditionalPropertiesObject. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this AdditionalPropertiesObject. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this AdditionalPropertiesObject.
|
||||
|
||||
|
||||
:param name: The name of this AdditionalPropertiesObject. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this AdditionalPropertiesObject. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class AdditionalPropertiesObject(ModelNormal):
|
||||
if not isinstance(other, AdditionalPropertiesObject):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class AdditionalPropertiesString(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class AdditionalPropertiesString(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'str'
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None): # noqa: E501
|
||||
"""AdditionalPropertiesString - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = (str,) # noqa: E501
|
||||
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""AdditionalPropertiesString - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
name (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this AdditionalPropertiesString. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this AdditionalPropertiesString. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this AdditionalPropertiesString. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this AdditionalPropertiesString.
|
||||
|
||||
|
||||
:param name: The name of this AdditionalPropertiesString. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this AdditionalPropertiesString. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class AdditionalPropertiesString(ModelNormal):
|
||||
if not isinstance(other, AdditionalPropertiesString):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,13 +15,29 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.cat import Cat
|
||||
from petstore_api.models.dog import Dog
|
||||
|
||||
|
||||
class Animal(ModelNormal):
|
||||
@@ -46,6 +62,8 @@ class Animal(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -57,108 +75,165 @@ class Animal(ModelNormal):
|
||||
}
|
||||
|
||||
discriminator_value_class_map = {
|
||||
'Dog': 'Dog',
|
||||
'Cat': 'Cat'
|
||||
'Dog': Dog,
|
||||
'Cat': Cat
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'class_name': 'str',
|
||||
'color': 'str'
|
||||
'class_name': (str,), # noqa: E501
|
||||
'color': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, class_name=None, color='red'): # noqa: E501
|
||||
"""Animal - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._class_name = None
|
||||
self._color = None
|
||||
self.discriminator = 'class_name'
|
||||
discriminator = 'class_name'
|
||||
|
||||
self.class_name = class_name
|
||||
if color is not None:
|
||||
self.color = (
|
||||
color
|
||||
def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Animal - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
class_name (str):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('class_name', class_name)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
"""Gets the class_name of this Animal. # noqa: E501
|
||||
|
||||
|
||||
:return: The class_name of this Animal. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The class_name of this Animal. # noqa: E501
|
||||
"""
|
||||
return self._class_name
|
||||
return self.__get_item('class_name')
|
||||
|
||||
@class_name.setter
|
||||
def class_name(self, class_name): # noqa: E501
|
||||
"""Sets the class_name of this Animal.
|
||||
|
||||
|
||||
:param class_name: The class_name of this Animal. # noqa: E501
|
||||
:type: str
|
||||
def class_name(self, value):
|
||||
"""Sets the class_name of this Animal. # noqa: E501
|
||||
"""
|
||||
if class_name is None:
|
||||
raise ApiValueError("Invalid value for `class_name`, must not be `None`") # noqa: E501
|
||||
|
||||
self._class_name = (
|
||||
class_name
|
||||
)
|
||||
return self.__set_item('class_name', value)
|
||||
|
||||
@property
|
||||
def color(self):
|
||||
"""Gets the color of this Animal. # noqa: E501
|
||||
|
||||
|
||||
:return: The color of this Animal. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The color of this Animal. # noqa: E501
|
||||
"""
|
||||
return self._color
|
||||
return self.__get_item('color')
|
||||
|
||||
@color.setter
|
||||
def color(self, color): # noqa: E501
|
||||
"""Sets the color of this Animal.
|
||||
|
||||
|
||||
:param color: The color of this Animal. # noqa: E501
|
||||
:type: str
|
||||
def color(self, value):
|
||||
"""Sets the color of this Animal. # noqa: E501
|
||||
"""
|
||||
return self.__set_item('color', value)
|
||||
|
||||
self._color = (
|
||||
color
|
||||
)
|
||||
|
||||
def get_real_child_model(self, data):
|
||||
"""Returns the real base class specified by the discriminator"""
|
||||
discriminator_key = self.attribute_map[self.discriminator]
|
||||
@classmethod
|
||||
def get_real_child_model(cls, data):
|
||||
"""Returns the real base class specified by the discriminator
|
||||
We assume that data has javascript keys
|
||||
"""
|
||||
discriminator_key = cls.attribute_map[cls.discriminator]
|
||||
discriminator_value = data[discriminator_key]
|
||||
return self.discriminator_value_class_map.get(discriminator_value)
|
||||
return cls.discriminator_value_class_map.get(discriminator_value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -173,7 +248,22 @@ class Animal(ModelNormal):
|
||||
if not isinstance(other, Animal):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class ApiResponse(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -58,127 +74,166 @@ class ApiResponse(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'code': 'int',
|
||||
'type': 'str',
|
||||
'message': 'str'
|
||||
'code': (int,), # noqa: E501
|
||||
'type': (str,), # noqa: E501
|
||||
'message': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, code=None, type=None, message=None): # noqa: E501
|
||||
"""ApiResponse - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._code = None
|
||||
self._type = None
|
||||
self._message = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if code is not None:
|
||||
self.code = (
|
||||
code
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""ApiResponse - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
code (int): [optional] # noqa: E501
|
||||
type (str): [optional] # noqa: E501
|
||||
message (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if type is not None:
|
||||
self.type = (
|
||||
type
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if message is not None:
|
||||
self.message = (
|
||||
message
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def code(self):
|
||||
"""Gets the code of this ApiResponse. # noqa: E501
|
||||
|
||||
|
||||
:return: The code of this ApiResponse. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The code of this ApiResponse. # noqa: E501
|
||||
"""
|
||||
return self._code
|
||||
return self.__get_item('code')
|
||||
|
||||
@code.setter
|
||||
def code(self, code): # noqa: E501
|
||||
"""Sets the code of this ApiResponse.
|
||||
|
||||
|
||||
:param code: The code of this ApiResponse. # noqa: E501
|
||||
:type: int
|
||||
def code(self, value):
|
||||
"""Sets the code of this ApiResponse. # noqa: E501
|
||||
"""
|
||||
|
||||
self._code = (
|
||||
code
|
||||
)
|
||||
return self.__set_item('code', value)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
"""Gets the type of this ApiResponse. # noqa: E501
|
||||
|
||||
|
||||
:return: The type of this ApiResponse. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The type of this ApiResponse. # noqa: E501
|
||||
"""
|
||||
return self._type
|
||||
return self.__get_item('type')
|
||||
|
||||
@type.setter
|
||||
def type(self, type): # noqa: E501
|
||||
"""Sets the type of this ApiResponse.
|
||||
|
||||
|
||||
:param type: The type of this ApiResponse. # noqa: E501
|
||||
:type: str
|
||||
def type(self, value):
|
||||
"""Sets the type of this ApiResponse. # noqa: E501
|
||||
"""
|
||||
|
||||
self._type = (
|
||||
type
|
||||
)
|
||||
return self.__set_item('type', value)
|
||||
|
||||
@property
|
||||
def message(self):
|
||||
"""Gets the message of this ApiResponse. # noqa: E501
|
||||
|
||||
|
||||
:return: The message of this ApiResponse. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The message of this ApiResponse. # noqa: E501
|
||||
"""
|
||||
return self._message
|
||||
return self.__get_item('message')
|
||||
|
||||
@message.setter
|
||||
def message(self, message): # noqa: E501
|
||||
"""Sets the message of this ApiResponse.
|
||||
|
||||
|
||||
:param message: The message of this ApiResponse. # noqa: E501
|
||||
:type: str
|
||||
def message(self, value):
|
||||
"""Sets the message of this ApiResponse. # noqa: E501
|
||||
"""
|
||||
|
||||
self._message = (
|
||||
message
|
||||
)
|
||||
return self.__set_item('message', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -193,7 +248,22 @@ class ApiResponse(ModelNormal):
|
||||
if not isinstance(other, ApiResponse):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class ArrayOfArrayOfNumberOnly(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class ArrayOfArrayOfNumberOnly(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'array_array_number': 'list[list[float]]'
|
||||
'array_array_number': ([[float]],), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, array_array_number=None): # noqa: E501
|
||||
"""ArrayOfArrayOfNumberOnly - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._array_array_number = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if array_array_number is not None:
|
||||
self.array_array_number = (
|
||||
array_array_number
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""ArrayOfArrayOfNumberOnly - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
array_array_number ([[float]]): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def array_array_number(self):
|
||||
"""Gets the array_array_number of this ArrayOfArrayOfNumberOnly. # noqa: E501
|
||||
|
||||
|
||||
:return: The array_array_number of this ArrayOfArrayOfNumberOnly. # noqa: E501
|
||||
:rtype: list[list[float]]
|
||||
Returns:
|
||||
([[float]]): The array_array_number of this ArrayOfArrayOfNumberOnly. # noqa: E501
|
||||
"""
|
||||
return self._array_array_number
|
||||
return self.__get_item('array_array_number')
|
||||
|
||||
@array_array_number.setter
|
||||
def array_array_number(self, array_array_number): # noqa: E501
|
||||
"""Sets the array_array_number of this ArrayOfArrayOfNumberOnly.
|
||||
|
||||
|
||||
:param array_array_number: The array_array_number of this ArrayOfArrayOfNumberOnly. # noqa: E501
|
||||
:type: list[list[float]]
|
||||
def array_array_number(self, value):
|
||||
"""Sets the array_array_number of this ArrayOfArrayOfNumberOnly. # noqa: E501
|
||||
"""
|
||||
|
||||
self._array_array_number = (
|
||||
array_array_number
|
||||
)
|
||||
return self.__set_item('array_array_number', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class ArrayOfArrayOfNumberOnly(ModelNormal):
|
||||
if not isinstance(other, ArrayOfArrayOfNumberOnly):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class ArrayOfNumberOnly(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class ArrayOfNumberOnly(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'array_number': 'list[float]'
|
||||
'array_number': ([float],), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, array_number=None): # noqa: E501
|
||||
"""ArrayOfNumberOnly - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._array_number = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if array_number is not None:
|
||||
self.array_number = (
|
||||
array_number
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""ArrayOfNumberOnly - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
array_number ([float]): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def array_number(self):
|
||||
"""Gets the array_number of this ArrayOfNumberOnly. # noqa: E501
|
||||
|
||||
|
||||
:return: The array_number of this ArrayOfNumberOnly. # noqa: E501
|
||||
:rtype: list[float]
|
||||
Returns:
|
||||
([float]): The array_number of this ArrayOfNumberOnly. # noqa: E501
|
||||
"""
|
||||
return self._array_number
|
||||
return self.__get_item('array_number')
|
||||
|
||||
@array_number.setter
|
||||
def array_number(self, array_number): # noqa: E501
|
||||
"""Sets the array_number of this ArrayOfNumberOnly.
|
||||
|
||||
|
||||
:param array_number: The array_number of this ArrayOfNumberOnly. # noqa: E501
|
||||
:type: list[float]
|
||||
def array_number(self, value):
|
||||
"""Sets the array_number of this ArrayOfNumberOnly. # noqa: E501
|
||||
"""
|
||||
|
||||
self._array_number = (
|
||||
array_number
|
||||
)
|
||||
return self.__set_item('array_number', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class ArrayOfNumberOnly(ModelNormal):
|
||||
if not isinstance(other, ArrayOfNumberOnly):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,13 +15,28 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.read_only_first import ReadOnlyFirst
|
||||
|
||||
|
||||
class ArrayTest(ModelNormal):
|
||||
@@ -46,6 +61,8 @@ class ArrayTest(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -58,127 +75,166 @@ class ArrayTest(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'array_of_string': 'list[str]',
|
||||
'array_array_of_integer': 'list[list[int]]',
|
||||
'array_array_of_model': 'list[list[ReadOnlyFirst]]'
|
||||
'array_of_string': ([str],), # noqa: E501
|
||||
'array_array_of_integer': ([[int]],), # noqa: E501
|
||||
'array_array_of_model': ([[ReadOnlyFirst]],), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._array_of_string = None
|
||||
self._array_array_of_integer = None
|
||||
self._array_array_of_model = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if array_of_string is not None:
|
||||
self.array_of_string = (
|
||||
array_of_string
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""ArrayTest - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
array_of_string ([str]): [optional] # noqa: E501
|
||||
array_array_of_integer ([[int]]): [optional] # noqa: E501
|
||||
array_array_of_model ([[ReadOnlyFirst]]): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if array_array_of_integer is not None:
|
||||
self.array_array_of_integer = (
|
||||
array_array_of_integer
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if array_array_of_model is not None:
|
||||
self.array_array_of_model = (
|
||||
array_array_of_model
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def array_of_string(self):
|
||||
"""Gets the array_of_string of this ArrayTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The array_of_string of this ArrayTest. # noqa: E501
|
||||
:rtype: list[str]
|
||||
Returns:
|
||||
([str]): The array_of_string of this ArrayTest. # noqa: E501
|
||||
"""
|
||||
return self._array_of_string
|
||||
return self.__get_item('array_of_string')
|
||||
|
||||
@array_of_string.setter
|
||||
def array_of_string(self, array_of_string): # noqa: E501
|
||||
"""Sets the array_of_string of this ArrayTest.
|
||||
|
||||
|
||||
:param array_of_string: The array_of_string of this ArrayTest. # noqa: E501
|
||||
:type: list[str]
|
||||
def array_of_string(self, value):
|
||||
"""Sets the array_of_string of this ArrayTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._array_of_string = (
|
||||
array_of_string
|
||||
)
|
||||
return self.__set_item('array_of_string', value)
|
||||
|
||||
@property
|
||||
def array_array_of_integer(self):
|
||||
"""Gets the array_array_of_integer of this ArrayTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The array_array_of_integer of this ArrayTest. # noqa: E501
|
||||
:rtype: list[list[int]]
|
||||
Returns:
|
||||
([[int]]): The array_array_of_integer of this ArrayTest. # noqa: E501
|
||||
"""
|
||||
return self._array_array_of_integer
|
||||
return self.__get_item('array_array_of_integer')
|
||||
|
||||
@array_array_of_integer.setter
|
||||
def array_array_of_integer(self, array_array_of_integer): # noqa: E501
|
||||
"""Sets the array_array_of_integer of this ArrayTest.
|
||||
|
||||
|
||||
:param array_array_of_integer: The array_array_of_integer of this ArrayTest. # noqa: E501
|
||||
:type: list[list[int]]
|
||||
def array_array_of_integer(self, value):
|
||||
"""Sets the array_array_of_integer of this ArrayTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._array_array_of_integer = (
|
||||
array_array_of_integer
|
||||
)
|
||||
return self.__set_item('array_array_of_integer', value)
|
||||
|
||||
@property
|
||||
def array_array_of_model(self):
|
||||
"""Gets the array_array_of_model of this ArrayTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The array_array_of_model of this ArrayTest. # noqa: E501
|
||||
:rtype: list[list[ReadOnlyFirst]]
|
||||
Returns:
|
||||
([[ReadOnlyFirst]]): The array_array_of_model of this ArrayTest. # noqa: E501
|
||||
"""
|
||||
return self._array_array_of_model
|
||||
return self.__get_item('array_array_of_model')
|
||||
|
||||
@array_array_of_model.setter
|
||||
def array_array_of_model(self, array_array_of_model): # noqa: E501
|
||||
"""Sets the array_array_of_model of this ArrayTest.
|
||||
|
||||
|
||||
:param array_array_of_model: The array_array_of_model of this ArrayTest. # noqa: E501
|
||||
:type: list[list[ReadOnlyFirst]]
|
||||
def array_array_of_model(self, value):
|
||||
"""Sets the array_array_of_model of this ArrayTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._array_array_of_model = (
|
||||
array_array_of_model
|
||||
)
|
||||
return self.__set_item('array_array_of_model', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -193,7 +249,22 @@ class ArrayTest(ModelNormal):
|
||||
if not isinstance(other, ArrayTest):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class Capitalization(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -61,216 +77,219 @@ class Capitalization(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'small_camel': 'str',
|
||||
'capital_camel': 'str',
|
||||
'small_snake': 'str',
|
||||
'capital_snake': 'str',
|
||||
'sca_eth_flow_points': 'str',
|
||||
'att_name': 'str'
|
||||
'small_camel': (str,), # noqa: E501
|
||||
'capital_camel': (str,), # noqa: E501
|
||||
'small_snake': (str,), # noqa: E501
|
||||
'capital_snake': (str,), # noqa: E501
|
||||
'sca_eth_flow_points': (str,), # noqa: E501
|
||||
'att_name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._small_camel = None
|
||||
self._capital_camel = None
|
||||
self._small_snake = None
|
||||
self._capital_snake = None
|
||||
self._sca_eth_flow_points = None
|
||||
self._att_name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if small_camel is not None:
|
||||
self.small_camel = (
|
||||
small_camel
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Capitalization - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
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
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if capital_camel is not None:
|
||||
self.capital_camel = (
|
||||
capital_camel
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if small_snake is not None:
|
||||
self.small_snake = (
|
||||
small_snake
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if capital_snake is not None:
|
||||
self.capital_snake = (
|
||||
capital_snake
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if sca_eth_flow_points is not None:
|
||||
self.sca_eth_flow_points = (
|
||||
sca_eth_flow_points
|
||||
)
|
||||
if att_name is not None:
|
||||
self.att_name = (
|
||||
att_name
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def small_camel(self):
|
||||
"""Gets the small_camel of this Capitalization. # noqa: E501
|
||||
|
||||
|
||||
:return: The small_camel of this Capitalization. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The small_camel of this Capitalization. # noqa: E501
|
||||
"""
|
||||
return self._small_camel
|
||||
return self.__get_item('small_camel')
|
||||
|
||||
@small_camel.setter
|
||||
def small_camel(self, small_camel): # noqa: E501
|
||||
"""Sets the small_camel of this Capitalization.
|
||||
|
||||
|
||||
:param small_camel: The small_camel of this Capitalization. # noqa: E501
|
||||
:type: str
|
||||
def small_camel(self, value):
|
||||
"""Sets the small_camel of this Capitalization. # noqa: E501
|
||||
"""
|
||||
|
||||
self._small_camel = (
|
||||
small_camel
|
||||
)
|
||||
return self.__set_item('small_camel', value)
|
||||
|
||||
@property
|
||||
def capital_camel(self):
|
||||
"""Gets the capital_camel of this Capitalization. # noqa: E501
|
||||
|
||||
|
||||
:return: The capital_camel of this Capitalization. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The capital_camel of this Capitalization. # noqa: E501
|
||||
"""
|
||||
return self._capital_camel
|
||||
return self.__get_item('capital_camel')
|
||||
|
||||
@capital_camel.setter
|
||||
def capital_camel(self, capital_camel): # noqa: E501
|
||||
"""Sets the capital_camel of this Capitalization.
|
||||
|
||||
|
||||
:param capital_camel: The capital_camel of this Capitalization. # noqa: E501
|
||||
:type: str
|
||||
def capital_camel(self, value):
|
||||
"""Sets the capital_camel of this Capitalization. # noqa: E501
|
||||
"""
|
||||
|
||||
self._capital_camel = (
|
||||
capital_camel
|
||||
)
|
||||
return self.__set_item('capital_camel', value)
|
||||
|
||||
@property
|
||||
def small_snake(self):
|
||||
"""Gets the small_snake of this Capitalization. # noqa: E501
|
||||
|
||||
|
||||
:return: The small_snake of this Capitalization. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The small_snake of this Capitalization. # noqa: E501
|
||||
"""
|
||||
return self._small_snake
|
||||
return self.__get_item('small_snake')
|
||||
|
||||
@small_snake.setter
|
||||
def small_snake(self, small_snake): # noqa: E501
|
||||
"""Sets the small_snake of this Capitalization.
|
||||
|
||||
|
||||
:param small_snake: The small_snake of this Capitalization. # noqa: E501
|
||||
:type: str
|
||||
def small_snake(self, value):
|
||||
"""Sets the small_snake of this Capitalization. # noqa: E501
|
||||
"""
|
||||
|
||||
self._small_snake = (
|
||||
small_snake
|
||||
)
|
||||
return self.__set_item('small_snake', value)
|
||||
|
||||
@property
|
||||
def capital_snake(self):
|
||||
"""Gets the capital_snake of this Capitalization. # noqa: E501
|
||||
|
||||
|
||||
:return: The capital_snake of this Capitalization. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The capital_snake of this Capitalization. # noqa: E501
|
||||
"""
|
||||
return self._capital_snake
|
||||
return self.__get_item('capital_snake')
|
||||
|
||||
@capital_snake.setter
|
||||
def capital_snake(self, capital_snake): # noqa: E501
|
||||
"""Sets the capital_snake of this Capitalization.
|
||||
|
||||
|
||||
:param capital_snake: The capital_snake of this Capitalization. # noqa: E501
|
||||
:type: str
|
||||
def capital_snake(self, value):
|
||||
"""Sets the capital_snake of this Capitalization. # noqa: E501
|
||||
"""
|
||||
|
||||
self._capital_snake = (
|
||||
capital_snake
|
||||
)
|
||||
return self.__set_item('capital_snake', value)
|
||||
|
||||
@property
|
||||
def sca_eth_flow_points(self):
|
||||
"""Gets the sca_eth_flow_points of this Capitalization. # noqa: E501
|
||||
|
||||
|
||||
:return: The sca_eth_flow_points of this Capitalization. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The sca_eth_flow_points of this Capitalization. # noqa: E501
|
||||
"""
|
||||
return self._sca_eth_flow_points
|
||||
return self.__get_item('sca_eth_flow_points')
|
||||
|
||||
@sca_eth_flow_points.setter
|
||||
def sca_eth_flow_points(self, sca_eth_flow_points): # noqa: E501
|
||||
"""Sets the sca_eth_flow_points of this Capitalization.
|
||||
|
||||
|
||||
:param sca_eth_flow_points: The sca_eth_flow_points of this Capitalization. # noqa: E501
|
||||
:type: str
|
||||
def sca_eth_flow_points(self, value):
|
||||
"""Sets the sca_eth_flow_points of this Capitalization. # noqa: E501
|
||||
"""
|
||||
|
||||
self._sca_eth_flow_points = (
|
||||
sca_eth_flow_points
|
||||
)
|
||||
return self.__set_item('sca_eth_flow_points', value)
|
||||
|
||||
@property
|
||||
def att_name(self):
|
||||
"""Gets the att_name of this Capitalization. # noqa: E501
|
||||
|
||||
Name of the pet # noqa: E501
|
||||
|
||||
:return: The att_name of this Capitalization. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The att_name of this Capitalization. # noqa: E501
|
||||
"""
|
||||
return self._att_name
|
||||
return self.__get_item('att_name')
|
||||
|
||||
@att_name.setter
|
||||
def att_name(self, att_name): # noqa: E501
|
||||
"""Sets the att_name of this Capitalization.
|
||||
|
||||
def att_name(self, value):
|
||||
"""Sets the att_name of this Capitalization. # noqa: E501
|
||||
Name of the pet # noqa: E501
|
||||
|
||||
:param att_name: The att_name of this Capitalization. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
|
||||
self._att_name = (
|
||||
att_name
|
||||
)
|
||||
return self.__set_item('att_name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -285,7 +304,22 @@ class Capitalization(ModelNormal):
|
||||
if not isinstance(other, Capitalization):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,79 +60,182 @@ class Cat(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
'class_name': 'className', # noqa: E501
|
||||
'color': 'color', # noqa: E501
|
||||
'declawed': 'declawed' # noqa: E501
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'declawed': 'bool'
|
||||
'class_name': (str,), # noqa: E501
|
||||
'color': (str,), # noqa: E501
|
||||
'declawed': (bool,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, declawed=None): # noqa: E501
|
||||
"""Cat - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._declawed = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if declawed is not None:
|
||||
self.declawed = (
|
||||
declawed
|
||||
def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Cat - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
class_name (str):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
declawed (bool): [optional] # noqa: E501
|
||||
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('class_name', class_name)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
"""Gets the class_name of this Cat. # noqa: E501
|
||||
|
||||
Returns:
|
||||
(str): The class_name of this Cat. # noqa: E501
|
||||
"""
|
||||
return self.__get_item('class_name')
|
||||
|
||||
@class_name.setter
|
||||
def class_name(self, value):
|
||||
"""Sets the class_name of this Cat. # noqa: E501
|
||||
"""
|
||||
return self.__set_item('class_name', value)
|
||||
|
||||
@property
|
||||
def color(self):
|
||||
"""Gets the color of this Cat. # noqa: E501
|
||||
|
||||
Returns:
|
||||
(str): The color of this Cat. # noqa: E501
|
||||
"""
|
||||
return self.__get_item('color')
|
||||
|
||||
@color.setter
|
||||
def color(self, value):
|
||||
"""Sets the color of this Cat. # noqa: E501
|
||||
"""
|
||||
return self.__set_item('color', value)
|
||||
|
||||
@property
|
||||
def declawed(self):
|
||||
"""Gets the declawed of this Cat. # noqa: E501
|
||||
|
||||
|
||||
:return: The declawed of this Cat. # noqa: E501
|
||||
:rtype: bool
|
||||
Returns:
|
||||
(bool): The declawed of this Cat. # noqa: E501
|
||||
"""
|
||||
return self._declawed
|
||||
return self.__get_item('declawed')
|
||||
|
||||
@declawed.setter
|
||||
def declawed(self, declawed): # noqa: E501
|
||||
"""Sets the declawed of this Cat.
|
||||
|
||||
|
||||
:param declawed: The declawed of this Cat. # noqa: E501
|
||||
:type: bool
|
||||
def declawed(self, value):
|
||||
"""Sets the declawed of this Cat. # noqa: E501
|
||||
"""
|
||||
|
||||
self._declawed = (
|
||||
declawed
|
||||
)
|
||||
return self.__set_item('declawed', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +250,22 @@ class Cat(ModelNormal):
|
||||
if not isinstance(other, Cat):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class CatAllOf(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class CatAllOf(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'declawed': 'bool'
|
||||
'declawed': (bool,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, declawed=None): # noqa: E501
|
||||
"""CatAllOf - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._declawed = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if declawed is not None:
|
||||
self.declawed = (
|
||||
declawed
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""CatAllOf - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
declawed (bool): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def declawed(self):
|
||||
"""Gets the declawed of this CatAllOf. # noqa: E501
|
||||
|
||||
|
||||
:return: The declawed of this CatAllOf. # noqa: E501
|
||||
:rtype: bool
|
||||
Returns:
|
||||
(bool): The declawed of this CatAllOf. # noqa: E501
|
||||
"""
|
||||
return self._declawed
|
||||
return self.__get_item('declawed')
|
||||
|
||||
@declawed.setter
|
||||
def declawed(self, declawed): # noqa: E501
|
||||
"""Sets the declawed of this CatAllOf.
|
||||
|
||||
|
||||
:param declawed: The declawed of this CatAllOf. # noqa: E501
|
||||
:type: bool
|
||||
def declawed(self, value):
|
||||
"""Sets the declawed of this CatAllOf. # noqa: E501
|
||||
"""
|
||||
|
||||
self._declawed = (
|
||||
declawed
|
||||
)
|
||||
return self.__set_item('declawed', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class CatAllOf(ModelNormal):
|
||||
if not isinstance(other, CatAllOf):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class Category(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -57,97 +73,151 @@ class Category(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'id': 'int',
|
||||
'name': 'str'
|
||||
'id': (int,), # noqa: E501
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, id=None, name='default-name'): # noqa: E501
|
||||
"""Category - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._id = None
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if id is not None:
|
||||
self.id = (
|
||||
id
|
||||
def __init__(self, name='default-name', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Category - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
|
||||
Keyword Args:
|
||||
name (str): defaults to 'default-name', must be one of ['default-name'] # noqa: E501
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
id (int): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('name', name)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
self.name = name
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""Gets the id of this Category. # noqa: E501
|
||||
|
||||
|
||||
:return: The id of this Category. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The id of this Category. # noqa: E501
|
||||
"""
|
||||
return self._id
|
||||
return self.__get_item('id')
|
||||
|
||||
@id.setter
|
||||
def id(self, id): # noqa: E501
|
||||
"""Sets the id of this Category.
|
||||
|
||||
|
||||
:param id: The id of this Category. # noqa: E501
|
||||
:type: int
|
||||
def id(self, value):
|
||||
"""Sets the id of this Category. # noqa: E501
|
||||
"""
|
||||
|
||||
self._id = (
|
||||
id
|
||||
)
|
||||
return self.__set_item('id', value)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this Category. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this Category. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this Category. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this Category.
|
||||
|
||||
|
||||
:param name: The name of this Category. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this Category. # noqa: E501
|
||||
"""
|
||||
if name is None:
|
||||
raise ApiValueError("Invalid value for `name`, must not be `None`") # noqa: E501
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -162,7 +232,22 @@ class Category(ModelNormal):
|
||||
if not isinstance(other, Category):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class ClassModel(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class ClassModel(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'_class': 'str'
|
||||
'_class': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, _class=None): # noqa: E501
|
||||
"""ClassModel - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self.__class = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if _class is not None:
|
||||
self._class = (
|
||||
_class
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""ClassModel - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
_class (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def _class(self):
|
||||
"""Gets the _class of this ClassModel. # noqa: E501
|
||||
|
||||
|
||||
:return: The _class of this ClassModel. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The _class of this ClassModel. # noqa: E501
|
||||
"""
|
||||
return self.__class
|
||||
return self.__get_item('_class')
|
||||
|
||||
@_class.setter
|
||||
def _class(self, _class): # noqa: E501
|
||||
"""Sets the _class of this ClassModel.
|
||||
|
||||
|
||||
:param _class: The _class of this ClassModel. # noqa: E501
|
||||
:type: str
|
||||
def _class(self, value):
|
||||
"""Sets the _class of this ClassModel. # noqa: E501
|
||||
"""
|
||||
|
||||
self.__class = (
|
||||
_class
|
||||
)
|
||||
return self.__set_item('_class', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class ClassModel(ModelNormal):
|
||||
if not isinstance(other, ClassModel):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class Client(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class Client(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'client': 'str'
|
||||
'client': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, client=None): # noqa: E501
|
||||
"""Client - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._client = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if client is not None:
|
||||
self.client = (
|
||||
client
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Client - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
client (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def client(self):
|
||||
"""Gets the client of this Client. # noqa: E501
|
||||
|
||||
|
||||
:return: The client of this Client. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The client of this Client. # noqa: E501
|
||||
"""
|
||||
return self._client
|
||||
return self.__get_item('client')
|
||||
|
||||
@client.setter
|
||||
def client(self, client): # noqa: E501
|
||||
"""Sets the client of this Client.
|
||||
|
||||
|
||||
:param client: The client of this Client. # noqa: E501
|
||||
:type: str
|
||||
def client(self, value):
|
||||
"""Sets the client of this Client. # noqa: E501
|
||||
"""
|
||||
|
||||
self._client = (
|
||||
client
|
||||
)
|
||||
return self.__set_item('client', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class Client(ModelNormal):
|
||||
if not isinstance(other, Client):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,79 +60,182 @@ class Dog(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
}
|
||||
|
||||
attribute_map = {
|
||||
'class_name': 'className', # noqa: E501
|
||||
'color': 'color', # noqa: E501
|
||||
'breed': 'breed' # noqa: E501
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'breed': 'str'
|
||||
'class_name': (str,), # noqa: E501
|
||||
'color': (str,), # noqa: E501
|
||||
'breed': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, breed=None): # noqa: E501
|
||||
"""Dog - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._breed = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if breed is not None:
|
||||
self.breed = (
|
||||
breed
|
||||
def __init__(self, class_name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Dog - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
class_name (str):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
breed (str): [optional] # noqa: E501
|
||||
color (str): [optional] if omitted the server will use the default value of 'red' # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('class_name', class_name)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def class_name(self):
|
||||
"""Gets the class_name of this Dog. # noqa: E501
|
||||
|
||||
Returns:
|
||||
(str): The class_name of this Dog. # noqa: E501
|
||||
"""
|
||||
return self.__get_item('class_name')
|
||||
|
||||
@class_name.setter
|
||||
def class_name(self, value):
|
||||
"""Sets the class_name of this Dog. # noqa: E501
|
||||
"""
|
||||
return self.__set_item('class_name', value)
|
||||
|
||||
@property
|
||||
def color(self):
|
||||
"""Gets the color of this Dog. # noqa: E501
|
||||
|
||||
Returns:
|
||||
(str): The color of this Dog. # noqa: E501
|
||||
"""
|
||||
return self.__get_item('color')
|
||||
|
||||
@color.setter
|
||||
def color(self, value):
|
||||
"""Sets the color of this Dog. # noqa: E501
|
||||
"""
|
||||
return self.__set_item('color', value)
|
||||
|
||||
@property
|
||||
def breed(self):
|
||||
"""Gets the breed of this Dog. # noqa: E501
|
||||
|
||||
|
||||
:return: The breed of this Dog. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The breed of this Dog. # noqa: E501
|
||||
"""
|
||||
return self._breed
|
||||
return self.__get_item('breed')
|
||||
|
||||
@breed.setter
|
||||
def breed(self, breed): # noqa: E501
|
||||
"""Sets the breed of this Dog.
|
||||
|
||||
|
||||
:param breed: The breed of this Dog. # noqa: E501
|
||||
:type: str
|
||||
def breed(self, value):
|
||||
"""Sets the breed of this Dog. # noqa: E501
|
||||
"""
|
||||
|
||||
self._breed = (
|
||||
breed
|
||||
)
|
||||
return self.__set_item('breed', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +250,22 @@ class Dog(ModelNormal):
|
||||
if not isinstance(other, Dog):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class DogAllOf(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class DogAllOf(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'breed': 'str'
|
||||
'breed': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, breed=None): # noqa: E501
|
||||
"""DogAllOf - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._breed = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if breed is not None:
|
||||
self.breed = (
|
||||
breed
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""DogAllOf - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
breed (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def breed(self):
|
||||
"""Gets the breed of this DogAllOf. # noqa: E501
|
||||
|
||||
|
||||
:return: The breed of this DogAllOf. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The breed of this DogAllOf. # noqa: E501
|
||||
"""
|
||||
return self._breed
|
||||
return self.__get_item('breed')
|
||||
|
||||
@breed.setter
|
||||
def breed(self, breed): # noqa: E501
|
||||
"""Sets the breed of this DogAllOf.
|
||||
|
||||
|
||||
:param breed: The breed of this DogAllOf. # noqa: E501
|
||||
:type: str
|
||||
def breed(self, value):
|
||||
"""Sets the breed of this DogAllOf. # noqa: E501
|
||||
"""
|
||||
|
||||
self._breed = (
|
||||
breed
|
||||
)
|
||||
return self.__set_item('breed', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class DogAllOf(ModelNormal):
|
||||
if not isinstance(other, DogAllOf):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,16 +60,18 @@ class EnumArrays(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
('just_symbol',): {
|
||||
'>=': ">=",
|
||||
'$': "$"
|
||||
'$': "$",
|
||||
},
|
||||
('array_enum',): {
|
||||
'FISH': "fish",
|
||||
'CRAB': "crab"
|
||||
'CRAB': "crab",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -65,110 +81,149 @@ class EnumArrays(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'just_symbol': 'str',
|
||||
'array_enum': 'list[str]'
|
||||
'just_symbol': (str,), # noqa: E501
|
||||
'array_enum': ([str],), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, just_symbol=None, array_enum=None): # noqa: E501
|
||||
"""EnumArrays - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._just_symbol = None
|
||||
self._array_enum = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if just_symbol is not None:
|
||||
self.just_symbol = (
|
||||
just_symbol
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""EnumArrays - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
just_symbol (str): [optional] # noqa: E501
|
||||
array_enum ([str]): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if array_enum is not None:
|
||||
self.array_enum = (
|
||||
array_enum
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def just_symbol(self):
|
||||
"""Gets the just_symbol of this EnumArrays. # noqa: E501
|
||||
|
||||
|
||||
:return: The just_symbol of this EnumArrays. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The just_symbol of this EnumArrays. # noqa: E501
|
||||
"""
|
||||
return self._just_symbol
|
||||
return self.__get_item('just_symbol')
|
||||
|
||||
@just_symbol.setter
|
||||
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
|
||||
def just_symbol(self, value):
|
||||
"""Sets the just_symbol of this EnumArrays. # noqa: E501
|
||||
"""
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
('just_symbol',),
|
||||
just_symbol,
|
||||
self.validations
|
||||
)
|
||||
|
||||
self._just_symbol = (
|
||||
just_symbol
|
||||
)
|
||||
return self.__set_item('just_symbol', value)
|
||||
|
||||
@property
|
||||
def array_enum(self):
|
||||
"""Gets the array_enum of this EnumArrays. # noqa: E501
|
||||
|
||||
|
||||
:return: The array_enum of this EnumArrays. # noqa: E501
|
||||
:rtype: list[str]
|
||||
Returns:
|
||||
([str]): The array_enum of this EnumArrays. # noqa: E501
|
||||
"""
|
||||
return self._array_enum
|
||||
return self.__get_item('array_enum')
|
||||
|
||||
@array_enum.setter
|
||||
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]
|
||||
def array_enum(self, value):
|
||||
"""Sets the array_enum of this EnumArrays. # noqa: E501
|
||||
"""
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
('array_enum',),
|
||||
array_enum,
|
||||
self.validations
|
||||
)
|
||||
|
||||
self._array_enum = (
|
||||
array_enum
|
||||
)
|
||||
return self.__set_item('array_enum', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -183,7 +238,22 @@ class EnumArrays(ModelNormal):
|
||||
if not isinstance(other, EnumArrays):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -42,65 +56,147 @@ class EnumClass(ModelSimple):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
('value',): {
|
||||
'_ABC': "_abc",
|
||||
'-EFG': "-efg",
|
||||
'(XYZ)': "(xyz)"
|
||||
'(XYZ)': "(xyz)",
|
||||
},
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'value': 'str'
|
||||
'value': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, value='-efg'): # noqa: E501
|
||||
"""EnumClass - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._value = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
self.value = value
|
||||
def __init__(self, value='-efg', _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""EnumClass - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
|
||||
Keyword Args:
|
||||
value (str): defaults to '-efg', must be one of ['-efg'] # noqa: E501
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('value', value)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
"""Gets the value of this EnumClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The value of this EnumClass. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The value of this EnumClass. # noqa: E501
|
||||
"""
|
||||
return self._value
|
||||
return self.__get_item('value')
|
||||
|
||||
@value.setter
|
||||
def value(self, value): # noqa: E501
|
||||
"""Sets the value of this EnumClass.
|
||||
|
||||
|
||||
:param value: The value of this EnumClass. # noqa: E501
|
||||
:type: str
|
||||
def value(self, value):
|
||||
"""Sets the value of this EnumClass. # noqa: E501
|
||||
"""
|
||||
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
|
||||
)
|
||||
return self.__set_item('value', value)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return str(self._value)
|
||||
return str(self.value)
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
@@ -111,7 +207,19 @@ class EnumClass(ModelSimple):
|
||||
if not isinstance(other, EnumClass):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
this_val = self._data_store['value']
|
||||
that_val = other._data_store['value']
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,13 +15,28 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.outer_enum import OuterEnum
|
||||
|
||||
|
||||
class EnumTest(ModelNormal):
|
||||
@@ -46,26 +61,28 @@ class EnumTest(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
('enum_string',): {
|
||||
'UPPER': "UPPER",
|
||||
'LOWER': "lower",
|
||||
'EMPTY': ""
|
||||
'EMPTY': "",
|
||||
},
|
||||
('enum_string_required',): {
|
||||
'UPPER': "UPPER",
|
||||
'LOWER': "lower",
|
||||
'EMPTY': ""
|
||||
'EMPTY': "",
|
||||
},
|
||||
('enum_integer',): {
|
||||
'1': 1,
|
||||
'-1': -1
|
||||
'-1': -1,
|
||||
},
|
||||
('enum_number',): {
|
||||
'1.1': 1.1,
|
||||
'-1.2': -1.2
|
||||
'-1.2': -1.2,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -78,208 +95,202 @@ class EnumTest(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'enum_string': 'str',
|
||||
'enum_string_required': 'str',
|
||||
'enum_integer': 'int',
|
||||
'enum_number': 'float',
|
||||
'outer_enum': 'OuterEnum'
|
||||
'enum_string': (str,), # noqa: E501
|
||||
'enum_string_required': (str,), # noqa: E501
|
||||
'enum_integer': (int,), # noqa: E501
|
||||
'enum_number': (float,), # noqa: E501
|
||||
'outer_enum': (OuterEnum,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._enum_string = None
|
||||
self._enum_string_required = None
|
||||
self._enum_integer = None
|
||||
self._enum_number = None
|
||||
self._outer_enum = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if enum_string is not None:
|
||||
self.enum_string = (
|
||||
enum_string
|
||||
def __init__(self, enum_string_required, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""EnumTest - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
enum_string_required (str):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
enum_string (str): [optional] # noqa: E501
|
||||
enum_integer (int): [optional] # noqa: E501
|
||||
enum_number (float): [optional] # noqa: E501
|
||||
outer_enum (OuterEnum): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('enum_string_required', enum_string_required)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
self.enum_string_required = enum_string_required
|
||||
if enum_integer is not None:
|
||||
self.enum_integer = (
|
||||
enum_integer
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if enum_number is not None:
|
||||
self.enum_number = (
|
||||
enum_number
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if outer_enum is not None:
|
||||
self.outer_enum = (
|
||||
outer_enum
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def enum_string(self):
|
||||
"""Gets the enum_string of this EnumTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The enum_string of this EnumTest. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The enum_string of this EnumTest. # noqa: E501
|
||||
"""
|
||||
return self._enum_string
|
||||
return self.__get_item('enum_string')
|
||||
|
||||
@enum_string.setter
|
||||
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
|
||||
def enum_string(self, value):
|
||||
"""Sets the enum_string of this EnumTest. # noqa: E501
|
||||
"""
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
('enum_string',),
|
||||
enum_string,
|
||||
self.validations
|
||||
)
|
||||
|
||||
self._enum_string = (
|
||||
enum_string
|
||||
)
|
||||
return self.__set_item('enum_string', value)
|
||||
|
||||
@property
|
||||
def enum_string_required(self):
|
||||
"""Gets the enum_string_required of this EnumTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The enum_string_required of this EnumTest. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The enum_string_required of this EnumTest. # noqa: E501
|
||||
"""
|
||||
return self._enum_string_required
|
||||
return self.__get_item('enum_string_required')
|
||||
|
||||
@enum_string_required.setter
|
||||
def enum_string_required(self, enum_string_required): # noqa: E501
|
||||
"""Sets the enum_string_required of this EnumTest.
|
||||
|
||||
|
||||
:param enum_string_required: The enum_string_required of this EnumTest. # noqa: E501
|
||||
:type: str
|
||||
def enum_string_required(self, value):
|
||||
"""Sets the enum_string_required of this EnumTest. # noqa: E501
|
||||
"""
|
||||
if enum_string_required is None:
|
||||
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
|
||||
)
|
||||
return self.__set_item('enum_string_required', value)
|
||||
|
||||
@property
|
||||
def enum_integer(self):
|
||||
"""Gets the enum_integer of this EnumTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The enum_integer of this EnumTest. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The enum_integer of this EnumTest. # noqa: E501
|
||||
"""
|
||||
return self._enum_integer
|
||||
return self.__get_item('enum_integer')
|
||||
|
||||
@enum_integer.setter
|
||||
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
|
||||
def enum_integer(self, value):
|
||||
"""Sets the enum_integer of this EnumTest. # noqa: E501
|
||||
"""
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
('enum_integer',),
|
||||
enum_integer,
|
||||
self.validations
|
||||
)
|
||||
|
||||
self._enum_integer = (
|
||||
enum_integer
|
||||
)
|
||||
return self.__set_item('enum_integer', value)
|
||||
|
||||
@property
|
||||
def enum_number(self):
|
||||
"""Gets the enum_number of this EnumTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The enum_number of this EnumTest. # noqa: E501
|
||||
:rtype: float
|
||||
Returns:
|
||||
(float): The enum_number of this EnumTest. # noqa: E501
|
||||
"""
|
||||
return self._enum_number
|
||||
return self.__get_item('enum_number')
|
||||
|
||||
@enum_number.setter
|
||||
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
|
||||
def enum_number(self, value):
|
||||
"""Sets the enum_number of this EnumTest. # noqa: E501
|
||||
"""
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
('enum_number',),
|
||||
enum_number,
|
||||
self.validations
|
||||
)
|
||||
|
||||
self._enum_number = (
|
||||
enum_number
|
||||
)
|
||||
return self.__set_item('enum_number', value)
|
||||
|
||||
@property
|
||||
def outer_enum(self):
|
||||
"""Gets the outer_enum of this EnumTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The outer_enum of this EnumTest. # noqa: E501
|
||||
:rtype: OuterEnum
|
||||
Returns:
|
||||
(OuterEnum): The outer_enum of this EnumTest. # noqa: E501
|
||||
"""
|
||||
return self._outer_enum
|
||||
return self.__get_item('outer_enum')
|
||||
|
||||
@outer_enum.setter
|
||||
def outer_enum(self, outer_enum): # noqa: E501
|
||||
"""Sets the outer_enum of this EnumTest.
|
||||
|
||||
|
||||
:param outer_enum: The outer_enum of this EnumTest. # noqa: E501
|
||||
:type: OuterEnum
|
||||
def outer_enum(self, value):
|
||||
"""Sets the outer_enum of this EnumTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._outer_enum = (
|
||||
outer_enum
|
||||
)
|
||||
return self.__set_item('outer_enum', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -294,7 +305,22 @@ class EnumTest(ModelNormal):
|
||||
if not isinstance(other, EnumTest):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class File(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,71 +72,134 @@ class File(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'source_uri': 'str'
|
||||
'source_uri': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, source_uri=None): # noqa: E501
|
||||
"""File - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._source_uri = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if source_uri is not None:
|
||||
self.source_uri = (
|
||||
source_uri
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""File - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
source_uri (str): Test capitalization. [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def source_uri(self):
|
||||
"""Gets the source_uri of this File. # noqa: E501
|
||||
|
||||
Test capitalization # noqa: E501
|
||||
|
||||
:return: The source_uri of this File. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The source_uri of this File. # noqa: E501
|
||||
"""
|
||||
return self._source_uri
|
||||
return self.__get_item('source_uri')
|
||||
|
||||
@source_uri.setter
|
||||
def source_uri(self, source_uri): # noqa: E501
|
||||
"""Sets the source_uri of this File.
|
||||
|
||||
def source_uri(self, value):
|
||||
"""Sets the source_uri of this File. # noqa: E501
|
||||
Test capitalization # noqa: E501
|
||||
|
||||
:param source_uri: The source_uri of this File. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
|
||||
self._source_uri = (
|
||||
source_uri
|
||||
)
|
||||
return self.__set_item('source_uri', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -135,7 +214,22 @@ class File(ModelNormal):
|
||||
if not isinstance(other, File):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,13 +15,28 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.file import File
|
||||
|
||||
|
||||
class FileSchemaTestClass(ModelNormal):
|
||||
@@ -46,6 +61,8 @@ class FileSchemaTestClass(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -57,98 +74,149 @@ class FileSchemaTestClass(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'file': 'File',
|
||||
'files': 'list[File]'
|
||||
'file': (File,), # noqa: E501
|
||||
'files': ([File],), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, file=None, files=None): # noqa: E501
|
||||
"""FileSchemaTestClass - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._file = None
|
||||
self._files = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if file is not None:
|
||||
self.file = (
|
||||
file
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""FileSchemaTestClass - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
file (File): [optional] # noqa: E501
|
||||
files ([File]): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if files is not None:
|
||||
self.files = (
|
||||
files
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def file(self):
|
||||
"""Gets the file of this FileSchemaTestClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The file of this FileSchemaTestClass. # noqa: E501
|
||||
:rtype: File
|
||||
Returns:
|
||||
(File): The file of this FileSchemaTestClass. # noqa: E501
|
||||
"""
|
||||
return self._file
|
||||
return self.__get_item('file')
|
||||
|
||||
@file.setter
|
||||
def file(self, file): # noqa: E501
|
||||
"""Sets the file of this FileSchemaTestClass.
|
||||
|
||||
|
||||
:param file: The file of this FileSchemaTestClass. # noqa: E501
|
||||
:type: File
|
||||
def file(self, value):
|
||||
"""Sets the file of this FileSchemaTestClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._file = (
|
||||
file
|
||||
)
|
||||
return self.__set_item('file', value)
|
||||
|
||||
@property
|
||||
def files(self):
|
||||
"""Gets the files of this FileSchemaTestClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The files of this FileSchemaTestClass. # noqa: E501
|
||||
:rtype: list[File]
|
||||
Returns:
|
||||
([File]): The files of this FileSchemaTestClass. # noqa: E501
|
||||
"""
|
||||
return self._files
|
||||
return self.__get_item('files')
|
||||
|
||||
@files.setter
|
||||
def files(self, files): # noqa: E501
|
||||
"""Sets the files of this FileSchemaTestClass.
|
||||
|
||||
|
||||
:param files: The files of this FileSchemaTestClass. # noqa: E501
|
||||
:type: list[File]
|
||||
def files(self, value):
|
||||
"""Sets the files of this FileSchemaTestClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._files = (
|
||||
files
|
||||
)
|
||||
return self.__set_item('files', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -163,7 +231,22 @@ class FileSchemaTestClass(ModelNormal):
|
||||
if not isinstance(other, FileSchemaTestClass):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class FormatTest(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -68,56 +84,49 @@ class FormatTest(ModelNormal):
|
||||
}
|
||||
|
||||
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'
|
||||
'integer': (int,), # noqa: E501
|
||||
'int32': (int,), # noqa: E501
|
||||
'int64': (int,), # noqa: E501
|
||||
'number': (float,), # noqa: E501
|
||||
'float': (float,), # noqa: E501
|
||||
'double': (float,), # noqa: E501
|
||||
'string': (str,), # noqa: E501
|
||||
'byte': (str,), # noqa: E501
|
||||
'binary': (file_type,), # noqa: E501
|
||||
'date': (date,), # noqa: E501
|
||||
'date_time': (datetime,), # noqa: E501
|
||||
'uuid': (str,), # noqa: E501
|
||||
'password': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
('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
|
||||
},
|
||||
@@ -128,435 +137,323 @@ class FormatTest(ModelNormal):
|
||||
},
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._integer = None
|
||||
self._int32 = None
|
||||
self._int64 = None
|
||||
self._number = None
|
||||
self._float = None
|
||||
self._double = None
|
||||
self._string = None
|
||||
self._byte = None
|
||||
self._binary = None
|
||||
self._date = None
|
||||
self._date_time = None
|
||||
self._uuid = None
|
||||
self._password = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if integer is not None:
|
||||
self.integer = (
|
||||
integer
|
||||
def __init__(self, number, byte, date, password, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""FormatTest - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
number (float):
|
||||
byte (str):
|
||||
date (date):
|
||||
password (str):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
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_type): [optional] # noqa: E501
|
||||
date_time (datetime): [optional] # noqa: E501
|
||||
uuid (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('number', number)
|
||||
self.__set_item('byte', byte)
|
||||
self.__set_item('date', date)
|
||||
self.__set_item('password', password)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if int32 is not None:
|
||||
self.int32 = (
|
||||
int32
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if int64 is not None:
|
||||
self.int64 = (
|
||||
int64
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
self.number = number
|
||||
if float is not None:
|
||||
self.float = (
|
||||
float
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if double is not None:
|
||||
self.double = (
|
||||
double
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if string is not None:
|
||||
self.string = (
|
||||
string
|
||||
)
|
||||
self.byte = byte
|
||||
if binary is not None:
|
||||
self.binary = (
|
||||
binary
|
||||
)
|
||||
self.date = date
|
||||
if date_time is not None:
|
||||
self.date_time = (
|
||||
date_time
|
||||
)
|
||||
if uuid is not None:
|
||||
self.uuid = (
|
||||
uuid
|
||||
)
|
||||
self.password = password
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def integer(self):
|
||||
"""Gets the integer of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The integer of this FormatTest. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The integer of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._integer
|
||||
return self.__get_item('integer')
|
||||
|
||||
@integer.setter
|
||||
def integer(self, integer): # noqa: E501
|
||||
"""Sets the integer of this FormatTest.
|
||||
|
||||
|
||||
:param integer: The integer of this FormatTest. # noqa: E501
|
||||
:type: int
|
||||
def integer(self, value):
|
||||
"""Sets the integer of this FormatTest. # noqa: E501
|
||||
"""
|
||||
check_validations(
|
||||
self.validations,
|
||||
('integer',),
|
||||
integer
|
||||
)
|
||||
|
||||
self._integer = (
|
||||
integer
|
||||
)
|
||||
return self.__set_item('integer', value)
|
||||
|
||||
@property
|
||||
def int32(self):
|
||||
"""Gets the int32 of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The int32 of this FormatTest. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The int32 of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._int32
|
||||
return self.__get_item('int32')
|
||||
|
||||
@int32.setter
|
||||
def int32(self, int32): # noqa: E501
|
||||
"""Sets the int32 of this FormatTest.
|
||||
|
||||
|
||||
:param int32: The int32 of this FormatTest. # noqa: E501
|
||||
:type: int
|
||||
def int32(self, value):
|
||||
"""Sets the int32 of this FormatTest. # noqa: E501
|
||||
"""
|
||||
check_validations(
|
||||
self.validations,
|
||||
('int32',),
|
||||
int32
|
||||
)
|
||||
|
||||
self._int32 = (
|
||||
int32
|
||||
)
|
||||
return self.__set_item('int32', value)
|
||||
|
||||
@property
|
||||
def int64(self):
|
||||
"""Gets the int64 of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The int64 of this FormatTest. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The int64 of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._int64
|
||||
return self.__get_item('int64')
|
||||
|
||||
@int64.setter
|
||||
def int64(self, int64): # noqa: E501
|
||||
"""Sets the int64 of this FormatTest.
|
||||
|
||||
|
||||
:param int64: The int64 of this FormatTest. # noqa: E501
|
||||
:type: int
|
||||
def int64(self, value):
|
||||
"""Sets the int64 of this FormatTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._int64 = (
|
||||
int64
|
||||
)
|
||||
return self.__set_item('int64', value)
|
||||
|
||||
@property
|
||||
def number(self):
|
||||
"""Gets the number of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The number of this FormatTest. # noqa: E501
|
||||
:rtype: float
|
||||
Returns:
|
||||
(float): The number of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._number
|
||||
return self.__get_item('number')
|
||||
|
||||
@number.setter
|
||||
def number(self, number): # noqa: E501
|
||||
"""Sets the number of this FormatTest.
|
||||
|
||||
|
||||
:param number: The number of this FormatTest. # noqa: E501
|
||||
:type: float
|
||||
def number(self, value):
|
||||
"""Sets the number of this FormatTest. # noqa: E501
|
||||
"""
|
||||
if number is None:
|
||||
raise ApiValueError("Invalid value for `number`, must not be `None`") # noqa: E501
|
||||
check_validations(
|
||||
self.validations,
|
||||
('number',),
|
||||
number
|
||||
)
|
||||
|
||||
self._number = (
|
||||
number
|
||||
)
|
||||
return self.__set_item('number', value)
|
||||
|
||||
@property
|
||||
def float(self):
|
||||
"""Gets the float of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The float of this FormatTest. # noqa: E501
|
||||
:rtype: float
|
||||
Returns:
|
||||
(float): The float of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._float
|
||||
return self.__get_item('float')
|
||||
|
||||
@float.setter
|
||||
def float(self, float): # noqa: E501
|
||||
"""Sets the float of this FormatTest.
|
||||
|
||||
|
||||
:param float: The float of this FormatTest. # noqa: E501
|
||||
:type: float
|
||||
def float(self, value):
|
||||
"""Sets the float of this FormatTest. # noqa: E501
|
||||
"""
|
||||
check_validations(
|
||||
self.validations,
|
||||
('float',),
|
||||
float
|
||||
)
|
||||
|
||||
self._float = (
|
||||
float
|
||||
)
|
||||
return self.__set_item('float', value)
|
||||
|
||||
@property
|
||||
def double(self):
|
||||
"""Gets the double of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The double of this FormatTest. # noqa: E501
|
||||
:rtype: float
|
||||
Returns:
|
||||
(float): The double of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._double
|
||||
return self.__get_item('double')
|
||||
|
||||
@double.setter
|
||||
def double(self, double): # noqa: E501
|
||||
"""Sets the double of this FormatTest.
|
||||
|
||||
|
||||
:param double: The double of this FormatTest. # noqa: E501
|
||||
:type: float
|
||||
def double(self, value):
|
||||
"""Sets the double of this FormatTest. # noqa: E501
|
||||
"""
|
||||
check_validations(
|
||||
self.validations,
|
||||
('double',),
|
||||
double
|
||||
)
|
||||
|
||||
self._double = (
|
||||
double
|
||||
)
|
||||
return self.__set_item('double', value)
|
||||
|
||||
@property
|
||||
def string(self):
|
||||
"""Gets the string of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The string of this FormatTest. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The string of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._string
|
||||
return self.__get_item('string')
|
||||
|
||||
@string.setter
|
||||
def string(self, string): # noqa: E501
|
||||
"""Sets the string of this FormatTest.
|
||||
|
||||
|
||||
:param string: The string of this FormatTest. # noqa: E501
|
||||
:type: str
|
||||
def string(self, value):
|
||||
"""Sets the string of this FormatTest. # noqa: E501
|
||||
"""
|
||||
check_validations(
|
||||
self.validations,
|
||||
('string',),
|
||||
string
|
||||
)
|
||||
|
||||
self._string = (
|
||||
string
|
||||
)
|
||||
return self.__set_item('string', value)
|
||||
|
||||
@property
|
||||
def byte(self):
|
||||
"""Gets the byte of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The byte of this FormatTest. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The byte of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._byte
|
||||
return self.__get_item('byte')
|
||||
|
||||
@byte.setter
|
||||
def byte(self, byte): # noqa: E501
|
||||
"""Sets the byte of this FormatTest.
|
||||
|
||||
|
||||
:param byte: The byte of this FormatTest. # noqa: E501
|
||||
:type: str
|
||||
def byte(self, value):
|
||||
"""Sets the byte of this FormatTest. # noqa: E501
|
||||
"""
|
||||
if byte is None:
|
||||
raise ApiValueError("Invalid value for `byte`, must not be `None`") # noqa: E501
|
||||
check_validations(
|
||||
self.validations,
|
||||
('byte',),
|
||||
byte
|
||||
)
|
||||
|
||||
self._byte = (
|
||||
byte
|
||||
)
|
||||
return self.__set_item('byte', value)
|
||||
|
||||
@property
|
||||
def binary(self):
|
||||
"""Gets the binary of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The binary of this FormatTest. # noqa: E501
|
||||
:rtype: file
|
||||
Returns:
|
||||
(file_type): The binary of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._binary
|
||||
return self.__get_item('binary')
|
||||
|
||||
@binary.setter
|
||||
def binary(self, binary): # noqa: E501
|
||||
"""Sets the binary of this FormatTest.
|
||||
|
||||
|
||||
:param binary: The binary of this FormatTest. # noqa: E501
|
||||
:type: file
|
||||
def binary(self, value):
|
||||
"""Sets the binary of this FormatTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._binary = (
|
||||
binary
|
||||
)
|
||||
return self.__set_item('binary', value)
|
||||
|
||||
@property
|
||||
def date(self):
|
||||
"""Gets the date of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The date of this FormatTest. # noqa: E501
|
||||
:rtype: date
|
||||
Returns:
|
||||
(date): The date of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._date
|
||||
return self.__get_item('date')
|
||||
|
||||
@date.setter
|
||||
def date(self, date): # noqa: E501
|
||||
"""Sets the date of this FormatTest.
|
||||
|
||||
|
||||
:param date: The date of this FormatTest. # noqa: E501
|
||||
:type: date
|
||||
def date(self, value):
|
||||
"""Sets the date of this FormatTest. # noqa: E501
|
||||
"""
|
||||
if date is None:
|
||||
raise ApiValueError("Invalid value for `date`, must not be `None`") # noqa: E501
|
||||
|
||||
self._date = (
|
||||
date
|
||||
)
|
||||
return self.__set_item('date', value)
|
||||
|
||||
@property
|
||||
def date_time(self):
|
||||
"""Gets the date_time of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The date_time of this FormatTest. # noqa: E501
|
||||
:rtype: datetime
|
||||
Returns:
|
||||
(datetime): The date_time of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._date_time
|
||||
return self.__get_item('date_time')
|
||||
|
||||
@date_time.setter
|
||||
def date_time(self, date_time): # noqa: E501
|
||||
"""Sets the date_time of this FormatTest.
|
||||
|
||||
|
||||
:param date_time: The date_time of this FormatTest. # noqa: E501
|
||||
:type: datetime
|
||||
def date_time(self, value):
|
||||
"""Sets the date_time of this FormatTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._date_time = (
|
||||
date_time
|
||||
)
|
||||
return self.__set_item('date_time', value)
|
||||
|
||||
@property
|
||||
def uuid(self):
|
||||
"""Gets the uuid of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The uuid of this FormatTest. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The uuid of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._uuid
|
||||
return self.__get_item('uuid')
|
||||
|
||||
@uuid.setter
|
||||
def uuid(self, uuid): # noqa: E501
|
||||
"""Sets the uuid of this FormatTest.
|
||||
|
||||
|
||||
:param uuid: The uuid of this FormatTest. # noqa: E501
|
||||
:type: str
|
||||
def uuid(self, value):
|
||||
"""Sets the uuid of this FormatTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._uuid = (
|
||||
uuid
|
||||
)
|
||||
return self.__set_item('uuid', value)
|
||||
|
||||
@property
|
||||
def password(self):
|
||||
"""Gets the password of this FormatTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The password of this FormatTest. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The password of this FormatTest. # noqa: E501
|
||||
"""
|
||||
return self._password
|
||||
return self.__get_item('password')
|
||||
|
||||
@password.setter
|
||||
def password(self, password): # noqa: E501
|
||||
"""Sets the password of this FormatTest.
|
||||
|
||||
|
||||
:param password: The password of this FormatTest. # noqa: E501
|
||||
:type: str
|
||||
def password(self, value):
|
||||
"""Sets the password of this FormatTest. # noqa: E501
|
||||
"""
|
||||
if password is None:
|
||||
raise ApiValueError("Invalid value for `password`, must not be `None`") # noqa: E501
|
||||
check_validations(
|
||||
self.validations,
|
||||
('password',),
|
||||
password
|
||||
)
|
||||
|
||||
self._password = (
|
||||
password
|
||||
)
|
||||
return self.__set_item('password', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -571,7 +468,22 @@ class FormatTest(ModelNormal):
|
||||
if not isinstance(other, FormatTest):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class HasOnlyReadOnly(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -57,98 +73,149 @@ class HasOnlyReadOnly(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'bar': 'str',
|
||||
'foo': 'str'
|
||||
'bar': (str,), # noqa: E501
|
||||
'foo': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, bar=None, foo=None): # noqa: E501
|
||||
"""HasOnlyReadOnly - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._bar = None
|
||||
self._foo = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if bar is not None:
|
||||
self.bar = (
|
||||
bar
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""HasOnlyReadOnly - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
bar (str): [optional] # noqa: E501
|
||||
foo (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if foo is not None:
|
||||
self.foo = (
|
||||
foo
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def bar(self):
|
||||
"""Gets the bar of this HasOnlyReadOnly. # noqa: E501
|
||||
|
||||
|
||||
:return: The bar of this HasOnlyReadOnly. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The bar of this HasOnlyReadOnly. # noqa: E501
|
||||
"""
|
||||
return self._bar
|
||||
return self.__get_item('bar')
|
||||
|
||||
@bar.setter
|
||||
def bar(self, bar): # noqa: E501
|
||||
"""Sets the bar of this HasOnlyReadOnly.
|
||||
|
||||
|
||||
:param bar: The bar of this HasOnlyReadOnly. # noqa: E501
|
||||
:type: str
|
||||
def bar(self, value):
|
||||
"""Sets the bar of this HasOnlyReadOnly. # noqa: E501
|
||||
"""
|
||||
|
||||
self._bar = (
|
||||
bar
|
||||
)
|
||||
return self.__set_item('bar', value)
|
||||
|
||||
@property
|
||||
def foo(self):
|
||||
"""Gets the foo of this HasOnlyReadOnly. # noqa: E501
|
||||
|
||||
|
||||
:return: The foo of this HasOnlyReadOnly. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The foo of this HasOnlyReadOnly. # noqa: E501
|
||||
"""
|
||||
return self._foo
|
||||
return self.__get_item('foo')
|
||||
|
||||
@foo.setter
|
||||
def foo(self, foo): # noqa: E501
|
||||
"""Sets the foo of this HasOnlyReadOnly.
|
||||
|
||||
|
||||
:param foo: The foo of this HasOnlyReadOnly. # noqa: E501
|
||||
:type: str
|
||||
def foo(self, value):
|
||||
"""Sets the foo of this HasOnlyReadOnly. # noqa: E501
|
||||
"""
|
||||
|
||||
self._foo = (
|
||||
foo
|
||||
)
|
||||
return self.__set_item('foo', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -163,7 +230,22 @@ class HasOnlyReadOnly(ModelNormal):
|
||||
if not isinstance(other, HasOnlyReadOnly):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class List(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class List(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'_123_list': 'str'
|
||||
'_123_list': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, _123_list=None): # noqa: E501
|
||||
"""List - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self.__123_list = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if _123_list is not None:
|
||||
self._123_list = (
|
||||
_123_list
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""List - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
_123_list (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def _123_list(self):
|
||||
"""Gets the _123_list of this List. # noqa: E501
|
||||
|
||||
|
||||
:return: The _123_list of this List. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The _123_list of this List. # noqa: E501
|
||||
"""
|
||||
return self.__123_list
|
||||
return self.__get_item('_123_list')
|
||||
|
||||
@_123_list.setter
|
||||
def _123_list(self, _123_list): # noqa: E501
|
||||
"""Sets the _123_list of this List.
|
||||
|
||||
|
||||
:param _123_list: The _123_list of this List. # noqa: E501
|
||||
:type: str
|
||||
def _123_list(self, value):
|
||||
"""Sets the _123_list of this List. # noqa: E501
|
||||
"""
|
||||
|
||||
self.__123_list = (
|
||||
_123_list
|
||||
)
|
||||
return self.__set_item('_123_list', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class List(ModelNormal):
|
||||
if not isinstance(other, List):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,13 +15,28 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.string_boolean_map import StringBooleanMap
|
||||
|
||||
|
||||
class MapTest(ModelNormal):
|
||||
@@ -46,12 +61,14 @@ class MapTest(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
('map_of_enum_string',): {
|
||||
'UPPER': "UPPER",
|
||||
'LOWER': "lower"
|
||||
'LOWER': "lower",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -63,162 +80,183 @@ class MapTest(ModelNormal):
|
||||
}
|
||||
|
||||
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'
|
||||
'map_map_of_string': ({str: ({str: (str,)},)},), # noqa: E501
|
||||
'map_of_enum_string': ({str: (str,)},), # noqa: E501
|
||||
'direct_map': ({str: (bool,)},), # noqa: E501
|
||||
'indirect_map': (StringBooleanMap,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._map_map_of_string = None
|
||||
self._map_of_enum_string = None
|
||||
self._direct_map = None
|
||||
self._indirect_map = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if map_map_of_string is not None:
|
||||
self.map_map_of_string = (
|
||||
map_map_of_string
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""MapTest - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
map_map_of_string ({str: ({str: (str,)},)}): [optional] # noqa: E501
|
||||
map_of_enum_string ({str: (str,)}): [optional] # noqa: E501
|
||||
direct_map ({str: (bool,)}): [optional] # noqa: E501
|
||||
indirect_map (StringBooleanMap): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if map_of_enum_string is not None:
|
||||
self.map_of_enum_string = (
|
||||
map_of_enum_string
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if direct_map is not None:
|
||||
self.direct_map = (
|
||||
direct_map
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if indirect_map is not None:
|
||||
self.indirect_map = (
|
||||
indirect_map
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def map_map_of_string(self):
|
||||
"""Gets the map_map_of_string of this MapTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_map_of_string of this MapTest. # noqa: E501
|
||||
:rtype: dict(str, dict(str, str))
|
||||
Returns:
|
||||
({str: ({str: (str,)},)}): The map_map_of_string of this MapTest. # noqa: E501
|
||||
"""
|
||||
return self._map_map_of_string
|
||||
return self.__get_item('map_map_of_string')
|
||||
|
||||
@map_map_of_string.setter
|
||||
def map_map_of_string(self, map_map_of_string): # noqa: E501
|
||||
"""Sets the map_map_of_string of this MapTest.
|
||||
|
||||
|
||||
:param map_map_of_string: The map_map_of_string of this MapTest. # noqa: E501
|
||||
:type: dict(str, dict(str, str))
|
||||
def map_map_of_string(self, value):
|
||||
"""Sets the map_map_of_string of this MapTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map_map_of_string = (
|
||||
map_map_of_string
|
||||
)
|
||||
return self.__set_item('map_map_of_string', value)
|
||||
|
||||
@property
|
||||
def map_of_enum_string(self):
|
||||
"""Gets the map_of_enum_string of this MapTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The map_of_enum_string of this MapTest. # noqa: E501
|
||||
:rtype: dict(str, str)
|
||||
Returns:
|
||||
({str: (str,)}): The map_of_enum_string of this MapTest. # noqa: E501
|
||||
"""
|
||||
return self._map_of_enum_string
|
||||
return self.__get_item('map_of_enum_string')
|
||||
|
||||
@map_of_enum_string.setter
|
||||
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)
|
||||
def map_of_enum_string(self, value):
|
||||
"""Sets the map_of_enum_string of this MapTest. # noqa: E501
|
||||
"""
|
||||
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
|
||||
)
|
||||
return self.__set_item('map_of_enum_string', value)
|
||||
|
||||
@property
|
||||
def direct_map(self):
|
||||
"""Gets the direct_map of this MapTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The direct_map of this MapTest. # noqa: E501
|
||||
:rtype: dict(str, bool)
|
||||
Returns:
|
||||
({str: (bool,)}): The direct_map of this MapTest. # noqa: E501
|
||||
"""
|
||||
return self._direct_map
|
||||
return self.__get_item('direct_map')
|
||||
|
||||
@direct_map.setter
|
||||
def direct_map(self, direct_map): # noqa: E501
|
||||
"""Sets the direct_map of this MapTest.
|
||||
|
||||
|
||||
:param direct_map: The direct_map of this MapTest. # noqa: E501
|
||||
:type: dict(str, bool)
|
||||
def direct_map(self, value):
|
||||
"""Sets the direct_map of this MapTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._direct_map = (
|
||||
direct_map
|
||||
)
|
||||
return self.__set_item('direct_map', value)
|
||||
|
||||
@property
|
||||
def indirect_map(self):
|
||||
"""Gets the indirect_map of this MapTest. # noqa: E501
|
||||
|
||||
|
||||
:return: The indirect_map of this MapTest. # noqa: E501
|
||||
:rtype: StringBooleanMap
|
||||
Returns:
|
||||
(StringBooleanMap): The indirect_map of this MapTest. # noqa: E501
|
||||
"""
|
||||
return self._indirect_map
|
||||
return self.__get_item('indirect_map')
|
||||
|
||||
@indirect_map.setter
|
||||
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: StringBooleanMap
|
||||
def indirect_map(self, value):
|
||||
"""Sets the indirect_map of this MapTest. # noqa: E501
|
||||
"""
|
||||
|
||||
self._indirect_map = (
|
||||
indirect_map
|
||||
)
|
||||
return self.__set_item('indirect_map', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -233,7 +271,22 @@ class MapTest(ModelNormal):
|
||||
if not isinstance(other, MapTest):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,13 +15,28 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.animal import Animal
|
||||
|
||||
|
||||
class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal):
|
||||
@@ -46,6 +61,8 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -58,127 +75,166 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'uuid': 'str',
|
||||
'date_time': 'datetime',
|
||||
'map': 'dict(str, Animal)'
|
||||
'uuid': (str,), # noqa: E501
|
||||
'date_time': (datetime,), # noqa: E501
|
||||
'map': ({str: (Animal,)},), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, uuid=None, date_time=None, map=None): # noqa: E501
|
||||
"""MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._uuid = None
|
||||
self._date_time = None
|
||||
self._map = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if uuid is not None:
|
||||
self.uuid = (
|
||||
uuid
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""MixedPropertiesAndAdditionalPropertiesClass - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
uuid (str): [optional] # noqa: E501
|
||||
date_time (datetime): [optional] # noqa: E501
|
||||
map ({str: (Animal,)}): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if date_time is not None:
|
||||
self.date_time = (
|
||||
date_time
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if map is not None:
|
||||
self.map = (
|
||||
map
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def uuid(self):
|
||||
"""Gets the uuid of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The uuid of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The uuid of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._uuid
|
||||
return self.__get_item('uuid')
|
||||
|
||||
@uuid.setter
|
||||
def uuid(self, uuid): # noqa: E501
|
||||
"""Sets the uuid of this MixedPropertiesAndAdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param uuid: The uuid of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
:type: str
|
||||
def uuid(self, value):
|
||||
"""Sets the uuid of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._uuid = (
|
||||
uuid
|
||||
)
|
||||
return self.__set_item('uuid', value)
|
||||
|
||||
@property
|
||||
def date_time(self):
|
||||
"""Gets the date_time of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The date_time of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: datetime
|
||||
Returns:
|
||||
(datetime): The date_time of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._date_time
|
||||
return self.__get_item('date_time')
|
||||
|
||||
@date_time.setter
|
||||
def date_time(self, date_time): # noqa: E501
|
||||
"""Sets the date_time of this MixedPropertiesAndAdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param date_time: The date_time of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
:type: datetime
|
||||
def date_time(self, value):
|
||||
"""Sets the date_time of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._date_time = (
|
||||
date_time
|
||||
)
|
||||
return self.__set_item('date_time', value)
|
||||
|
||||
@property
|
||||
def map(self):
|
||||
"""Gets the map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
|
||||
|
||||
:return: The map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
:rtype: dict(str, Animal)
|
||||
Returns:
|
||||
({str: (Animal,)}): The map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
return self._map
|
||||
return self.__get_item('map')
|
||||
|
||||
@map.setter
|
||||
def map(self, map): # noqa: E501
|
||||
"""Sets the map of this MixedPropertiesAndAdditionalPropertiesClass.
|
||||
|
||||
|
||||
:param map: The map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
:type: dict(str, Animal)
|
||||
def map(self, value):
|
||||
"""Sets the map of this MixedPropertiesAndAdditionalPropertiesClass. # noqa: E501
|
||||
"""
|
||||
|
||||
self._map = (
|
||||
map
|
||||
)
|
||||
return self.__set_item('map', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -193,7 +249,22 @@ class MixedPropertiesAndAdditionalPropertiesClass(ModelNormal):
|
||||
if not isinstance(other, MixedPropertiesAndAdditionalPropertiesClass):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class Model200Response(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -57,98 +73,149 @@ class Model200Response(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'int',
|
||||
'_class': 'str'
|
||||
'name': (int,), # noqa: E501
|
||||
'_class': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None, _class=None): # noqa: E501
|
||||
"""Model200Response - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._name = None
|
||||
self.__class = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Model200Response - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
name (int): [optional] # noqa: E501
|
||||
_class (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if _class is not None:
|
||||
self._class = (
|
||||
_class
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this Model200Response. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this Model200Response. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The name of this Model200Response. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this Model200Response.
|
||||
|
||||
|
||||
:param name: The name of this Model200Response. # noqa: E501
|
||||
:type: int
|
||||
def name(self, value):
|
||||
"""Sets the name of this Model200Response. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
@property
|
||||
def _class(self):
|
||||
"""Gets the _class of this Model200Response. # noqa: E501
|
||||
|
||||
|
||||
:return: The _class of this Model200Response. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The _class of this Model200Response. # noqa: E501
|
||||
"""
|
||||
return self.__class
|
||||
return self.__get_item('_class')
|
||||
|
||||
@_class.setter
|
||||
def _class(self, _class): # noqa: E501
|
||||
"""Sets the _class of this Model200Response.
|
||||
|
||||
|
||||
:param _class: The _class of this Model200Response. # noqa: E501
|
||||
:type: str
|
||||
def _class(self, value):
|
||||
"""Sets the _class of this Model200Response. # noqa: E501
|
||||
"""
|
||||
|
||||
self.__class = (
|
||||
_class
|
||||
)
|
||||
return self.__set_item('_class', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -163,7 +230,22 @@ class Model200Response(ModelNormal):
|
||||
if not isinstance(other, Model200Response):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class ModelReturn(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class ModelReturn(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'_return': 'int'
|
||||
'_return': (int,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, _return=None): # noqa: E501
|
||||
"""ModelReturn - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self.__return = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if _return is not None:
|
||||
self._return = (
|
||||
_return
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""ModelReturn - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
_return (int): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def _return(self):
|
||||
"""Gets the _return of this ModelReturn. # noqa: E501
|
||||
|
||||
|
||||
:return: The _return of this ModelReturn. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The _return of this ModelReturn. # noqa: E501
|
||||
"""
|
||||
return self.__return
|
||||
return self.__get_item('_return')
|
||||
|
||||
@_return.setter
|
||||
def _return(self, _return): # noqa: E501
|
||||
"""Sets the _return of this ModelReturn.
|
||||
|
||||
|
||||
:param _return: The _return of this ModelReturn. # noqa: E501
|
||||
:type: int
|
||||
def _return(self, value):
|
||||
"""Sets the _return of this ModelReturn. # noqa: E501
|
||||
"""
|
||||
|
||||
self.__return = (
|
||||
_return
|
||||
)
|
||||
return self.__set_item('_return', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class ModelReturn(ModelNormal):
|
||||
if not isinstance(other, ModelReturn):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class Name(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -59,155 +75,185 @@ class Name(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'name': 'int',
|
||||
'snake_case': 'int',
|
||||
'_property': 'str',
|
||||
'_123_number': 'int'
|
||||
'name': (int,), # noqa: E501
|
||||
'snake_case': (int,), # noqa: E501
|
||||
'_property': (str,), # noqa: E501
|
||||
'_123_number': (int,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, name=None, snake_case=None, _property=None, _123_number=None): # noqa: E501
|
||||
"""Name - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._name = None
|
||||
self._snake_case = None
|
||||
self.__property = None
|
||||
self.__123_number = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
self.name = name
|
||||
if snake_case is not None:
|
||||
self.snake_case = (
|
||||
snake_case
|
||||
def __init__(self, name, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Name - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
name (int):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
snake_case (int): [optional] # noqa: E501
|
||||
_property (str): [optional] # noqa: E501
|
||||
_123_number (int): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('name', name)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if _property is not None:
|
||||
self._property = (
|
||||
_property
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if _123_number is not None:
|
||||
self._123_number = (
|
||||
_123_number
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this Name. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this Name. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The name of this Name. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this Name.
|
||||
|
||||
|
||||
:param name: The name of this Name. # noqa: E501
|
||||
:type: int
|
||||
def name(self, value):
|
||||
"""Sets the name of this Name. # noqa: E501
|
||||
"""
|
||||
if name is None:
|
||||
raise ApiValueError("Invalid value for `name`, must not be `None`") # noqa: E501
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
@property
|
||||
def snake_case(self):
|
||||
"""Gets the snake_case of this Name. # noqa: E501
|
||||
|
||||
|
||||
:return: The snake_case of this Name. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The snake_case of this Name. # noqa: E501
|
||||
"""
|
||||
return self._snake_case
|
||||
return self.__get_item('snake_case')
|
||||
|
||||
@snake_case.setter
|
||||
def snake_case(self, snake_case): # noqa: E501
|
||||
"""Sets the snake_case of this Name.
|
||||
|
||||
|
||||
:param snake_case: The snake_case of this Name. # noqa: E501
|
||||
:type: int
|
||||
def snake_case(self, value):
|
||||
"""Sets the snake_case of this Name. # noqa: E501
|
||||
"""
|
||||
|
||||
self._snake_case = (
|
||||
snake_case
|
||||
)
|
||||
return self.__set_item('snake_case', value)
|
||||
|
||||
@property
|
||||
def _property(self):
|
||||
"""Gets the _property of this Name. # noqa: E501
|
||||
|
||||
|
||||
:return: The _property of this Name. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The _property of this Name. # noqa: E501
|
||||
"""
|
||||
return self.__property
|
||||
return self.__get_item('_property')
|
||||
|
||||
@_property.setter
|
||||
def _property(self, _property): # noqa: E501
|
||||
"""Sets the _property of this Name.
|
||||
|
||||
|
||||
:param _property: The _property of this Name. # noqa: E501
|
||||
:type: str
|
||||
def _property(self, value):
|
||||
"""Sets the _property of this Name. # noqa: E501
|
||||
"""
|
||||
|
||||
self.__property = (
|
||||
_property
|
||||
)
|
||||
return self.__set_item('_property', value)
|
||||
|
||||
@property
|
||||
def _123_number(self):
|
||||
"""Gets the _123_number of this Name. # noqa: E501
|
||||
|
||||
|
||||
:return: The _123_number of this Name. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The _123_number of this Name. # noqa: E501
|
||||
"""
|
||||
return self.__123_number
|
||||
return self.__get_item('_123_number')
|
||||
|
||||
@_123_number.setter
|
||||
def _123_number(self, _123_number): # noqa: E501
|
||||
"""Sets the _123_number of this Name.
|
||||
|
||||
|
||||
:param _123_number: The _123_number of this Name. # noqa: E501
|
||||
:type: int
|
||||
def _123_number(self, value):
|
||||
"""Sets the _123_number of this Name. # noqa: E501
|
||||
"""
|
||||
|
||||
self.__123_number = (
|
||||
_123_number
|
||||
)
|
||||
return self.__set_item('_123_number', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -222,7 +268,22 @@ class Name(ModelNormal):
|
||||
if not isinstance(other, Name):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class NumberOnly(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class NumberOnly(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'just_number': 'float'
|
||||
'just_number': (float,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, just_number=None): # noqa: E501
|
||||
"""NumberOnly - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._just_number = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if just_number is not None:
|
||||
self.just_number = (
|
||||
just_number
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""NumberOnly - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
just_number (float): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def just_number(self):
|
||||
"""Gets the just_number of this NumberOnly. # noqa: E501
|
||||
|
||||
|
||||
:return: The just_number of this NumberOnly. # noqa: E501
|
||||
:rtype: float
|
||||
Returns:
|
||||
(float): The just_number of this NumberOnly. # noqa: E501
|
||||
"""
|
||||
return self._just_number
|
||||
return self.__get_item('just_number')
|
||||
|
||||
@just_number.setter
|
||||
def just_number(self, just_number): # noqa: E501
|
||||
"""Sets the just_number of this NumberOnly.
|
||||
|
||||
|
||||
:param just_number: The just_number of this NumberOnly. # noqa: E501
|
||||
:type: float
|
||||
def just_number(self, value):
|
||||
"""Sets the just_number of this NumberOnly. # noqa: E501
|
||||
"""
|
||||
|
||||
self._just_number = (
|
||||
just_number
|
||||
)
|
||||
return self.__set_item('just_number', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class NumberOnly(ModelNormal):
|
||||
if not isinstance(other, NumberOnly):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,13 +60,15 @@ class Order(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
('status',): {
|
||||
'PLACED': "placed",
|
||||
'APPROVED': "approved",
|
||||
'DELIVERED': "delivered"
|
||||
'DELIVERED': "delivered",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -66,222 +82,219 @@ class Order(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'id': 'int',
|
||||
'pet_id': 'int',
|
||||
'quantity': 'int',
|
||||
'ship_date': 'datetime',
|
||||
'status': 'str',
|
||||
'complete': 'bool'
|
||||
'id': (int,), # noqa: E501
|
||||
'pet_id': (int,), # noqa: E501
|
||||
'quantity': (int,), # noqa: E501
|
||||
'ship_date': (datetime,), # noqa: E501
|
||||
'status': (str,), # noqa: E501
|
||||
'complete': (bool,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._id = None
|
||||
self._pet_id = None
|
||||
self._quantity = None
|
||||
self._ship_date = None
|
||||
self._status = None
|
||||
self._complete = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if id is not None:
|
||||
self.id = (
|
||||
id
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Order - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
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
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if pet_id is not None:
|
||||
self.pet_id = (
|
||||
pet_id
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if quantity is not None:
|
||||
self.quantity = (
|
||||
quantity
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if ship_date is not None:
|
||||
self.ship_date = (
|
||||
ship_date
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if status is not None:
|
||||
self.status = (
|
||||
status
|
||||
)
|
||||
if complete is not None:
|
||||
self.complete = (
|
||||
complete
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""Gets the id of this Order. # noqa: E501
|
||||
|
||||
|
||||
:return: The id of this Order. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The id of this Order. # noqa: E501
|
||||
"""
|
||||
return self._id
|
||||
return self.__get_item('id')
|
||||
|
||||
@id.setter
|
||||
def id(self, id): # noqa: E501
|
||||
"""Sets the id of this Order.
|
||||
|
||||
|
||||
:param id: The id of this Order. # noqa: E501
|
||||
:type: int
|
||||
def id(self, value):
|
||||
"""Sets the id of this Order. # noqa: E501
|
||||
"""
|
||||
|
||||
self._id = (
|
||||
id
|
||||
)
|
||||
return self.__set_item('id', value)
|
||||
|
||||
@property
|
||||
def pet_id(self):
|
||||
"""Gets the pet_id of this Order. # noqa: E501
|
||||
|
||||
|
||||
:return: The pet_id of this Order. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The pet_id of this Order. # noqa: E501
|
||||
"""
|
||||
return self._pet_id
|
||||
return self.__get_item('pet_id')
|
||||
|
||||
@pet_id.setter
|
||||
def pet_id(self, pet_id): # noqa: E501
|
||||
"""Sets the pet_id of this Order.
|
||||
|
||||
|
||||
:param pet_id: The pet_id of this Order. # noqa: E501
|
||||
:type: int
|
||||
def pet_id(self, value):
|
||||
"""Sets the pet_id of this Order. # noqa: E501
|
||||
"""
|
||||
|
||||
self._pet_id = (
|
||||
pet_id
|
||||
)
|
||||
return self.__set_item('pet_id', value)
|
||||
|
||||
@property
|
||||
def quantity(self):
|
||||
"""Gets the quantity of this Order. # noqa: E501
|
||||
|
||||
|
||||
:return: The quantity of this Order. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The quantity of this Order. # noqa: E501
|
||||
"""
|
||||
return self._quantity
|
||||
return self.__get_item('quantity')
|
||||
|
||||
@quantity.setter
|
||||
def quantity(self, quantity): # noqa: E501
|
||||
"""Sets the quantity of this Order.
|
||||
|
||||
|
||||
:param quantity: The quantity of this Order. # noqa: E501
|
||||
:type: int
|
||||
def quantity(self, value):
|
||||
"""Sets the quantity of this Order. # noqa: E501
|
||||
"""
|
||||
|
||||
self._quantity = (
|
||||
quantity
|
||||
)
|
||||
return self.__set_item('quantity', value)
|
||||
|
||||
@property
|
||||
def ship_date(self):
|
||||
"""Gets the ship_date of this Order. # noqa: E501
|
||||
|
||||
|
||||
:return: The ship_date of this Order. # noqa: E501
|
||||
:rtype: datetime
|
||||
Returns:
|
||||
(datetime): The ship_date of this Order. # noqa: E501
|
||||
"""
|
||||
return self._ship_date
|
||||
return self.__get_item('ship_date')
|
||||
|
||||
@ship_date.setter
|
||||
def ship_date(self, ship_date): # noqa: E501
|
||||
"""Sets the ship_date of this Order.
|
||||
|
||||
|
||||
:param ship_date: The ship_date of this Order. # noqa: E501
|
||||
:type: datetime
|
||||
def ship_date(self, value):
|
||||
"""Sets the ship_date of this Order. # noqa: E501
|
||||
"""
|
||||
|
||||
self._ship_date = (
|
||||
ship_date
|
||||
)
|
||||
return self.__set_item('ship_date', value)
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
"""Gets the status of this Order. # noqa: E501
|
||||
|
||||
Order Status # noqa: E501
|
||||
|
||||
:return: The status of this Order. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The status of this Order. # noqa: E501
|
||||
"""
|
||||
return self._status
|
||||
return self.__get_item('status')
|
||||
|
||||
@status.setter
|
||||
def status(self, status): # noqa: E501
|
||||
"""Sets the status of this Order.
|
||||
|
||||
def status(self, value):
|
||||
"""Sets the status of this Order. # noqa: E501
|
||||
Order Status # noqa: E501
|
||||
|
||||
:param status: The status of this Order. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
('status',),
|
||||
status,
|
||||
self.validations
|
||||
)
|
||||
|
||||
self._status = (
|
||||
status
|
||||
)
|
||||
return self.__set_item('status', value)
|
||||
|
||||
@property
|
||||
def complete(self):
|
||||
"""Gets the complete of this Order. # noqa: E501
|
||||
|
||||
|
||||
:return: The complete of this Order. # noqa: E501
|
||||
:rtype: bool
|
||||
Returns:
|
||||
(bool): The complete of this Order. # noqa: E501
|
||||
"""
|
||||
return self._complete
|
||||
return self.__get_item('complete')
|
||||
|
||||
@complete.setter
|
||||
def complete(self, complete): # noqa: E501
|
||||
"""Sets the complete of this Order.
|
||||
|
||||
|
||||
:param complete: The complete of this Order. # noqa: E501
|
||||
:type: bool
|
||||
def complete(self, value):
|
||||
"""Sets the complete of this Order. # noqa: E501
|
||||
"""
|
||||
|
||||
self._complete = (
|
||||
complete
|
||||
)
|
||||
return self.__set_item('complete', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -296,7 +309,22 @@ class Order(ModelNormal):
|
||||
if not isinstance(other, Order):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,13 +15,28 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.outer_number import OuterNumber
|
||||
|
||||
|
||||
class OuterComposite(ModelNormal):
|
||||
@@ -46,6 +61,8 @@ class OuterComposite(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -58,127 +75,166 @@ class OuterComposite(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'my_number': 'OuterNumber',
|
||||
'my_string': 'str',
|
||||
'my_boolean': 'bool'
|
||||
'my_number': (OuterNumber,), # noqa: E501
|
||||
'my_string': (str,), # noqa: E501
|
||||
'my_boolean': (bool,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, my_number=None, my_string=None, my_boolean=None): # noqa: E501
|
||||
"""OuterComposite - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._my_number = None
|
||||
self._my_string = None
|
||||
self._my_boolean = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if my_number is not None:
|
||||
self.my_number = (
|
||||
my_number
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""OuterComposite - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
my_number (OuterNumber): [optional] # noqa: E501
|
||||
my_string (str): [optional] # noqa: E501
|
||||
my_boolean (bool): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if my_string is not None:
|
||||
self.my_string = (
|
||||
my_string
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if my_boolean is not None:
|
||||
self.my_boolean = (
|
||||
my_boolean
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def my_number(self):
|
||||
"""Gets the my_number of this OuterComposite. # noqa: E501
|
||||
|
||||
|
||||
:return: The my_number of this OuterComposite. # noqa: E501
|
||||
:rtype: OuterNumber
|
||||
Returns:
|
||||
(OuterNumber): The my_number of this OuterComposite. # noqa: E501
|
||||
"""
|
||||
return self._my_number
|
||||
return self.__get_item('my_number')
|
||||
|
||||
@my_number.setter
|
||||
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: OuterNumber
|
||||
def my_number(self, value):
|
||||
"""Sets the my_number of this OuterComposite. # noqa: E501
|
||||
"""
|
||||
|
||||
self._my_number = (
|
||||
my_number
|
||||
)
|
||||
return self.__set_item('my_number', value)
|
||||
|
||||
@property
|
||||
def my_string(self):
|
||||
"""Gets the my_string of this OuterComposite. # noqa: E501
|
||||
|
||||
|
||||
:return: The my_string of this OuterComposite. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The my_string of this OuterComposite. # noqa: E501
|
||||
"""
|
||||
return self._my_string
|
||||
return self.__get_item('my_string')
|
||||
|
||||
@my_string.setter
|
||||
def my_string(self, my_string): # noqa: E501
|
||||
"""Sets the my_string of this OuterComposite.
|
||||
|
||||
|
||||
:param my_string: The my_string of this OuterComposite. # noqa: E501
|
||||
:type: str
|
||||
def my_string(self, value):
|
||||
"""Sets the my_string of this OuterComposite. # noqa: E501
|
||||
"""
|
||||
|
||||
self._my_string = (
|
||||
my_string
|
||||
)
|
||||
return self.__set_item('my_string', value)
|
||||
|
||||
@property
|
||||
def my_boolean(self):
|
||||
"""Gets the my_boolean of this OuterComposite. # noqa: E501
|
||||
|
||||
|
||||
:return: The my_boolean of this OuterComposite. # noqa: E501
|
||||
:rtype: bool
|
||||
Returns:
|
||||
(bool): The my_boolean of this OuterComposite. # noqa: E501
|
||||
"""
|
||||
return self._my_boolean
|
||||
return self.__get_item('my_boolean')
|
||||
|
||||
@my_boolean.setter
|
||||
def my_boolean(self, my_boolean): # noqa: E501
|
||||
"""Sets the my_boolean of this OuterComposite.
|
||||
|
||||
|
||||
:param my_boolean: The my_boolean of this OuterComposite. # noqa: E501
|
||||
:type: bool
|
||||
def my_boolean(self, value):
|
||||
"""Sets the my_boolean of this OuterComposite. # noqa: E501
|
||||
"""
|
||||
|
||||
self._my_boolean = (
|
||||
my_boolean
|
||||
)
|
||||
return self.__set_item('my_boolean', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -193,7 +249,22 @@ class OuterComposite(ModelNormal):
|
||||
if not isinstance(other, OuterComposite):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -42,65 +56,147 @@ class OuterEnum(ModelSimple):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
('value',): {
|
||||
'PLACED': "placed",
|
||||
'APPROVED': "approved",
|
||||
'DELIVERED': "delivered"
|
||||
'DELIVERED': "delivered",
|
||||
},
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'value': 'str'
|
||||
'value': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, value=None): # noqa: E501
|
||||
"""OuterEnum - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._value = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
self.value = value
|
||||
def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""OuterEnum - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
value (str):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('value', value)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
"""Gets the value of this OuterEnum. # noqa: E501
|
||||
|
||||
|
||||
:return: The value of this OuterEnum. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The value of this OuterEnum. # noqa: E501
|
||||
"""
|
||||
return self._value
|
||||
return self.__get_item('value')
|
||||
|
||||
@value.setter
|
||||
def value(self, value): # noqa: E501
|
||||
"""Sets the value of this OuterEnum.
|
||||
|
||||
|
||||
:param value: The value of this OuterEnum. # noqa: E501
|
||||
:type: str
|
||||
def value(self, value):
|
||||
"""Sets the value of this OuterEnum. # noqa: E501
|
||||
"""
|
||||
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
|
||||
)
|
||||
return self.__set_item('value', value)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return str(self._value)
|
||||
return str(self.value)
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
@@ -111,7 +207,19 @@ class OuterEnum(ModelSimple):
|
||||
if not isinstance(other, OuterEnum):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
this_val = self._data_store['value']
|
||||
that_val = other._data_store['value']
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -42,64 +56,146 @@ class OuterNumber(ModelSimple):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'value': 'float'
|
||||
'value': (float,), # noqa: E501
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._value = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
self.value = value
|
||||
def __init__(self, value, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""OuterNumber - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
value (float):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('value', value)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
"""Gets the value of this OuterNumber. # noqa: E501
|
||||
|
||||
|
||||
:return: The value of this OuterNumber. # noqa: E501
|
||||
:rtype: float
|
||||
Returns:
|
||||
(float): The value of this OuterNumber. # noqa: E501
|
||||
"""
|
||||
return self._value
|
||||
return self.__get_item('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
|
||||
def value(self, value):
|
||||
"""Sets the value of this OuterNumber. # noqa: E501
|
||||
"""
|
||||
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
|
||||
)
|
||||
return self.__set_item('value', value)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
return str(self._value)
|
||||
return str(self.value)
|
||||
|
||||
def __repr__(self):
|
||||
"""For `print` and `pprint`"""
|
||||
@@ -110,7 +206,19 @@ class OuterNumber(ModelSimple):
|
||||
if not isinstance(other, OuterNumber):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
this_val = self._data_store['value']
|
||||
that_val = other._data_store['value']
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if not six.PY3 and len(types) == 2 and unicode in types: # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,13 +15,29 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
from petstore_api.models.category import Category
|
||||
from petstore_api.models.tag import Tag
|
||||
|
||||
|
||||
class Pet(ModelNormal):
|
||||
@@ -46,13 +62,15 @@ class Pet(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
('status',): {
|
||||
'AVAILABLE': "available",
|
||||
'PENDING': "pending",
|
||||
'SOLD': "sold"
|
||||
'SOLD': "sold",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -66,220 +84,222 @@ class Pet(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'id': 'int',
|
||||
'category': 'Category',
|
||||
'name': 'str',
|
||||
'photo_urls': 'list[str]',
|
||||
'tags': 'list[Tag]',
|
||||
'status': 'str'
|
||||
'id': (int,), # noqa: E501
|
||||
'category': (Category,), # noqa: E501
|
||||
'name': (str,), # noqa: E501
|
||||
'photo_urls': ([str],), # noqa: E501
|
||||
'tags': ([Tag],), # noqa: E501
|
||||
'status': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._id = None
|
||||
self._category = None
|
||||
self._name = None
|
||||
self._photo_urls = None
|
||||
self._tags = None
|
||||
self._status = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if id is not None:
|
||||
self.id = (
|
||||
id
|
||||
def __init__(self, name, photo_urls, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Pet - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
name (str):
|
||||
photo_urls ([str]):
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
id (int): [optional] # noqa: E501
|
||||
category (Category): [optional] # noqa: E501
|
||||
tags ([Tag]): [optional] # noqa: E501
|
||||
status (str): pet status in the store. [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('name', name)
|
||||
self.__set_item('photo_urls', photo_urls)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if category is not None:
|
||||
self.category = (
|
||||
category
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
self.name = name
|
||||
self.photo_urls = photo_urls
|
||||
if tags is not None:
|
||||
self.tags = (
|
||||
tags
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
if status is not None:
|
||||
self.status = (
|
||||
status
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""Gets the id of this Pet. # noqa: E501
|
||||
|
||||
|
||||
:return: The id of this Pet. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The id of this Pet. # noqa: E501
|
||||
"""
|
||||
return self._id
|
||||
return self.__get_item('id')
|
||||
|
||||
@id.setter
|
||||
def id(self, id): # noqa: E501
|
||||
"""Sets the id of this Pet.
|
||||
|
||||
|
||||
:param id: The id of this Pet. # noqa: E501
|
||||
:type: int
|
||||
def id(self, value):
|
||||
"""Sets the id of this Pet. # noqa: E501
|
||||
"""
|
||||
|
||||
self._id = (
|
||||
id
|
||||
)
|
||||
return self.__set_item('id', value)
|
||||
|
||||
@property
|
||||
def category(self):
|
||||
"""Gets the category of this Pet. # noqa: E501
|
||||
|
||||
|
||||
:return: The category of this Pet. # noqa: E501
|
||||
:rtype: Category
|
||||
Returns:
|
||||
(Category): The category of this Pet. # noqa: E501
|
||||
"""
|
||||
return self._category
|
||||
return self.__get_item('category')
|
||||
|
||||
@category.setter
|
||||
def category(self, category): # noqa: E501
|
||||
"""Sets the category of this Pet.
|
||||
|
||||
|
||||
:param category: The category of this Pet. # noqa: E501
|
||||
:type: Category
|
||||
def category(self, value):
|
||||
"""Sets the category of this Pet. # noqa: E501
|
||||
"""
|
||||
|
||||
self._category = (
|
||||
category
|
||||
)
|
||||
return self.__set_item('category', value)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this Pet. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this Pet. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this Pet. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this Pet.
|
||||
|
||||
|
||||
:param name: The name of this Pet. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this Pet. # noqa: E501
|
||||
"""
|
||||
if name is None:
|
||||
raise ApiValueError("Invalid value for `name`, must not be `None`") # noqa: E501
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
@property
|
||||
def photo_urls(self):
|
||||
"""Gets the photo_urls of this Pet. # noqa: E501
|
||||
|
||||
|
||||
:return: The photo_urls of this Pet. # noqa: E501
|
||||
:rtype: list[str]
|
||||
Returns:
|
||||
([str]): The photo_urls of this Pet. # noqa: E501
|
||||
"""
|
||||
return self._photo_urls
|
||||
return self.__get_item('photo_urls')
|
||||
|
||||
@photo_urls.setter
|
||||
def photo_urls(self, photo_urls): # noqa: E501
|
||||
"""Sets the photo_urls of this Pet.
|
||||
|
||||
|
||||
:param photo_urls: The photo_urls of this Pet. # noqa: E501
|
||||
:type: list[str]
|
||||
def photo_urls(self, value):
|
||||
"""Sets the photo_urls of this Pet. # noqa: E501
|
||||
"""
|
||||
if photo_urls is None:
|
||||
raise ApiValueError("Invalid value for `photo_urls`, must not be `None`") # noqa: E501
|
||||
|
||||
self._photo_urls = (
|
||||
photo_urls
|
||||
)
|
||||
return self.__set_item('photo_urls', value)
|
||||
|
||||
@property
|
||||
def tags(self):
|
||||
"""Gets the tags of this Pet. # noqa: E501
|
||||
|
||||
|
||||
:return: The tags of this Pet. # noqa: E501
|
||||
:rtype: list[Tag]
|
||||
Returns:
|
||||
([Tag]): The tags of this Pet. # noqa: E501
|
||||
"""
|
||||
return self._tags
|
||||
return self.__get_item('tags')
|
||||
|
||||
@tags.setter
|
||||
def tags(self, tags): # noqa: E501
|
||||
"""Sets the tags of this Pet.
|
||||
|
||||
|
||||
:param tags: The tags of this Pet. # noqa: E501
|
||||
:type: list[Tag]
|
||||
def tags(self, value):
|
||||
"""Sets the tags of this Pet. # noqa: E501
|
||||
"""
|
||||
|
||||
self._tags = (
|
||||
tags
|
||||
)
|
||||
return self.__set_item('tags', value)
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
"""Gets the status of this Pet. # noqa: E501
|
||||
|
||||
pet status in the store # noqa: E501
|
||||
|
||||
:return: The status of this Pet. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The status of this Pet. # noqa: E501
|
||||
"""
|
||||
return self._status
|
||||
return self.__get_item('status')
|
||||
|
||||
@status.setter
|
||||
def status(self, status): # noqa: E501
|
||||
"""Sets the status of this Pet.
|
||||
|
||||
def status(self, value):
|
||||
"""Sets the status of this Pet. # noqa: E501
|
||||
pet status in the store # noqa: E501
|
||||
|
||||
:param status: The status of this Pet. # noqa: E501
|
||||
:type: str
|
||||
"""
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
('status',),
|
||||
status,
|
||||
self.validations
|
||||
)
|
||||
|
||||
self._status = (
|
||||
status
|
||||
)
|
||||
return self.__set_item('status', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -294,7 +314,22 @@ class Pet(ModelNormal):
|
||||
if not isinstance(other, Pet):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class ReadOnlyFirst(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -57,98 +73,149 @@ class ReadOnlyFirst(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'bar': 'str',
|
||||
'baz': 'str'
|
||||
'bar': (str,), # noqa: E501
|
||||
'baz': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, bar=None, baz=None): # noqa: E501
|
||||
"""ReadOnlyFirst - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._bar = None
|
||||
self._baz = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if bar is not None:
|
||||
self.bar = (
|
||||
bar
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""ReadOnlyFirst - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
bar (str): [optional] # noqa: E501
|
||||
baz (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if baz is not None:
|
||||
self.baz = (
|
||||
baz
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def bar(self):
|
||||
"""Gets the bar of this ReadOnlyFirst. # noqa: E501
|
||||
|
||||
|
||||
:return: The bar of this ReadOnlyFirst. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The bar of this ReadOnlyFirst. # noqa: E501
|
||||
"""
|
||||
return self._bar
|
||||
return self.__get_item('bar')
|
||||
|
||||
@bar.setter
|
||||
def bar(self, bar): # noqa: E501
|
||||
"""Sets the bar of this ReadOnlyFirst.
|
||||
|
||||
|
||||
:param bar: The bar of this ReadOnlyFirst. # noqa: E501
|
||||
:type: str
|
||||
def bar(self, value):
|
||||
"""Sets the bar of this ReadOnlyFirst. # noqa: E501
|
||||
"""
|
||||
|
||||
self._bar = (
|
||||
bar
|
||||
)
|
||||
return self.__set_item('bar', value)
|
||||
|
||||
@property
|
||||
def baz(self):
|
||||
"""Gets the baz of this ReadOnlyFirst. # noqa: E501
|
||||
|
||||
|
||||
:return: The baz of this ReadOnlyFirst. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The baz of this ReadOnlyFirst. # noqa: E501
|
||||
"""
|
||||
return self._baz
|
||||
return self.__get_item('baz')
|
||||
|
||||
@baz.setter
|
||||
def baz(self, baz): # noqa: E501
|
||||
"""Sets the baz of this ReadOnlyFirst.
|
||||
|
||||
|
||||
:param baz: The baz of this ReadOnlyFirst. # noqa: E501
|
||||
:type: str
|
||||
def baz(self, value):
|
||||
"""Sets the baz of this ReadOnlyFirst. # noqa: E501
|
||||
"""
|
||||
|
||||
self._baz = (
|
||||
baz
|
||||
)
|
||||
return self.__set_item('baz', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -163,7 +230,22 @@ class ReadOnlyFirst(ModelNormal):
|
||||
if not isinstance(other, ReadOnlyFirst):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class SpecialModelName(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -56,69 +72,132 @@ class SpecialModelName(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'special_property_name': 'int'
|
||||
'special_property_name': (int,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, special_property_name=None): # noqa: E501
|
||||
"""SpecialModelName - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._special_property_name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if special_property_name is not None:
|
||||
self.special_property_name = (
|
||||
special_property_name
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""SpecialModelName - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
special_property_name (int): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def special_property_name(self):
|
||||
"""Gets the special_property_name of this SpecialModelName. # noqa: E501
|
||||
|
||||
|
||||
:return: The special_property_name of this SpecialModelName. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The special_property_name of this SpecialModelName. # noqa: E501
|
||||
"""
|
||||
return self._special_property_name
|
||||
return self.__get_item('special_property_name')
|
||||
|
||||
@special_property_name.setter
|
||||
def special_property_name(self, special_property_name): # noqa: E501
|
||||
"""Sets the special_property_name of this SpecialModelName.
|
||||
|
||||
|
||||
:param special_property_name: The special_property_name of this SpecialModelName. # noqa: E501
|
||||
:type: int
|
||||
def special_property_name(self, value):
|
||||
"""Sets the special_property_name of this SpecialModelName. # noqa: E501
|
||||
"""
|
||||
|
||||
self._special_property_name = (
|
||||
special_property_name
|
||||
)
|
||||
return self.__set_item('special_property_name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -133,7 +212,22 @@ class SpecialModelName(ModelNormal):
|
||||
if not isinstance(other, SpecialModelName):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class StringBooleanMap(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -60,33 +76,110 @@ class StringBooleanMap(ModelNormal):
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self): # noqa: E501
|
||||
"""StringBooleanMap - a model defined in OpenAPI""" # noqa: E501
|
||||
self.discriminator = None
|
||||
additional_properties_type = (bool,) # noqa: E501
|
||||
|
||||
discriminator = None
|
||||
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""StringBooleanMap - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
def to_dict(self):
|
||||
"""Returns the model properties as a dict"""
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -101,7 +194,22 @@ class StringBooleanMap(ModelNormal):
|
||||
if not isinstance(other, StringBooleanMap):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class Tag(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -57,98 +73,149 @@ class Tag(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'id': 'int',
|
||||
'name': 'str'
|
||||
'id': (int,), # noqa: E501
|
||||
'name': (str,), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
def __init__(self, id=None, name=None): # noqa: E501
|
||||
"""Tag - a model defined in OpenAPI""" # noqa: E501
|
||||
additional_properties_type = None
|
||||
|
||||
self._id = None
|
||||
self._name = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
if id is not None:
|
||||
self.id = (
|
||||
id
|
||||
def __init__(self, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""Tag - a model defined in OpenAPI
|
||||
|
||||
|
||||
Keyword Args:
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
id (int): [optional] # noqa: E501
|
||||
name (str): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if name is not None:
|
||||
self.name = (
|
||||
name
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""Gets the id of this Tag. # noqa: E501
|
||||
|
||||
|
||||
:return: The id of this Tag. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The id of this Tag. # noqa: E501
|
||||
"""
|
||||
return self._id
|
||||
return self.__get_item('id')
|
||||
|
||||
@id.setter
|
||||
def id(self, id): # noqa: E501
|
||||
"""Sets the id of this Tag.
|
||||
|
||||
|
||||
:param id: The id of this Tag. # noqa: E501
|
||||
:type: int
|
||||
def id(self, value):
|
||||
"""Sets the id of this Tag. # noqa: E501
|
||||
"""
|
||||
|
||||
self._id = (
|
||||
id
|
||||
)
|
||||
return self.__set_item('id', value)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Gets the name of this Tag. # noqa: E501
|
||||
|
||||
|
||||
:return: The name of this Tag. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The name of this Tag. # noqa: E501
|
||||
"""
|
||||
return self._name
|
||||
return self.__get_item('name')
|
||||
|
||||
@name.setter
|
||||
def name(self, name): # noqa: E501
|
||||
"""Sets the name of this Tag.
|
||||
|
||||
|
||||
:param name: The name of this Tag. # noqa: E501
|
||||
:type: str
|
||||
def name(self, value):
|
||||
"""Sets the name of this Tag. # noqa: E501
|
||||
"""
|
||||
|
||||
self._name = (
|
||||
name
|
||||
)
|
||||
return self.__set_item('name', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -163,7 +230,22 @@ class Tag(ModelNormal):
|
||||
if not isinstance(other, Tag):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
@@ -15,12 +15,26 @@ import re # noqa: F401
|
||||
|
||||
import six # noqa: F401
|
||||
|
||||
from petstore_api.exceptions import ApiValueError # noqa: F401
|
||||
from petstore_api.exceptions import ( # noqa: F401
|
||||
ApiKeyError,
|
||||
ApiTypeError,
|
||||
ApiValueError,
|
||||
)
|
||||
from petstore_api.model_utils import ( # noqa: F401
|
||||
ModelNormal,
|
||||
ModelSimple,
|
||||
check_allowed_values,
|
||||
check_validations
|
||||
check_validations,
|
||||
date,
|
||||
datetime,
|
||||
file_type,
|
||||
get_simple_class,
|
||||
int,
|
||||
model_to_dict,
|
||||
none_type,
|
||||
str,
|
||||
type_error_message,
|
||||
validate_and_convert_types
|
||||
)
|
||||
|
||||
|
||||
@@ -46,6 +60,8 @@ class TypeHolderDefault(ModelNormal):
|
||||
that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
additional_properties_type (tuple): A tuple of classes accepted
|
||||
as additional properties values.
|
||||
"""
|
||||
|
||||
allowed_values = {
|
||||
@@ -62,238 +78,240 @@ class TypeHolderDefault(ModelNormal):
|
||||
}
|
||||
|
||||
openapi_types = {
|
||||
'string_item': 'str',
|
||||
'number_item': 'float',
|
||||
'integer_item': 'int',
|
||||
'bool_item': 'bool',
|
||||
'date_item': 'date',
|
||||
'datetime_item': 'datetime',
|
||||
'array_item': 'list[int]'
|
||||
'string_item': (str,), # noqa: E501
|
||||
'number_item': (float,), # noqa: E501
|
||||
'integer_item': (int,), # noqa: E501
|
||||
'bool_item': (bool,), # noqa: E501
|
||||
'date_item': (date,), # noqa: E501
|
||||
'datetime_item': (datetime,), # noqa: E501
|
||||
'array_item': ([int],), # noqa: E501
|
||||
}
|
||||
|
||||
validations = {
|
||||
}
|
||||
|
||||
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
|
||||
additional_properties_type = None
|
||||
|
||||
self._string_item = None
|
||||
self._number_item = None
|
||||
self._integer_item = None
|
||||
self._bool_item = None
|
||||
self._date_item = None
|
||||
self._datetime_item = None
|
||||
self._array_item = None
|
||||
self.discriminator = None
|
||||
discriminator = None
|
||||
|
||||
self.string_item = string_item
|
||||
self.number_item = number_item
|
||||
self.integer_item = integer_item
|
||||
self.bool_item = bool_item
|
||||
if date_item is not None:
|
||||
self.date_item = (
|
||||
date_item
|
||||
def __init__(self, array_item, string_item='what', number_item=1.234, integer_item=-2, bool_item=True, _check_type=True, _from_server=False, _path_to_item=(), _configuration=None, **kwargs): # noqa: E501
|
||||
"""TypeHolderDefault - a model defined in OpenAPI
|
||||
|
||||
Args:
|
||||
array_item ([int]):
|
||||
|
||||
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
|
||||
_check_type (bool): if True, values for parameters in openapi_types
|
||||
will be type checked and a TypeError will be
|
||||
raised if the wrong type is input.
|
||||
Defaults to True
|
||||
_path_to_item (tuple/list): This is a list of keys or values to
|
||||
drill down to the model in received_data
|
||||
when deserializing a response
|
||||
_from_server (bool): True if the data is from the server
|
||||
False if the data is from the client (default)
|
||||
_configuration (Configuration): the instance to use when
|
||||
deserializing a file_type parameter.
|
||||
If passed, type conversion is attempted
|
||||
If omitted no type conversion is done.
|
||||
date_item (date): [optional] # noqa: E501
|
||||
datetime_item (datetime): [optional] # noqa: E501
|
||||
"""
|
||||
self._data_store = {}
|
||||
self._check_type = _check_type
|
||||
self._from_server = _from_server
|
||||
self._path_to_item = _path_to_item
|
||||
self._configuration = _configuration
|
||||
|
||||
self.__set_item('string_item', string_item)
|
||||
self.__set_item('number_item', number_item)
|
||||
self.__set_item('integer_item', integer_item)
|
||||
self.__set_item('bool_item', bool_item)
|
||||
self.__set_item('array_item', array_item)
|
||||
for var_name, var_value in six.iteritems(kwargs):
|
||||
self.__set_item(var_name, var_value)
|
||||
|
||||
def __set_item(self, name, value):
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
|
||||
if name in self.openapi_types:
|
||||
required_types_mixed = self.openapi_types[name]
|
||||
elif self.additional_properties_type is None:
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
path_to_item
|
||||
)
|
||||
if datetime_item is not None:
|
||||
self.datetime_item = (
|
||||
datetime_item
|
||||
elif self.additional_properties_type is not None:
|
||||
required_types_mixed = self.additional_properties_type
|
||||
|
||||
if get_simple_class(name) != str:
|
||||
error_msg = type_error_message(
|
||||
var_name=name,
|
||||
var_value=name,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
self.array_item = array_item
|
||||
raise ApiTypeError(
|
||||
error_msg,
|
||||
path_to_item=path_to_item,
|
||||
valid_classes=(str,),
|
||||
key_type=True
|
||||
)
|
||||
|
||||
if self._check_type:
|
||||
value = validate_and_convert_types(
|
||||
value, required_types_mixed, path_to_item, self._from_server,
|
||||
self._check_type, configuration=self._configuration)
|
||||
if (name,) in self.allowed_values:
|
||||
check_allowed_values(
|
||||
self.allowed_values,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
if (name,) in self.validations:
|
||||
check_validations(
|
||||
self.validations,
|
||||
(name,),
|
||||
value
|
||||
)
|
||||
self._data_store[name] = value
|
||||
|
||||
def __get_item(self, name):
|
||||
if name in self._data_store:
|
||||
return self._data_store[name]
|
||||
|
||||
path_to_item = []
|
||||
if self._path_to_item:
|
||||
path_to_item.extend(self._path_to_item)
|
||||
path_to_item.append(name)
|
||||
raise ApiKeyError(
|
||||
"{0} has no key '{1}'".format(type(self).__name__, name),
|
||||
[name]
|
||||
)
|
||||
|
||||
def __setitem__(self, name, value):
|
||||
"""this allows us to set values with instance[field_name] = val"""
|
||||
self.__set_item(name, value)
|
||||
|
||||
def __getitem__(self, name):
|
||||
"""this allows us to get a value with val = instance[field_name]"""
|
||||
return self.__get_item(name)
|
||||
|
||||
@property
|
||||
def string_item(self):
|
||||
"""Gets the string_item of this TypeHolderDefault. # noqa: E501
|
||||
|
||||
|
||||
:return: The string_item of this TypeHolderDefault. # noqa: E501
|
||||
:rtype: str
|
||||
Returns:
|
||||
(str): The string_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
return self._string_item
|
||||
return self.__get_item('string_item')
|
||||
|
||||
@string_item.setter
|
||||
def string_item(self, string_item): # noqa: E501
|
||||
"""Sets the string_item of this TypeHolderDefault.
|
||||
|
||||
|
||||
:param string_item: The string_item of this TypeHolderDefault. # noqa: E501
|
||||
:type: str
|
||||
def string_item(self, value):
|
||||
"""Sets the string_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
if string_item is None:
|
||||
raise ApiValueError("Invalid value for `string_item`, must not be `None`") # noqa: E501
|
||||
|
||||
self._string_item = (
|
||||
string_item
|
||||
)
|
||||
return self.__set_item('string_item', value)
|
||||
|
||||
@property
|
||||
def number_item(self):
|
||||
"""Gets the number_item of this TypeHolderDefault. # noqa: E501
|
||||
|
||||
|
||||
:return: The number_item of this TypeHolderDefault. # noqa: E501
|
||||
:rtype: float
|
||||
Returns:
|
||||
(float): The number_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
return self._number_item
|
||||
return self.__get_item('number_item')
|
||||
|
||||
@number_item.setter
|
||||
def number_item(self, number_item): # noqa: E501
|
||||
"""Sets the number_item of this TypeHolderDefault.
|
||||
|
||||
|
||||
:param number_item: The number_item of this TypeHolderDefault. # noqa: E501
|
||||
:type: float
|
||||
def number_item(self, value):
|
||||
"""Sets the number_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
if number_item is None:
|
||||
raise ApiValueError("Invalid value for `number_item`, must not be `None`") # noqa: E501
|
||||
|
||||
self._number_item = (
|
||||
number_item
|
||||
)
|
||||
return self.__set_item('number_item', value)
|
||||
|
||||
@property
|
||||
def integer_item(self):
|
||||
"""Gets the integer_item of this TypeHolderDefault. # noqa: E501
|
||||
|
||||
|
||||
:return: The integer_item of this TypeHolderDefault. # noqa: E501
|
||||
:rtype: int
|
||||
Returns:
|
||||
(int): The integer_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
return self._integer_item
|
||||
return self.__get_item('integer_item')
|
||||
|
||||
@integer_item.setter
|
||||
def integer_item(self, integer_item): # noqa: E501
|
||||
"""Sets the integer_item of this TypeHolderDefault.
|
||||
|
||||
|
||||
:param integer_item: The integer_item of this TypeHolderDefault. # noqa: E501
|
||||
:type: int
|
||||
def integer_item(self, value):
|
||||
"""Sets the integer_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
if integer_item is None:
|
||||
raise ApiValueError("Invalid value for `integer_item`, must not be `None`") # noqa: E501
|
||||
|
||||
self._integer_item = (
|
||||
integer_item
|
||||
)
|
||||
return self.__set_item('integer_item', value)
|
||||
|
||||
@property
|
||||
def bool_item(self):
|
||||
"""Gets the bool_item of this TypeHolderDefault. # noqa: E501
|
||||
|
||||
|
||||
:return: The bool_item of this TypeHolderDefault. # noqa: E501
|
||||
:rtype: bool
|
||||
Returns:
|
||||
(bool): The bool_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
return self._bool_item
|
||||
return self.__get_item('bool_item')
|
||||
|
||||
@bool_item.setter
|
||||
def bool_item(self, bool_item): # noqa: E501
|
||||
"""Sets the bool_item of this TypeHolderDefault.
|
||||
|
||||
|
||||
:param bool_item: The bool_item of this TypeHolderDefault. # noqa: E501
|
||||
:type: bool
|
||||
def bool_item(self, value):
|
||||
"""Sets the bool_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
if bool_item is None:
|
||||
raise ApiValueError("Invalid value for `bool_item`, must not be `None`") # noqa: E501
|
||||
|
||||
self._bool_item = (
|
||||
bool_item
|
||||
)
|
||||
return self.__set_item('bool_item', value)
|
||||
|
||||
@property
|
||||
def date_item(self):
|
||||
"""Gets the date_item of this TypeHolderDefault. # noqa: E501
|
||||
|
||||
|
||||
:return: The date_item of this TypeHolderDefault. # noqa: E501
|
||||
:rtype: date
|
||||
Returns:
|
||||
(date): The date_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
return self._date_item
|
||||
return self.__get_item('date_item')
|
||||
|
||||
@date_item.setter
|
||||
def date_item(self, date_item): # noqa: E501
|
||||
"""Sets the date_item of this TypeHolderDefault.
|
||||
|
||||
|
||||
:param date_item: The date_item of this TypeHolderDefault. # noqa: E501
|
||||
:type: date
|
||||
def date_item(self, value):
|
||||
"""Sets the date_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
|
||||
self._date_item = (
|
||||
date_item
|
||||
)
|
||||
return self.__set_item('date_item', value)
|
||||
|
||||
@property
|
||||
def datetime_item(self):
|
||||
"""Gets the datetime_item of this TypeHolderDefault. # noqa: E501
|
||||
|
||||
|
||||
:return: The datetime_item of this TypeHolderDefault. # noqa: E501
|
||||
:rtype: datetime
|
||||
Returns:
|
||||
(datetime): The datetime_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
return self._datetime_item
|
||||
return self.__get_item('datetime_item')
|
||||
|
||||
@datetime_item.setter
|
||||
def datetime_item(self, datetime_item): # noqa: E501
|
||||
"""Sets the datetime_item of this TypeHolderDefault.
|
||||
|
||||
|
||||
:param datetime_item: The datetime_item of this TypeHolderDefault. # noqa: E501
|
||||
:type: datetime
|
||||
def datetime_item(self, value):
|
||||
"""Sets the datetime_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
|
||||
self._datetime_item = (
|
||||
datetime_item
|
||||
)
|
||||
return self.__set_item('datetime_item', value)
|
||||
|
||||
@property
|
||||
def array_item(self):
|
||||
"""Gets the array_item of this TypeHolderDefault. # noqa: E501
|
||||
|
||||
|
||||
:return: The array_item of this TypeHolderDefault. # noqa: E501
|
||||
:rtype: list[int]
|
||||
Returns:
|
||||
([int]): The array_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
return self._array_item
|
||||
return self.__get_item('array_item')
|
||||
|
||||
@array_item.setter
|
||||
def array_item(self, array_item): # noqa: E501
|
||||
"""Sets the array_item of this TypeHolderDefault.
|
||||
|
||||
|
||||
:param array_item: The array_item of this TypeHolderDefault. # noqa: E501
|
||||
:type: list[int]
|
||||
def array_item(self, value):
|
||||
"""Sets the array_item of this TypeHolderDefault. # noqa: E501
|
||||
"""
|
||||
if array_item is None:
|
||||
raise ApiValueError("Invalid value for `array_item`, must not be `None`") # noqa: E501
|
||||
|
||||
self._array_item = (
|
||||
array_item
|
||||
)
|
||||
return self.__set_item('array_item', value)
|
||||
|
||||
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
|
||||
return model_to_dict(self, serialize=False)
|
||||
|
||||
def to_str(self):
|
||||
"""Returns the string representation of the model"""
|
||||
@@ -308,7 +326,22 @@ class TypeHolderDefault(ModelNormal):
|
||||
if not isinstance(other, TypeHolderDefault):
|
||||
return False
|
||||
|
||||
return self.__dict__ == other.__dict__
|
||||
if not set(self._data_store.keys()) == set(other._data_store.keys()):
|
||||
return False
|
||||
for _var_name, this_val in six.iteritems(self._data_store):
|
||||
that_val = other._data_store[_var_name]
|
||||
types = set()
|
||||
types.add(this_val.__class__)
|
||||
types.add(that_val.__class__)
|
||||
vals_equal = this_val == that_val
|
||||
if (not six.PY3 and
|
||||
len(types) == 2 and unicode in types): # noqa: F821
|
||||
vals_equal = (
|
||||
this_val.encode('utf-8') == that_val.encode('utf-8')
|
||||
)
|
||||
if not vals_equal:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __ne__(self, other):
|
||||
"""Returns true if both objects are not equal"""
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user