[python-flask] Apply template tweaks to improve lint results (#6826)

The linting results for the generated samples are as follows
where the first number is the BEFORE and the second is AFTER.

flaskConnexion          1843 vs. 20
flaskConnexion-python2  1841 vs. 19

For the complete details please see the following gist.
https://gist.github.com/kenjones-cisco/edc9d71ef7fd2bf23714ecbb693d52b3
This commit is contained in:
Kenny Jones 2017-10-27 10:18:14 -04:00 committed by wing328
parent f472b623f0
commit 28d14e34c4
46 changed files with 1276 additions and 1239 deletions

View File

@ -1,6 +1,7 @@
# coding: utf-8 # coding: utf-8
# flake8: noqa
from __future__ import absolute_import from __future__ import absolute_import
# import models into model package # import models into model package
{{#models}}{{#model}}from .{{classFilename}} import {{classname}}{{/model}} {{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}}
{{/models}} {{/models}}

View File

@ -1,8 +1,10 @@
from flask_testing import TestCase
from ..encoder import JSONEncoder
import connexion
import logging import logging
import connexion
from flask_testing import TestCase
from {{packageName}}.encoder import JSONEncoder
class BaseTestCase(TestCase): class BaseTestCase(TestCase):

View File

@ -6,13 +6,14 @@
{{/supportPython2}} {{/supportPython2}}
import connexion import connexion
from .encoder import JSONEncoder
from {{packageName}} import encoder
def main(): def main():
app = connexion.App(__name__, specification_dir='./swagger/') app = connexion.App(__name__, specification_dir='./swagger/')
app.app.json_encoder = JSONEncoder app.app.json_encoder = encoder.JSONEncoder
app.add_api('swagger.yaml', arguments={'title': '{{appDescription}}'}) app.add_api('swagger.yaml', arguments={'title': '{{appName}}'})
app.run(port={{serverPort}}) app.run(port={{serverPort}})

View File

@ -1,38 +1,39 @@
from pprint import pformat import pprint
import six
{{^supportPython2}} {{^supportPython2}}
from typing import TypeVar, Type import typing
{{/supportPython2}} {{/supportPython2}}
from six import iteritems
from ..util import deserialize_model from {{packageName}} import util
{{^supportPython2}} {{^supportPython2}}
T = TypeVar('T') T = typing.TypeVar('T')
{{/supportPython2}} {{/supportPython2}}
class Model(object): class Model(object):
# swaggerTypes: The key is attribute name and the value is attribute type. # swaggerTypes: The key is attribute name and the
# value is attribute type.
swagger_types = {} swagger_types = {}
# attributeMap: The key is attribute name and the value is json key in definition. # attributeMap: The key is attribute name and the
# value is json key in definition.
attribute_map = {} attribute_map = {}
@classmethod @classmethod
def from_dict(cls{{^supportPython2}}: Type[T]{{/supportPython2}}, dikt){{^supportPython2}} -> T{{/supportPython2}}: def from_dict(cls{{^supportPython2}}: typing.Type[T]{{/supportPython2}}, dikt){{^supportPython2}} -> T{{/supportPython2}}:
""" """Returns the dict as a model"""
Returns the dict as a model return util.deserialize_model(dikt, cls)
"""
return deserialize_model(dikt, cls)
def to_dict(self): def to_dict(self):
""" """Returns the model properties as a dict
Returns the model properties as a dict
:rtype: dict :rtype: dict
""" """
result = {} result = {}
for attr, _ in iteritems(self.swagger_types): for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr) value = getattr(self, attr)
if isinstance(value, list): if isinstance(value, list):
result[attr] = list(map( result[attr] = list(map(
@ -53,27 +54,20 @@ class Model(object):
return result return result
def to_str(self): def to_str(self):
""" """Returns the string representation of the model
Returns the string representation of the model
:rtype: str :rtype: str
""" """
return pformat(self.to_dict()) return pprint.pformat(self.to_dict())
def __repr__(self): def __repr__(self):
""" """For `print` and `pprint`"""
For `print` and `pprint`
"""
return self.to_str() return self.to_str()
def __eq__(self, other): def __eq__(self, other):
""" """Returns true if both objects are equal"""
Returns true if both objects are equal
"""
return self.__dict__ == other.__dict__ return self.__dict__ == other.__dict__
def __ne__(self, other): def __ne__(self, other):
""" """Returns true if both objects are not equal"""
Returns true if both objects are not equal return not self == other
"""
return not self == other

View File

@ -1,18 +1,18 @@
import connexion import connexion
{{#imports}}{{import}} import six
{{#imports}}{{import}} # noqa: E501
{{/imports}} {{/imports}}
from datetime import date, datetime from {{packageName}} import util
from typing import List, Dict
from six import iteritems
from ..util import deserialize_date, deserialize_datetime
{{#operations}} {{#operations}}
{{#operation}} {{#operation}}
def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): # noqa: E501
""" """{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}}
{{#summary}}{{.}}{{/summary}}{{^summary}}{{operationId}}{{/summary}}
{{#notes}}{{.}}{{/notes}} {{#notes}}{{.}}{{/notes}} # noqa: E501
{{#allParams}} {{#allParams}}
:param {{paramName}}: {{description}} :param {{paramName}}: {{description}}
{{^isContainer}} {{^isContainer}}
@ -55,15 +55,15 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{
{{#allParams}} {{#allParams}}
{{^isContainer}} {{^isContainer}}
{{#isDate}} {{#isDate}}
{{paramName}} = deserialize_date({{paramName}}) {{paramName}} = util.deserialize_date({{paramName}})
{{/isDate}} {{/isDate}}
{{#isDateTime}} {{#isDateTime}}
{{paramName}} = deserialize_datetime({{paramName}}) {{paramName}} = util.deserialize_datetime({{paramName}})
{{/isDateTime}} {{/isDateTime}}
{{^isPrimitiveType}} {{^isPrimitiveType}}
{{^isFile}} {{^isFile}}
if connexion.request.is_json: if connexion.request.is_json:
{{paramName}} = {{baseType}}.from_dict(connexion.request.get_json()) {{paramName}} = {{baseType}}.from_dict(connexion.request.get_json()) # noqa: E501
{{/isFile}} {{/isFile}}
{{/isPrimitiveType}} {{/isPrimitiveType}}
{{/isContainer}} {{/isContainer}}
@ -71,15 +71,15 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{
{{#items}} {{#items}}
{{#isDate}} {{#isDate}}
if connexion.request.is_json: if connexion.request.is_json:
{{paramName}} = [deserialize_date(s) for s in connexion.request.get_json()] {{paramName}} = [util.deserialize_date(s) for s in connexion.request.get_json()] # noqa: E501
{{/isDate}} {{/isDate}}
{{#isDateTime}} {{#isDateTime}}
if connexion.request.is_json: if connexion.request.is_json:
{{paramName}} = [deserialize_datetime(s) for s in connexion.request.get_json()] {{paramName}} = [util.deserialize_datetime(s) for s in connexion.request.get_json()] # noqa: E501
{{/isDateTime}} {{/isDateTime}}
{{#complexType}} {{#complexType}}
if connexion.request.is_json: if connexion.request.is_json:
{{paramName}} = [{{complexType}}.from_dict(d) for d in connexion.request.get_json()] {{paramName}} = [{{complexType}}.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
{{/complexType}} {{/complexType}}
{{/items}} {{/items}}
{{/isListContainer}} {{/isListContainer}}
@ -87,15 +87,15 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{
{{#items}} {{#items}}
{{#isDate}} {{#isDate}}
if connexion.request.is_json: if connexion.request.is_json:
{{paramName}} = {k: deserialize_date(v) for k, v in iteritems(connexion.request.get_json())} {{paramName}} = {k: util.deserialize_date(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{/isDate}} {{/isDate}}
{{#isDateTime}} {{#isDateTime}}
if connexion.request.is_json: if connexion.request.is_json:
{{paramName}} = {k: deserialize_datetime(v) for k, v in iteritems(connexion.request.get_json())} {{paramName}} = {k: util.deserialize_datetime(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{/isDateTime}} {{/isDateTime}}
{{#complexType}} {{#complexType}}
if connexion.request.is_json: if connexion.request.is_json:
{{paramName}} = {k: {{baseType}}.from_dict(v) for k, v in iteritems(connexion.request.get_json())} {{paramName}} = {k: {{baseType}}.from_dict(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{/complexType}} {{/complexType}}
{{/items}} {{/items}}
{{/isMapContainer}} {{/isMapContainer}}

View File

@ -2,20 +2,20 @@
from __future__ import absolute_import from __future__ import absolute_import
{{#imports}}{{import}}
{{/imports}}
from . import BaseTestCase
from six import BytesIO
from flask import json from flask import json
from six import BytesIO
{{#imports}}{{import}} # noqa: E501
{{/imports}}
from {{packageName}}.test import BaseTestCase
class {{#operations}}Test{{classname}}(BaseTestCase): class {{#operations}}Test{{classname}}(BaseTestCase):
""" {{classname}} integration test stubs """ """{{classname}} integration test stubs"""
{{#operation}} {{#operation}}
def test_{{operationId}}(self): def test_{{operationId}}(self):
""" """Test case for {{{operationId}}}
Test case for {{{operationId}}}
{{{summary}}} {{{summary}}}
""" """
@ -31,15 +31,17 @@ class {{#operations}}Test{{classname}}(BaseTestCase):
{{#formParams}} {{#formParams}}
{{#-first}}data = dict({{/-first}}{{^-first}} {{/-first}}{{paramName}}={{{example}}}{{#hasMore}},{{/hasMore}}{{#-last}}){{/-last}} {{#-first}}data = dict({{/-first}}{{^-first}} {{/-first}}{{paramName}}={{{example}}}{{#hasMore}},{{/hasMore}}{{#-last}}){{/-last}}
{{/formParams}} {{/formParams}}
response = self.client.open('{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}={{{example}}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}}, response = self.client.open(
method='{{httpMethod}}'{{#bodyParam}}, '{{#contextPath}}{{{.}}}{{/contextPath}}{{{path}}}'{{#pathParams}}{{#-first}}.format({{/-first}}{{paramName}}={{{example}}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}){{/hasMore}}{{/pathParams}},
data=json.dumps({{paramName}}){{^consumes}}, method='{{httpMethod}}'{{#bodyParam}},
content_type='application/json'{{/consumes}}{{/bodyParam}}{{#headerParams}}{{#-first}}, data=json.dumps({{paramName}}){{^consumes}},
headers=headers{{/-first}}{{/headerParams}}{{#formParams}}{{#-first}}, content_type='application/json'{{/consumes}}{{/bodyParam}}{{#headerParams}}{{#-first}},
data=data{{/-first}}{{/formParams}}{{#consumes}}{{#-first}}, headers=headers{{/-first}}{{/headerParams}}{{#formParams}}{{#-first}},
content_type='{{{mediaType}}}'{{/-first}}{{/consumes}}{{#queryParams}}{{#-first}}, data=data{{/-first}}{{/formParams}}{{#consumes}}{{#-first}},
query_string=query_string{{/-first}}{{/queryParams}}) content_type='{{{mediaType}}}'{{/-first}}{{/consumes}}{{#queryParams}}{{#-first}},
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) query_string=query_string{{/-first}}{{/queryParams}})
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
{{/operation}} {{/operation}}
{{/operations}} {{/operations}}

View File

@ -1,6 +1,8 @@
from six import iteritems
from {{modelPackage}}.base_model_ import Model
from connexion.apps.flask_app import FlaskJSONEncoder from connexion.apps.flask_app import FlaskJSONEncoder
import six
from {{modelPackage}}.base_model_ import Model
class JSONEncoder(FlaskJSONEncoder): class JSONEncoder(FlaskJSONEncoder):
include_nulls = False include_nulls = False
@ -8,11 +10,11 @@ class JSONEncoder(FlaskJSONEncoder):
def default(self, o): def default(self, o):
if isinstance(o, Model): if isinstance(o, Model):
dikt = {} dikt = {}
for attr, _ in iteritems(o.swagger_types): for attr, _ in six.iteritems(o.swagger_types):
value = getattr(o, attr) value = getattr(o, attr)
if value is None and not self.include_nulls: if value is None and not self.include_nulls:
continue continue
attr = o.attribute_map[attr] attr = o.attribute_map[attr]
dikt[attr] = value dikt[attr] = value
return dikt return dikt
return FlaskJSONEncoder.default(self, o) return FlaskJSONEncoder.default(self, o)

View File

@ -1,73 +1,74 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
{{#imports}}{{import}} from datetime import date, datetime # noqa: F401
from typing import List, Dict # noqa: F401
from {{modelPackage}}.base_model_ import Model
{{#imports}}{{import}} # noqa: E501
{{/imports}} {{/imports}}
from .base_model_ import Model from {{packageName}} import util
from datetime import date, datetime
from typing import List, Dict
from ..util import deserialize_model
{{#models}} {{#models}}
{{#model}} {{#model}}
class {{classname}}(Model): class {{classname}}(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """{{#allowableValues}}
{{#allowableValues}}
""" """
allowed enum values allowed enum values
""" """
{{#enumVars}} {{#enumVars}}
{{name}} = {{{value}}} {{name}} = {{{value}}}{{^-last}}
{{/enumVars}} {{/-last}}
{{/allowableValues}} {{/enumVars}}{{/allowableValues}}
def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
""" """{{classname}} - a model defined in Swagger
{{classname}} - a model defined in Swagger
{{#vars}} {{#vars}}
:param {{name}}: The {{name}} of this {{classname}}. :param {{name}}: The {{name}} of this {{classname}}. # noqa: E501
:type {{name}}: {{datatype}} :type {{name}}: {{datatype}}
{{/vars}} {{/vars}}
""" """
self.swagger_types = { self.swagger_types = {
{{#vars}}'{{name}}': {{{datatype}}}{{#hasMore}}, {{#vars}}
{{/hasMore}}{{/vars}} '{{name}}': {{{datatype}}}{{#hasMore}},{{/hasMore}}
{{/vars}}
} }
self.attribute_map = { self.attribute_map = {
{{#vars}}'{{name}}': '{{baseName}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
}
{{#vars}} {{#vars}}
'{{name}}': '{{baseName}}'{{#hasMore}},{{/hasMore}}
{{/vars}}
}
{{#vars}}{{#-first}}
{{/-first}}
self._{{name}} = {{name}} self._{{name}} = {{name}}
{{/vars}} {{/vars}}
@classmethod @classmethod
def from_dict(cls, dikt){{^supportPython2}} -> '{{classname}}'{{/supportPython2}}: def from_dict(cls, dikt){{^supportPython2}} -> '{{classname}}'{{/supportPython2}}:
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The {{name}} of this {{classname}}. :return: The {{name}} of this {{classname}}. # noqa: E501
:rtype: {{classname}} :rtype: {{classname}}
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls){{#vars}}{{#-first}}
{{#vars}}{{#-first}}
{{/-first}} {{/-first}}
@property @property
def {{name}}(self){{^supportPython2}} -> {{datatype}}{{/supportPython2}}: def {{name}}(self){{^supportPython2}} -> {{datatype}}{{/supportPython2}}:
""" """Gets the {{name}} of this {{classname}}.
Gets the {{name}} of this {{classname}}.
{{#description}} {{#description}}
{{{description}}} {{{description}}} # noqa: E501
{{/description}} {{/description}}
:return: The {{name}} of this {{classname}}. :return: The {{name}} of this {{classname}}.
@ -77,31 +78,31 @@ class {{classname}}(Model):
@{{name}}.setter @{{name}}.setter
def {{name}}(self, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}): def {{name}}(self, {{name}}{{^supportPython2}}: {{datatype}}{{/supportPython2}}):
""" """Sets the {{name}} of this {{classname}}.
Sets the {{name}} of this {{classname}}.
{{#description}} {{#description}}
{{{description}}} {{{description}}} # noqa: E501
{{/description}} {{/description}}
:param {{name}}: The {{name}} of this {{classname}}. :param {{name}}: The {{name}} of this {{classname}}.
:type {{name}}: {{datatype}} :type {{name}}: {{datatype}}
""" """
{{#isEnum}} {{#isEnum}}
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] # noqa: E501
{{#isContainer}} {{#isContainer}}
{{#isListContainer}} {{#isListContainer}}
if not set({{{name}}}).issubset(set(allowed_values)): if not set({{{name}}}).issubset(set(allowed_values)):
raise ValueError( raise ValueError(
"Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" "Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501
.format(", ".join(map(str, set({{{name}}})-set(allowed_values))), .format(", ".join(map(str, set({{{name}}})-set(allowed_values))), # noqa: E501
", ".join(map(str, allowed_values))) ", ".join(map(str, allowed_values)))
) )
{{/isListContainer}} {{/isListContainer}}
{{#isMapContainer}} {{#isMapContainer}}
if not set({{{name}}}.keys()).issubset(set(allowed_values)): if not set({{{name}}}.keys()).issubset(set(allowed_values)):
raise ValueError( raise ValueError(
"Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" "Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]" # noqa: E501
.format(", ".join(map(str, set({{{name}}}.keys())-set(allowed_values))), .format(", ".join(map(str, set({{{name}}}.keys())-set(allowed_values))), # noqa: E501
", ".join(map(str, allowed_values))) ", ".join(map(str, allowed_values)))
) )
{{/isMapContainer}} {{/isMapContainer}}
@ -117,42 +118,44 @@ class {{classname}}(Model):
{{^isEnum}} {{^isEnum}}
{{#required}} {{#required}}
if {{name}} is None: if {{name}} is None:
raise ValueError("Invalid value for `{{name}}`, must not be `None`") raise ValueError("Invalid value for `{{name}}`, must not be `None`") # noqa: E501
{{/required}} {{/required}}
{{#hasValidation}} {{#hasValidation}}
{{#maxLength}} {{#maxLength}}
if {{name}} is not None and len({{name}}) > {{maxLength}}: if {{name}} is not None and len({{name}}) > {{maxLength}}:
raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`") # noqa: E501
{{/maxLength}} {{/maxLength}}
{{#minLength}} {{#minLength}}
if {{name}} is not None and len({{name}}) < {{minLength}}: if {{name}} is not None and len({{name}}) < {{minLength}}:
raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`") # noqa: E501
{{/minLength}} {{/minLength}}
{{#maximum}} {{#maximum}}
if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: if {{name}} is not None and {{name}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}: # noqa: E501
raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") raise ValueError("Invalid value for `{{name}}`, must be a value less than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}`{{maximum}}`") # noqa: E501
{{/maximum}} {{/maximum}}
{{#minimum}} {{#minimum}}
if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: if {{name}} is not None and {{name}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}: # noqa: E501
raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") raise ValueError("Invalid value for `{{name}}`, must be a value greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}`{{minimum}}`") # noqa: E501
{{/minimum}} {{/minimum}}
{{#pattern}} {{#pattern}}
if {{name}} is not None and not re.search('{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): if {{name}} is not None and not re.search('{{{vendorExtensions.x-regex}}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}): # noqa: E501
raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{{pattern}}}`") # noqa: E501
{{/pattern}} {{/pattern}}
{{#maxItems}} {{#maxItems}}
if {{name}} is not None and len({{name}}) > {{maxItems}}: if {{name}} is not None and len({{name}}) > {{maxItems}}:
raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") raise ValueError("Invalid value for `{{name}}`, number of items must be less than or equal to `{{maxItems}}`") # noqa: E501
{{/maxItems}} {{/maxItems}}
{{#minItems}} {{#minItems}}
if {{name}} is not None and len({{name}}) < {{minItems}}: if {{name}} is not None and len({{name}}) < {{minItems}}:
raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") raise ValueError("Invalid value for `{{name}}`, number of items must be greater than or equal to `{{minItems}}`") # noqa: E501
{{/minItems}} {{/minItems}}
{{/hasValidation}} {{/hasValidation}}
{{/isEnum}} {{/isEnum}}
self._{{name}} = {{name}} self._{{name}} = {{name}}{{^-last}}
{{/-last}}
{{/vars}} {{/vars}}
{{/model}} {{/model}}
{{/models}} {{/models}}

View File

@ -1,11 +1,11 @@
from typing import GenericMeta import datetime
from datetime import datetime, date
from six import integer_types, iteritems import six
import typing
def _deserialize(data, klass): def _deserialize(data, klass):
""" """Deserializes dict, list, str into an object.
Deserializes dict, list, str into an object.
:param data: dict, list or str. :param data: dict, list or str.
:param klass: class literal, or string of class name. :param klass: class literal, or string of class name.
@ -15,15 +15,15 @@ def _deserialize(data, klass):
if data is None: if data is None:
return None return None
if klass in integer_types or klass in (float, str, bool): if klass in six.integer_types or klass in (float, str, bool):
return _deserialize_primitive(data, klass) return _deserialize_primitive(data, klass)
elif klass == object: elif klass == object:
return _deserialize_object(data) return _deserialize_object(data)
elif klass == date: elif klass == datetime.date:
return deserialize_date(data) return deserialize_date(data)
elif klass == datetime: elif klass == datetime.datetime:
return deserialize_datetime(data) return deserialize_datetime(data)
elif type(klass) == GenericMeta: elif type(klass) == typing.GenericMeta:
if klass.__extra__ == list: if klass.__extra__ == list:
return _deserialize_list(data, klass.__args__[0]) return _deserialize_list(data, klass.__args__[0])
if klass.__extra__ == dict: if klass.__extra__ == dict:
@ -33,8 +33,7 @@ def _deserialize(data, klass):
def _deserialize_primitive(data, klass): def _deserialize_primitive(data, klass):
""" """Deserializes to primitive type.
Deserializes to primitive type.
:param data: data to deserialize. :param data: data to deserialize.
:param klass: class literal. :param klass: class literal.
@ -52,8 +51,7 @@ def _deserialize_primitive(data, klass):
def _deserialize_object(value): def _deserialize_object(value):
""" """Return a original value.
Return a original value.
:return: object. :return: object.
""" """
@ -61,8 +59,7 @@ def _deserialize_object(value):
def deserialize_date(string): def deserialize_date(string):
""" """Deserializes string to date.
Deserializes string to date.
:param string: str. :param string: str.
:type string: str :type string: str
@ -77,8 +74,7 @@ def deserialize_date(string):
def deserialize_datetime(string): def deserialize_datetime(string):
""" """Deserializes string to datetime.
Deserializes string to datetime.
The string should be in iso8601 datetime format. The string should be in iso8601 datetime format.
@ -95,8 +91,7 @@ def deserialize_datetime(string):
def deserialize_model(data, klass): def deserialize_model(data, klass):
""" """Deserializes list or dict to model.
Deserializes list or dict to model.
:param data: dict, list. :param data: dict, list.
:type data: dict | list :type data: dict | list
@ -108,7 +103,7 @@ def deserialize_model(data, klass):
if not instance.swagger_types: if not instance.swagger_types:
return data return data
for attr, attr_type in iteritems(instance.swagger_types): for attr, attr_type in six.iteritems(instance.swagger_types):
if data is not None \ if data is not None \
and instance.attribute_map[attr] in data \ and instance.attribute_map[attr] in data \
and isinstance(data, (list, dict)): and isinstance(data, (list, dict)):
@ -119,8 +114,7 @@ def deserialize_model(data, klass):
def _deserialize_list(data, boxed_type): def _deserialize_list(data, boxed_type):
""" """Deserializes a list and its elements.
Deserializes a list and its elements.
:param data: list to deserialize. :param data: list to deserialize.
:type data: list :type data: list
@ -133,10 +127,8 @@ def _deserialize_list(data, boxed_type):
for sub_data in data] for sub_data in data]
def _deserialize_dict(data, boxed_type): def _deserialize_dict(data, boxed_type):
""" """Deserializes a dict and its elements.
Deserializes a dict and its elements.
:param data: dict to deserialize. :param data: dict to deserialize.
:type data: dict :type data: dict
@ -146,4 +138,4 @@ def _deserialize_dict(data, boxed_type):
:rtype: dict :rtype: dict
""" """
return {k: _deserialize(v, boxed_type) return {k: _deserialize(v, boxed_type)
for k, v in iteritems(data)} for k, v in six.iteritems(data)}

View File

@ -1,13 +1,14 @@
#!/usr/bin/env python #!/usr/bin/env python
import connexion import connexion
from .encoder import JSONEncoder
from swagger_server import encoder
def main(): def main():
app = connexion.App(__name__, specification_dir='./swagger/') app = connexion.App(__name__, specification_dir='./swagger/')
app.app.json_encoder = JSONEncoder app.app.json_encoder = encoder.JSONEncoder
app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key &#x60;special-key&#x60; to test the authorization filters.'}) app.add_api('swagger.yaml', arguments={'title': 'Swagger Petstore'})
app.run(port=8080) app.run(port=8080)

View File

@ -1,30 +1,31 @@
import connexion import connexion
from swagger_server.models.api_response import ApiResponse import six
from swagger_server.models.pet import Pet
from datetime import date, datetime from swagger_server.models.api_response import ApiResponse # noqa: E501
from typing import List, Dict from swagger_server.models.pet import Pet # noqa: E501
from six import iteritems from swagger_server import util
from ..util import deserialize_date, deserialize_datetime
def add_pet(body): def add_pet(body): # noqa: E501
""" """Add a new pet to the store
Add a new pet to the store
# noqa: E501
:param body: Pet object that needs to be added to the store :param body: Pet object that needs to be added to the store
:type body: dict | bytes :type body: dict | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = Pet.from_dict(connexion.request.get_json()) body = Pet.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'
def delete_pet(petId, api_key=None): def delete_pet(petId, api_key=None): # noqa: E501
""" """Deletes a pet
Deletes a pet
# noqa: E501
:param petId: Pet id to delete :param petId: Pet id to delete
:type petId: int :type petId: int
:param api_key: :param api_key:
@ -35,10 +36,11 @@ def delete_pet(petId, api_key=None):
return 'do some magic!' return 'do some magic!'
def find_pets_by_status(status): def find_pets_by_status(status): # noqa: E501
""" """Finds Pets by status
Finds Pets by status
Multiple status values can be provided with comma separated strings Multiple status values can be provided with comma separated strings # noqa: E501
:param status: Status values that need to be considered for filter :param status: Status values that need to be considered for filter
:type status: List[str] :type status: List[str]
@ -47,10 +49,11 @@ def find_pets_by_status(status):
return 'do some magic!' return 'do some magic!'
def find_pets_by_tags(tags): def find_pets_by_tags(tags): # noqa: E501
""" """Finds Pets by tags
Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501
:param tags: Tags to filter by :param tags: Tags to filter by
:type tags: List[str] :type tags: List[str]
@ -59,10 +62,11 @@ def find_pets_by_tags(tags):
return 'do some magic!' return 'do some magic!'
def get_pet_by_id(petId): def get_pet_by_id(petId): # noqa: E501
""" """Find pet by ID
Find pet by ID
Returns a single pet Returns a single pet # noqa: E501
:param petId: ID of pet to return :param petId: ID of pet to return
:type petId: int :type petId: int
@ -71,24 +75,26 @@ def get_pet_by_id(petId):
return 'do some magic!' return 'do some magic!'
def update_pet(body): def update_pet(body): # noqa: E501
""" """Update an existing pet
Update an existing pet
# noqa: E501
:param body: Pet object that needs to be added to the store :param body: Pet object that needs to be added to the store
:type body: dict | bytes :type body: dict | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = Pet.from_dict(connexion.request.get_json()) body = Pet.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'
def update_pet_with_form(petId, name=None, status=None): def update_pet_with_form(petId, name=None, status=None): # noqa: E501
""" """Updates a pet in the store with form data
Updates a pet in the store with form data
# noqa: E501
:param petId: ID of pet that needs to be updated :param petId: ID of pet that needs to be updated
:type petId: int :type petId: int
:param name: Updated name of the pet :param name: Updated name of the pet
@ -101,10 +107,11 @@ def update_pet_with_form(petId, name=None, status=None):
return 'do some magic!' return 'do some magic!'
def upload_file(petId, additionalMetadata=None, file=None): def upload_file(petId, additionalMetadata=None, file=None): # noqa: E501
""" """uploads an image
uploads an image
# noqa: E501
:param petId: ID of pet to update :param petId: ID of pet to update
:type petId: int :type petId: int
:param additionalMetadata: Additional data to pass to server :param additionalMetadata: Additional data to pass to server

View File

@ -1,15 +1,15 @@
import connexion import connexion
from swagger_server.models.order import Order import six
from datetime import date, datetime
from typing import List, Dict from swagger_server.models.order import Order # noqa: E501
from six import iteritems from swagger_server import util
from ..util import deserialize_date, deserialize_datetime
def delete_order(orderId): def delete_order(orderId): # noqa: E501
""" """Delete purchase order by ID
Delete purchase order by ID
For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501
:param orderId: ID of the order that needs to be deleted :param orderId: ID of the order that needs to be deleted
:type orderId: str :type orderId: str
@ -18,20 +18,22 @@ def delete_order(orderId):
return 'do some magic!' return 'do some magic!'
def get_inventory(): def get_inventory(): # noqa: E501
""" """Returns pet inventories by status
Returns pet inventories by status
Returns a map of status codes to quantities Returns a map of status codes to quantities # noqa: E501
:rtype: Dict[str, int] :rtype: Dict[str, int]
""" """
return 'do some magic!' return 'do some magic!'
def get_order_by_id(orderId): def get_order_by_id(orderId): # noqa: E501
""" """Find purchase order by ID
Find purchase order by ID
For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions # noqa: E501
:param orderId: ID of pet that needs to be fetched :param orderId: ID of pet that needs to be fetched
:type orderId: int :type orderId: int
@ -40,15 +42,16 @@ def get_order_by_id(orderId):
return 'do some magic!' return 'do some magic!'
def place_order(body): def place_order(body): # noqa: E501
""" """Place an order for a pet
Place an order for a pet
# noqa: E501
:param body: order placed for purchasing the pet :param body: order placed for purchasing the pet
:type body: dict | bytes :type body: dict | bytes
:rtype: Order :rtype: Order
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = Order.from_dict(connexion.request.get_json()) body = Order.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'

View File

@ -1,57 +1,60 @@
import connexion import connexion
from swagger_server.models.user import User import six
from datetime import date, datetime
from typing import List, Dict from swagger_server.models.user import User # noqa: E501
from six import iteritems from swagger_server import util
from ..util import deserialize_date, deserialize_datetime
def create_user(body): def create_user(body): # noqa: E501
""" """Create user
Create user
This can only be done by the logged in user. This can only be done by the logged in user. # noqa: E501
:param body: Created user object :param body: Created user object
:type body: dict | bytes :type body: dict | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = User.from_dict(connexion.request.get_json()) body = User.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'
def create_users_with_array_input(body): def create_users_with_array_input(body): # noqa: E501
""" """Creates list of users with given input array
Creates list of users with given input array
# noqa: E501
:param body: List of user object :param body: List of user object
:type body: list | bytes :type body: list | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = [User.from_dict(d) for d in connexion.request.get_json()] body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
return 'do some magic!' return 'do some magic!'
def create_users_with_list_input(body): def create_users_with_list_input(body): # noqa: E501
""" """Creates list of users with given input array
Creates list of users with given input array
# noqa: E501
:param body: List of user object :param body: List of user object
:type body: list | bytes :type body: list | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = [User.from_dict(d) for d in connexion.request.get_json()] body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
return 'do some magic!' return 'do some magic!'
def delete_user(username): def delete_user(username): # noqa: E501
""" """Delete user
Delete user
This can only be done by the logged in user. This can only be done by the logged in user. # noqa: E501
:param username: The name that needs to be deleted :param username: The name that needs to be deleted
:type username: str :type username: str
@ -60,10 +63,11 @@ def delete_user(username):
return 'do some magic!' return 'do some magic!'
def get_user_by_name(username): def get_user_by_name(username): # noqa: E501
""" """Get user by user name
Get user by user name
# noqa: E501
:param username: The name that needs to be fetched. Use user1 for testing. :param username: The name that needs to be fetched. Use user1 for testing.
:type username: str :type username: str
@ -72,10 +76,11 @@ def get_user_by_name(username):
return 'do some magic!' return 'do some magic!'
def login_user(username, password): def login_user(username, password): # noqa: E501
""" """Logs user into the system
Logs user into the system
# noqa: E501
:param username: The user name for login :param username: The user name for login
:type username: str :type username: str
:param password: The password for login in clear text :param password: The password for login in clear text
@ -86,20 +91,22 @@ def login_user(username, password):
return 'do some magic!' return 'do some magic!'
def logout_user(): def logout_user(): # noqa: E501
""" """Logs out current logged in user session
Logs out current logged in user session
# noqa: E501
:rtype: None :rtype: None
""" """
return 'do some magic!' return 'do some magic!'
def update_user(username, body): def update_user(username, body): # noqa: E501
""" """Updated user
Updated user
This can only be done by the logged in user. This can only be done by the logged in user. # noqa: E501
:param username: name that need to be deleted :param username: name that need to be deleted
:type username: str :type username: str
:param body: Updated user object :param body: Updated user object
@ -108,5 +115,5 @@ def update_user(username, body):
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = User.from_dict(connexion.request.get_json()) body = User.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'

View File

@ -1,6 +1,8 @@
from six import iteritems
from swagger_server.models.base_model_ import Model
from connexion.apps.flask_app import FlaskJSONEncoder from connexion.apps.flask_app import FlaskJSONEncoder
import six
from swagger_server.models.base_model_ import Model
class JSONEncoder(FlaskJSONEncoder): class JSONEncoder(FlaskJSONEncoder):
include_nulls = False include_nulls = False
@ -8,11 +10,11 @@ class JSONEncoder(FlaskJSONEncoder):
def default(self, o): def default(self, o):
if isinstance(o, Model): if isinstance(o, Model):
dikt = {} dikt = {}
for attr, _ in iteritems(o.swagger_types): for attr, _ in six.iteritems(o.swagger_types):
value = getattr(o, attr) value = getattr(o, attr)
if value is None and not self.include_nulls: if value is None and not self.include_nulls:
continue continue
attr = o.attribute_map[attr] attr = o.attribute_map[attr]
dikt[attr] = value dikt[attr] = value
return dikt return dikt
return FlaskJSONEncoder.default(self, o) return FlaskJSONEncoder.default(self, o)

View File

@ -1,10 +1,11 @@
# coding: utf-8 # coding: utf-8
# flake8: noqa
from __future__ import absolute_import from __future__ import absolute_import
# import models into model package # import models into model package
from .api_response import ApiResponse from swagger_server.models.api_response import ApiResponse
from .category import Category from swagger_server.models.category import Category
from .order import Order from swagger_server.models.order import Order
from .pet import Pet from swagger_server.models.pet import Pet
from .tag import Tag from swagger_server.models.tag import Tag
from .user import User from swagger_server.models.user import User

View File

@ -1,28 +1,28 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class ApiResponse(Model): class ApiResponse(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, code=None, type=None, message=None): # noqa: E501
"""ApiResponse - a model defined in Swagger
def __init__(self, code=None, type=None, message=None): :param code: The code of this ApiResponse. # noqa: E501
"""
ApiResponse - a model defined in Swagger
:param code: The code of this ApiResponse.
:type code: int :type code: int
:param type: The type of this ApiResponse. :param type: The type of this ApiResponse. # noqa: E501
:type type: str :type type: str
:param message: The message of this ApiResponse. :param message: The message of this ApiResponse. # noqa: E501
:type message: str :type message: str
""" """
self.swagger_types = { self.swagger_types = {
@ -43,20 +43,19 @@ class ApiResponse(Model):
@classmethod @classmethod
def from_dict(cls, dikt): def from_dict(cls, dikt):
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The ApiResponse of this ApiResponse. :return: The ApiResponse of this ApiResponse. # noqa: E501
:rtype: ApiResponse :rtype: ApiResponse
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def code(self): def code(self):
""" """Gets the code of this ApiResponse.
Gets the code of this ApiResponse.
:return: The code of this ApiResponse. :return: The code of this ApiResponse.
:rtype: int :rtype: int
@ -65,8 +64,8 @@ class ApiResponse(Model):
@code.setter @code.setter
def code(self, code): def code(self, code):
""" """Sets the code of this ApiResponse.
Sets the code of this ApiResponse.
:param code: The code of this ApiResponse. :param code: The code of this ApiResponse.
:type code: int :type code: int
@ -76,8 +75,8 @@ class ApiResponse(Model):
@property @property
def type(self): def type(self):
""" """Gets the type of this ApiResponse.
Gets the type of this ApiResponse.
:return: The type of this ApiResponse. :return: The type of this ApiResponse.
:rtype: str :rtype: str
@ -86,8 +85,8 @@ class ApiResponse(Model):
@type.setter @type.setter
def type(self, type): def type(self, type):
""" """Sets the type of this ApiResponse.
Sets the type of this ApiResponse.
:param type: The type of this ApiResponse. :param type: The type of this ApiResponse.
:type type: str :type type: str
@ -97,8 +96,8 @@ class ApiResponse(Model):
@property @property
def message(self): def message(self):
""" """Gets the message of this ApiResponse.
Gets the message of this ApiResponse.
:return: The message of this ApiResponse. :return: The message of this ApiResponse.
:rtype: str :rtype: str
@ -107,12 +106,11 @@ class ApiResponse(Model):
@message.setter @message.setter
def message(self, message): def message(self, message):
""" """Sets the message of this ApiResponse.
Sets the message of this ApiResponse.
:param message: The message of this ApiResponse. :param message: The message of this ApiResponse.
:type message: str :type message: str
""" """
self._message = message self._message = message

View File

@ -1,31 +1,32 @@
from pprint import pformat import pprint
from six import iteritems
from ..util import deserialize_model import six
from swagger_server import util
class Model(object): class Model(object):
# swaggerTypes: The key is attribute name and the value is attribute type. # swaggerTypes: The key is attribute name and the
# value is attribute type.
swagger_types = {} swagger_types = {}
# attributeMap: The key is attribute name and the value is json key in definition. # attributeMap: The key is attribute name and the
# value is json key in definition.
attribute_map = {} attribute_map = {}
@classmethod @classmethod
def from_dict(cls, dikt): def from_dict(cls, dikt):
""" """Returns the dict as a model"""
Returns the dict as a model return util.deserialize_model(dikt, cls)
"""
return deserialize_model(dikt, cls)
def to_dict(self): def to_dict(self):
""" """Returns the model properties as a dict
Returns the model properties as a dict
:rtype: dict :rtype: dict
""" """
result = {} result = {}
for attr, _ in iteritems(self.swagger_types): for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr) value = getattr(self, attr)
if isinstance(value, list): if isinstance(value, list):
result[attr] = list(map( result[attr] = list(map(
@ -46,27 +47,20 @@ class Model(object):
return result return result
def to_str(self): def to_str(self):
""" """Returns the string representation of the model
Returns the string representation of the model
:rtype: str :rtype: str
""" """
return pformat(self.to_dict()) return pprint.pformat(self.to_dict())
def __repr__(self): def __repr__(self):
""" """For `print` and `pprint`"""
For `print` and `pprint`
"""
return self.to_str() return self.to_str()
def __eq__(self, other): def __eq__(self, other):
""" """Returns true if both objects are equal"""
Returns true if both objects are equal
"""
return self.__dict__ == other.__dict__ return self.__dict__ == other.__dict__
def __ne__(self, other): def __ne__(self, other):
""" """Returns true if both objects are not equal"""
Returns true if both objects are not equal return not self == other
"""
return not self == other

View File

@ -1,26 +1,26 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class Category(Model): class Category(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id=None, name=None): # noqa: E501
"""Category - a model defined in Swagger
def __init__(self, id=None, name=None): :param id: The id of this Category. # noqa: E501
"""
Category - a model defined in Swagger
:param id: The id of this Category.
:type id: long :type id: long
:param name: The name of this Category. :param name: The name of this Category. # noqa: E501
:type name: str :type name: str
""" """
self.swagger_types = { self.swagger_types = {
@ -38,20 +38,19 @@ class Category(Model):
@classmethod @classmethod
def from_dict(cls, dikt): def from_dict(cls, dikt):
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The Category of this Category. :return: The Category of this Category. # noqa: E501
:rtype: Category :rtype: Category
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self): def id(self):
""" """Gets the id of this Category.
Gets the id of this Category.
:return: The id of this Category. :return: The id of this Category.
:rtype: long :rtype: long
@ -60,8 +59,8 @@ class Category(Model):
@id.setter @id.setter
def id(self, id): def id(self, id):
""" """Sets the id of this Category.
Sets the id of this Category.
:param id: The id of this Category. :param id: The id of this Category.
:type id: long :type id: long
@ -71,8 +70,8 @@ class Category(Model):
@property @property
def name(self): def name(self):
""" """Gets the name of this Category.
Gets the name of this Category.
:return: The name of this Category. :return: The name of this Category.
:rtype: str :rtype: str
@ -81,12 +80,11 @@ class Category(Model):
@name.setter @name.setter
def name(self, name): def name(self, name):
""" """Sets the name of this Category.
Sets the name of this Category.
:param name: The name of this Category. :param name: The name of this Category.
:type name: str :type name: str
""" """
self._name = name self._name = name

View File

@ -1,34 +1,34 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class Order(Model): class Order(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False): # noqa: E501
"""Order - a model defined in Swagger
def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False): :param id: The id of this Order. # noqa: E501
"""
Order - a model defined in Swagger
:param id: The id of this Order.
:type id: long :type id: long
:param pet_id: The pet_id of this Order. :param pet_id: The pet_id of this Order. # noqa: E501
:type pet_id: long :type pet_id: long
:param quantity: The quantity of this Order. :param quantity: The quantity of this Order. # noqa: E501
:type quantity: int :type quantity: int
:param ship_date: The ship_date of this Order. :param ship_date: The ship_date of this Order. # noqa: E501
:type ship_date: datetime :type ship_date: datetime
:param status: The status of this Order. :param status: The status of this Order. # noqa: E501
:type status: str :type status: str
:param complete: The complete of this Order. :param complete: The complete of this Order. # noqa: E501
:type complete: bool :type complete: bool
""" """
self.swagger_types = { self.swagger_types = {
@ -58,20 +58,19 @@ class Order(Model):
@classmethod @classmethod
def from_dict(cls, dikt): def from_dict(cls, dikt):
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The Order of this Order. :return: The Order of this Order. # noqa: E501
:rtype: Order :rtype: Order
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self): def id(self):
""" """Gets the id of this Order.
Gets the id of this Order.
:return: The id of this Order. :return: The id of this Order.
:rtype: long :rtype: long
@ -80,8 +79,8 @@ class Order(Model):
@id.setter @id.setter
def id(self, id): def id(self, id):
""" """Sets the id of this Order.
Sets the id of this Order.
:param id: The id of this Order. :param id: The id of this Order.
:type id: long :type id: long
@ -91,8 +90,8 @@ class Order(Model):
@property @property
def pet_id(self): def pet_id(self):
""" """Gets the pet_id of this Order.
Gets the pet_id of this Order.
:return: The pet_id of this Order. :return: The pet_id of this Order.
:rtype: long :rtype: long
@ -101,8 +100,8 @@ class Order(Model):
@pet_id.setter @pet_id.setter
def pet_id(self, pet_id): def pet_id(self, pet_id):
""" """Sets the pet_id of this Order.
Sets the pet_id of this Order.
:param pet_id: The pet_id of this Order. :param pet_id: The pet_id of this Order.
:type pet_id: long :type pet_id: long
@ -112,8 +111,8 @@ class Order(Model):
@property @property
def quantity(self): def quantity(self):
""" """Gets the quantity of this Order.
Gets the quantity of this Order.
:return: The quantity of this Order. :return: The quantity of this Order.
:rtype: int :rtype: int
@ -122,8 +121,8 @@ class Order(Model):
@quantity.setter @quantity.setter
def quantity(self, quantity): def quantity(self, quantity):
""" """Sets the quantity of this Order.
Sets the quantity of this Order.
:param quantity: The quantity of this Order. :param quantity: The quantity of this Order.
:type quantity: int :type quantity: int
@ -133,8 +132,8 @@ class Order(Model):
@property @property
def ship_date(self): def ship_date(self):
""" """Gets the ship_date of this Order.
Gets the ship_date of this Order.
:return: The ship_date of this Order. :return: The ship_date of this Order.
:rtype: datetime :rtype: datetime
@ -143,8 +142,8 @@ class Order(Model):
@ship_date.setter @ship_date.setter
def ship_date(self, ship_date): def ship_date(self, ship_date):
""" """Sets the ship_date of this Order.
Sets the ship_date of this Order.
:param ship_date: The ship_date of this Order. :param ship_date: The ship_date of this Order.
:type ship_date: datetime :type ship_date: datetime
@ -154,9 +153,9 @@ class Order(Model):
@property @property
def status(self): def status(self):
""" """Gets the status of this Order.
Gets the status of this Order.
Order Status Order Status # noqa: E501
:return: The status of this Order. :return: The status of this Order.
:rtype: str :rtype: str
@ -165,14 +164,14 @@ class Order(Model):
@status.setter @status.setter
def status(self, status): def status(self, status):
""" """Sets the status of this Order.
Sets the status of this Order.
Order Status Order Status # noqa: E501
:param status: The status of this Order. :param status: The status of this Order.
:type status: str :type status: str
""" """
allowed_values = ["placed", "approved", "delivered"] allowed_values = ["placed", "approved", "delivered"] # noqa: E501
if status not in allowed_values: if status not in allowed_values:
raise ValueError( raise ValueError(
"Invalid value for `status` ({0}), must be one of {1}" "Invalid value for `status` ({0}), must be one of {1}"
@ -183,8 +182,8 @@ class Order(Model):
@property @property
def complete(self): def complete(self):
""" """Gets the complete of this Order.
Gets the complete of this Order.
:return: The complete of this Order. :return: The complete of this Order.
:rtype: bool :rtype: bool
@ -193,12 +192,11 @@ class Order(Model):
@complete.setter @complete.setter
def complete(self, complete): def complete(self, complete):
""" """Sets the complete of this Order.
Sets the complete of this Order.
:param complete: The complete of this Order. :param complete: The complete of this Order.
:type complete: bool :type complete: bool
""" """
self._complete = complete self._complete = complete

View File

@ -1,36 +1,36 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from swagger_server.models.category import Category from datetime import date, datetime # noqa: F401
from swagger_server.models.tag import Tag
from .base_model_ import Model from typing import List, Dict # noqa: F401
from datetime import date, datetime
from typing import List, Dict from swagger_server.models.base_model_ import Model
from ..util import deserialize_model from swagger_server.models.category import Category # noqa: E501
from swagger_server.models.tag import Tag # noqa: E501
from swagger_server import util
class Pet(Model): class Pet(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None): # noqa: E501
"""Pet - a model defined in Swagger
def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None): :param id: The id of this Pet. # noqa: E501
"""
Pet - a model defined in Swagger
:param id: The id of this Pet.
:type id: long :type id: long
:param category: The category of this Pet. :param category: The category of this Pet. # noqa: E501
:type category: Category :type category: Category
:param name: The name of this Pet. :param name: The name of this Pet. # noqa: E501
:type name: str :type name: str
:param photo_urls: The photo_urls of this Pet. :param photo_urls: The photo_urls of this Pet. # noqa: E501
:type photo_urls: List[str] :type photo_urls: List[str]
:param tags: The tags of this Pet. :param tags: The tags of this Pet. # noqa: E501
:type tags: List[Tag] :type tags: List[Tag]
:param status: The status of this Pet. :param status: The status of this Pet. # noqa: E501
:type status: str :type status: str
""" """
self.swagger_types = { self.swagger_types = {
@ -60,20 +60,19 @@ class Pet(Model):
@classmethod @classmethod
def from_dict(cls, dikt): def from_dict(cls, dikt):
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The Pet of this Pet. :return: The Pet of this Pet. # noqa: E501
:rtype: Pet :rtype: Pet
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self): def id(self):
""" """Gets the id of this Pet.
Gets the id of this Pet.
:return: The id of this Pet. :return: The id of this Pet.
:rtype: long :rtype: long
@ -82,8 +81,8 @@ class Pet(Model):
@id.setter @id.setter
def id(self, id): def id(self, id):
""" """Sets the id of this Pet.
Sets the id of this Pet.
:param id: The id of this Pet. :param id: The id of this Pet.
:type id: long :type id: long
@ -93,8 +92,8 @@ class Pet(Model):
@property @property
def category(self): def category(self):
""" """Gets the category of this Pet.
Gets the category of this Pet.
:return: The category of this Pet. :return: The category of this Pet.
:rtype: Category :rtype: Category
@ -103,8 +102,8 @@ class Pet(Model):
@category.setter @category.setter
def category(self, category): def category(self, category):
""" """Sets the category of this Pet.
Sets the category of this Pet.
:param category: The category of this Pet. :param category: The category of this Pet.
:type category: Category :type category: Category
@ -114,8 +113,8 @@ class Pet(Model):
@property @property
def name(self): def name(self):
""" """Gets the name of this Pet.
Gets the name of this Pet.
:return: The name of this Pet. :return: The name of this Pet.
:rtype: str :rtype: str
@ -124,21 +123,21 @@ class Pet(Model):
@name.setter @name.setter
def name(self, name): def name(self, name):
""" """Sets the name of this Pet.
Sets the name of this Pet.
:param name: The name of this Pet. :param name: The name of this Pet.
:type name: str :type name: str
""" """
if name is None: if name is None:
raise ValueError("Invalid value for `name`, must not be `None`") raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501
self._name = name self._name = name
@property @property
def photo_urls(self): def photo_urls(self):
""" """Gets the photo_urls of this Pet.
Gets the photo_urls of this Pet.
:return: The photo_urls of this Pet. :return: The photo_urls of this Pet.
:rtype: List[str] :rtype: List[str]
@ -147,21 +146,21 @@ class Pet(Model):
@photo_urls.setter @photo_urls.setter
def photo_urls(self, photo_urls): def photo_urls(self, photo_urls):
""" """Sets the photo_urls of this Pet.
Sets the photo_urls of this Pet.
:param photo_urls: The photo_urls of this Pet. :param photo_urls: The photo_urls of this Pet.
:type photo_urls: List[str] :type photo_urls: List[str]
""" """
if photo_urls is None: if photo_urls is None:
raise ValueError("Invalid value for `photo_urls`, must not be `None`") raise ValueError("Invalid value for `photo_urls`, must not be `None`") # noqa: E501
self._photo_urls = photo_urls self._photo_urls = photo_urls
@property @property
def tags(self): def tags(self):
""" """Gets the tags of this Pet.
Gets the tags of this Pet.
:return: The tags of this Pet. :return: The tags of this Pet.
:rtype: List[Tag] :rtype: List[Tag]
@ -170,8 +169,8 @@ class Pet(Model):
@tags.setter @tags.setter
def tags(self, tags): def tags(self, tags):
""" """Sets the tags of this Pet.
Sets the tags of this Pet.
:param tags: The tags of this Pet. :param tags: The tags of this Pet.
:type tags: List[Tag] :type tags: List[Tag]
@ -181,9 +180,9 @@ class Pet(Model):
@property @property
def status(self): def status(self):
""" """Gets the status of this Pet.
Gets the status of this Pet.
pet status in the store pet status in the store # noqa: E501
:return: The status of this Pet. :return: The status of this Pet.
:rtype: str :rtype: str
@ -192,14 +191,14 @@ class Pet(Model):
@status.setter @status.setter
def status(self, status): def status(self, status):
""" """Sets the status of this Pet.
Sets the status of this Pet.
pet status in the store pet status in the store # noqa: E501
:param status: The status of this Pet. :param status: The status of this Pet.
:type status: str :type status: str
""" """
allowed_values = ["available", "pending", "sold"] allowed_values = ["available", "pending", "sold"] # noqa: E501
if status not in allowed_values: if status not in allowed_values:
raise ValueError( raise ValueError(
"Invalid value for `status` ({0}), must be one of {1}" "Invalid value for `status` ({0}), must be one of {1}"
@ -207,4 +206,3 @@ class Pet(Model):
) )
self._status = status self._status = status

View File

@ -1,26 +1,26 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class Tag(Model): class Tag(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id=None, name=None): # noqa: E501
"""Tag - a model defined in Swagger
def __init__(self, id=None, name=None): :param id: The id of this Tag. # noqa: E501
"""
Tag - a model defined in Swagger
:param id: The id of this Tag.
:type id: long :type id: long
:param name: The name of this Tag. :param name: The name of this Tag. # noqa: E501
:type name: str :type name: str
""" """
self.swagger_types = { self.swagger_types = {
@ -38,20 +38,19 @@ class Tag(Model):
@classmethod @classmethod
def from_dict(cls, dikt): def from_dict(cls, dikt):
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The Tag of this Tag. :return: The Tag of this Tag. # noqa: E501
:rtype: Tag :rtype: Tag
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self): def id(self):
""" """Gets the id of this Tag.
Gets the id of this Tag.
:return: The id of this Tag. :return: The id of this Tag.
:rtype: long :rtype: long
@ -60,8 +59,8 @@ class Tag(Model):
@id.setter @id.setter
def id(self, id): def id(self, id):
""" """Sets the id of this Tag.
Sets the id of this Tag.
:param id: The id of this Tag. :param id: The id of this Tag.
:type id: long :type id: long
@ -71,8 +70,8 @@ class Tag(Model):
@property @property
def name(self): def name(self):
""" """Gets the name of this Tag.
Gets the name of this Tag.
:return: The name of this Tag. :return: The name of this Tag.
:rtype: str :rtype: str
@ -81,12 +80,11 @@ class Tag(Model):
@name.setter @name.setter
def name(self, name): def name(self, name):
""" """Sets the name of this Tag.
Sets the name of this Tag.
:param name: The name of this Tag. :param name: The name of this Tag.
:type name: str :type name: str
""" """
self._name = name self._name = name

View File

@ -1,38 +1,38 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class User(Model): class User(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): # noqa: E501
"""User - a model defined in Swagger
def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): :param id: The id of this User. # noqa: E501
"""
User - a model defined in Swagger
:param id: The id of this User.
:type id: long :type id: long
:param username: The username of this User. :param username: The username of this User. # noqa: E501
:type username: str :type username: str
:param first_name: The first_name of this User. :param first_name: The first_name of this User. # noqa: E501
:type first_name: str :type first_name: str
:param last_name: The last_name of this User. :param last_name: The last_name of this User. # noqa: E501
:type last_name: str :type last_name: str
:param email: The email of this User. :param email: The email of this User. # noqa: E501
:type email: str :type email: str
:param password: The password of this User. :param password: The password of this User. # noqa: E501
:type password: str :type password: str
:param phone: The phone of this User. :param phone: The phone of this User. # noqa: E501
:type phone: str :type phone: str
:param user_status: The user_status of this User. :param user_status: The user_status of this User. # noqa: E501
:type user_status: int :type user_status: int
""" """
self.swagger_types = { self.swagger_types = {
@ -68,20 +68,19 @@ class User(Model):
@classmethod @classmethod
def from_dict(cls, dikt): def from_dict(cls, dikt):
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The User of this User. :return: The User of this User. # noqa: E501
:rtype: User :rtype: User
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self): def id(self):
""" """Gets the id of this User.
Gets the id of this User.
:return: The id of this User. :return: The id of this User.
:rtype: long :rtype: long
@ -90,8 +89,8 @@ class User(Model):
@id.setter @id.setter
def id(self, id): def id(self, id):
""" """Sets the id of this User.
Sets the id of this User.
:param id: The id of this User. :param id: The id of this User.
:type id: long :type id: long
@ -101,8 +100,8 @@ class User(Model):
@property @property
def username(self): def username(self):
""" """Gets the username of this User.
Gets the username of this User.
:return: The username of this User. :return: The username of this User.
:rtype: str :rtype: str
@ -111,8 +110,8 @@ class User(Model):
@username.setter @username.setter
def username(self, username): def username(self, username):
""" """Sets the username of this User.
Sets the username of this User.
:param username: The username of this User. :param username: The username of this User.
:type username: str :type username: str
@ -122,8 +121,8 @@ class User(Model):
@property @property
def first_name(self): def first_name(self):
""" """Gets the first_name of this User.
Gets the first_name of this User.
:return: The first_name of this User. :return: The first_name of this User.
:rtype: str :rtype: str
@ -132,8 +131,8 @@ class User(Model):
@first_name.setter @first_name.setter
def first_name(self, first_name): def first_name(self, first_name):
""" """Sets the first_name of this User.
Sets the first_name of this User.
:param first_name: The first_name of this User. :param first_name: The first_name of this User.
:type first_name: str :type first_name: str
@ -143,8 +142,8 @@ class User(Model):
@property @property
def last_name(self): def last_name(self):
""" """Gets the last_name of this User.
Gets the last_name of this User.
:return: The last_name of this User. :return: The last_name of this User.
:rtype: str :rtype: str
@ -153,8 +152,8 @@ class User(Model):
@last_name.setter @last_name.setter
def last_name(self, last_name): def last_name(self, last_name):
""" """Sets the last_name of this User.
Sets the last_name of this User.
:param last_name: The last_name of this User. :param last_name: The last_name of this User.
:type last_name: str :type last_name: str
@ -164,8 +163,8 @@ class User(Model):
@property @property
def email(self): def email(self):
""" """Gets the email of this User.
Gets the email of this User.
:return: The email of this User. :return: The email of this User.
:rtype: str :rtype: str
@ -174,8 +173,8 @@ class User(Model):
@email.setter @email.setter
def email(self, email): def email(self, email):
""" """Sets the email of this User.
Sets the email of this User.
:param email: The email of this User. :param email: The email of this User.
:type email: str :type email: str
@ -185,8 +184,8 @@ class User(Model):
@property @property
def password(self): def password(self):
""" """Gets the password of this User.
Gets the password of this User.
:return: The password of this User. :return: The password of this User.
:rtype: str :rtype: str
@ -195,8 +194,8 @@ class User(Model):
@password.setter @password.setter
def password(self, password): def password(self, password):
""" """Sets the password of this User.
Sets the password of this User.
:param password: The password of this User. :param password: The password of this User.
:type password: str :type password: str
@ -206,8 +205,8 @@ class User(Model):
@property @property
def phone(self): def phone(self):
""" """Gets the phone of this User.
Gets the phone of this User.
:return: The phone of this User. :return: The phone of this User.
:rtype: str :rtype: str
@ -216,8 +215,8 @@ class User(Model):
@phone.setter @phone.setter
def phone(self, phone): def phone(self, phone):
""" """Sets the phone of this User.
Sets the phone of this User.
:param phone: The phone of this User. :param phone: The phone of this User.
:type phone: str :type phone: str
@ -227,9 +226,9 @@ class User(Model):
@property @property
def user_status(self): def user_status(self):
""" """Gets the user_status of this User.
Gets the user_status of this User.
User Status User Status # noqa: E501
:return: The user_status of this User. :return: The user_status of this User.
:rtype: int :rtype: int
@ -238,13 +237,12 @@ class User(Model):
@user_status.setter @user_status.setter
def user_status(self, user_status): def user_status(self, user_status):
""" """Sets the user_status of this User.
Sets the user_status of this User.
User Status User Status # noqa: E501
:param user_status: The user_status of this User. :param user_status: The user_status of this User.
:type user_status: int :type user_status: int
""" """
self._user_status = user_status self._user_status = user_status

View File

@ -108,11 +108,11 @@ paths:
type: "array" type: "array"
items: items:
type: "string" type: "string"
default: "available"
enum: enum:
- "available" - "available"
- "pending" - "pending"
- "sold" - "sold"
default: "available"
collectionFormat: "csv" collectionFormat: "csv"
responses: responses:
200: 200:

View File

@ -1,8 +1,10 @@
from flask_testing import TestCase
from ..encoder import JSONEncoder
import connexion
import logging import logging
import connexion
from flask_testing import TestCase
from swagger_server.encoder import JSONEncoder
class BaseTestCase(TestCase): class BaseTestCase(TestCase):

View File

@ -2,115 +2,124 @@
from __future__ import absolute_import from __future__ import absolute_import
from swagger_server.models.api_response import ApiResponse
from swagger_server.models.pet import Pet
from . import BaseTestCase
from six import BytesIO
from flask import json from flask import json
from six import BytesIO
from swagger_server.models.api_response import ApiResponse # noqa: E501
from swagger_server.models.pet import Pet # noqa: E501
from swagger_server.test import BaseTestCase
class TestPetController(BaseTestCase): class TestPetController(BaseTestCase):
""" PetController integration test stubs """ """PetController integration test stubs"""
def test_add_pet(self): def test_add_pet(self):
""" """Test case for add_pet
Test case for add_pet
Add a new pet to the store Add a new pet to the store
""" """
body = Pet() body = Pet()
response = self.client.open('/v2/pet', response = self.client.open(
method='POST', '/v2/pet',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_delete_pet(self): def test_delete_pet(self):
""" """Test case for delete_pet
Test case for delete_pet
Deletes a pet Deletes a pet
""" """
headers = [('api_key', 'api_key_example')] headers = [('api_key', 'api_key_example')]
response = self.client.open('/v2/pet/{petId}'.format(petId=789), response = self.client.open(
method='DELETE', '/v2/pet/{petId}'.format(petId=789),
headers=headers) method='DELETE',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) headers=headers)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_find_pets_by_status(self): def test_find_pets_by_status(self):
""" """Test case for find_pets_by_status
Test case for find_pets_by_status
Finds Pets by status Finds Pets by status
""" """
query_string = [('status', 'available')] query_string = [('status', 'available')]
response = self.client.open('/v2/pet/findByStatus', response = self.client.open(
method='GET', '/v2/pet/findByStatus',
query_string=query_string) method='GET',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) query_string=query_string)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_find_pets_by_tags(self): def test_find_pets_by_tags(self):
""" """Test case for find_pets_by_tags
Test case for find_pets_by_tags
Finds Pets by tags Finds Pets by tags
""" """
query_string = [('tags', 'tags_example')] query_string = [('tags', 'tags_example')]
response = self.client.open('/v2/pet/findByTags', response = self.client.open(
method='GET', '/v2/pet/findByTags',
query_string=query_string) method='GET',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) query_string=query_string)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_pet_by_id(self): def test_get_pet_by_id(self):
""" """Test case for get_pet_by_id
Test case for get_pet_by_id
Find pet by ID Find pet by ID
""" """
response = self.client.open('/v2/pet/{petId}'.format(petId=789), response = self.client.open(
method='GET') '/v2/pet/{petId}'.format(petId=789),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_update_pet(self): def test_update_pet(self):
""" """Test case for update_pet
Test case for update_pet
Update an existing pet Update an existing pet
""" """
body = Pet() body = Pet()
response = self.client.open('/v2/pet', response = self.client.open(
method='PUT', '/v2/pet',
data=json.dumps(body), method='PUT',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_update_pet_with_form(self): def test_update_pet_with_form(self):
""" """Test case for update_pet_with_form
Test case for update_pet_with_form
Updates a pet in the store with form data Updates a pet in the store with form data
""" """
data = dict(name='name_example', data = dict(name='name_example',
status='status_example') status='status_example')
response = self.client.open('/v2/pet/{petId}'.format(petId=789), response = self.client.open(
method='POST', '/v2/pet/{petId}'.format(petId=789),
data=data, method='POST',
content_type='application/x-www-form-urlencoded') data=data,
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/x-www-form-urlencoded')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_upload_file(self): def test_upload_file(self):
""" """Test case for upload_file
Test case for upload_file
uploads an image uploads an image
""" """
data = dict(additionalMetadata='additionalMetadata_example', data = dict(additionalMetadata='additionalMetadata_example',
file=(BytesIO(b'some file data'), 'file.txt')) file=(BytesIO(b'some file data'), 'file.txt'))
response = self.client.open('/v2/pet/{petId}/uploadImage'.format(petId=789), response = self.client.open(
method='POST', '/v2/pet/{petId}/uploadImage'.format(petId=789),
data=data, method='POST',
content_type='multipart/form-data') data=data,
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='multipart/form-data')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -2,57 +2,62 @@
from __future__ import absolute_import from __future__ import absolute_import
from swagger_server.models.order import Order
from . import BaseTestCase
from six import BytesIO
from flask import json from flask import json
from six import BytesIO
from swagger_server.models.order import Order # noqa: E501
from swagger_server.test import BaseTestCase
class TestStoreController(BaseTestCase): class TestStoreController(BaseTestCase):
""" StoreController integration test stubs """ """StoreController integration test stubs"""
def test_delete_order(self): def test_delete_order(self):
""" """Test case for delete_order
Test case for delete_order
Delete purchase order by ID Delete purchase order by ID
""" """
response = self.client.open('/v2/store/order/{orderId}'.format(orderId='orderId_example'), response = self.client.open(
method='DELETE') '/v2/store/order/{orderId}'.format(orderId='orderId_example'),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='DELETE')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_inventory(self): def test_get_inventory(self):
""" """Test case for get_inventory
Test case for get_inventory
Returns pet inventories by status Returns pet inventories by status
""" """
response = self.client.open('/v2/store/inventory', response = self.client.open(
method='GET') '/v2/store/inventory',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_order_by_id(self): def test_get_order_by_id(self):
""" """Test case for get_order_by_id
Test case for get_order_by_id
Find purchase order by ID Find purchase order by ID
""" """
response = self.client.open('/v2/store/order/{orderId}'.format(orderId=5), response = self.client.open(
method='GET') '/v2/store/order/{orderId}'.format(orderId=5),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_place_order(self): def test_place_order(self):
""" """Test case for place_order
Test case for place_order
Place an order for a pet Place an order for a pet
""" """
body = Order() body = Order()
response = self.client.open('/v2/store/order', response = self.client.open(
method='POST', '/v2/store/order',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -2,109 +2,118 @@
from __future__ import absolute_import from __future__ import absolute_import
from swagger_server.models.user import User
from . import BaseTestCase
from six import BytesIO
from flask import json from flask import json
from six import BytesIO
from swagger_server.models.user import User # noqa: E501
from swagger_server.test import BaseTestCase
class TestUserController(BaseTestCase): class TestUserController(BaseTestCase):
""" UserController integration test stubs """ """UserController integration test stubs"""
def test_create_user(self): def test_create_user(self):
""" """Test case for create_user
Test case for create_user
Create user Create user
""" """
body = User() body = User()
response = self.client.open('/v2/user', response = self.client.open(
method='POST', '/v2/user',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_create_users_with_array_input(self): def test_create_users_with_array_input(self):
""" """Test case for create_users_with_array_input
Test case for create_users_with_array_input
Creates list of users with given input array Creates list of users with given input array
""" """
body = [User()] body = [User()]
response = self.client.open('/v2/user/createWithArray', response = self.client.open(
method='POST', '/v2/user/createWithArray',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_create_users_with_list_input(self): def test_create_users_with_list_input(self):
""" """Test case for create_users_with_list_input
Test case for create_users_with_list_input
Creates list of users with given input array Creates list of users with given input array
""" """
body = [User()] body = [User()]
response = self.client.open('/v2/user/createWithList', response = self.client.open(
method='POST', '/v2/user/createWithList',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_delete_user(self): def test_delete_user(self):
""" """Test case for delete_user
Test case for delete_user
Delete user Delete user
""" """
response = self.client.open('/v2/user/{username}'.format(username='username_example'), response = self.client.open(
method='DELETE') '/v2/user/{username}'.format(username='username_example'),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='DELETE')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_user_by_name(self): def test_get_user_by_name(self):
""" """Test case for get_user_by_name
Test case for get_user_by_name
Get user by user name Get user by user name
""" """
response = self.client.open('/v2/user/{username}'.format(username='username_example'), response = self.client.open(
method='GET') '/v2/user/{username}'.format(username='username_example'),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_login_user(self): def test_login_user(self):
""" """Test case for login_user
Test case for login_user
Logs user into the system Logs user into the system
""" """
query_string = [('username', 'username_example'), query_string = [('username', 'username_example'),
('password', 'password_example')] ('password', 'password_example')]
response = self.client.open('/v2/user/login', response = self.client.open(
method='GET', '/v2/user/login',
query_string=query_string) method='GET',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) query_string=query_string)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_logout_user(self): def test_logout_user(self):
""" """Test case for logout_user
Test case for logout_user
Logs out current logged in user session Logs out current logged in user session
""" """
response = self.client.open('/v2/user/logout', response = self.client.open(
method='GET') '/v2/user/logout',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_update_user(self): def test_update_user(self):
""" """Test case for update_user
Test case for update_user
Updated user Updated user
""" """
body = User() body = User()
response = self.client.open('/v2/user/{username}'.format(username='username_example'), response = self.client.open(
method='PUT', '/v2/user/{username}'.format(username='username_example'),
data=json.dumps(body), method='PUT',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1,11 +1,11 @@
from typing import GenericMeta import datetime
from datetime import datetime, date
from six import integer_types, iteritems import six
import typing
def _deserialize(data, klass): def _deserialize(data, klass):
""" """Deserializes dict, list, str into an object.
Deserializes dict, list, str into an object.
:param data: dict, list or str. :param data: dict, list or str.
:param klass: class literal, or string of class name. :param klass: class literal, or string of class name.
@ -15,15 +15,15 @@ def _deserialize(data, klass):
if data is None: if data is None:
return None return None
if klass in integer_types or klass in (float, str, bool): if klass in six.integer_types or klass in (float, str, bool):
return _deserialize_primitive(data, klass) return _deserialize_primitive(data, klass)
elif klass == object: elif klass == object:
return _deserialize_object(data) return _deserialize_object(data)
elif klass == date: elif klass == datetime.date:
return deserialize_date(data) return deserialize_date(data)
elif klass == datetime: elif klass == datetime.datetime:
return deserialize_datetime(data) return deserialize_datetime(data)
elif type(klass) == GenericMeta: elif type(klass) == typing.GenericMeta:
if klass.__extra__ == list: if klass.__extra__ == list:
return _deserialize_list(data, klass.__args__[0]) return _deserialize_list(data, klass.__args__[0])
if klass.__extra__ == dict: if klass.__extra__ == dict:
@ -33,8 +33,7 @@ def _deserialize(data, klass):
def _deserialize_primitive(data, klass): def _deserialize_primitive(data, klass):
""" """Deserializes to primitive type.
Deserializes to primitive type.
:param data: data to deserialize. :param data: data to deserialize.
:param klass: class literal. :param klass: class literal.
@ -52,8 +51,7 @@ def _deserialize_primitive(data, klass):
def _deserialize_object(value): def _deserialize_object(value):
""" """Return a original value.
Return a original value.
:return: object. :return: object.
""" """
@ -61,8 +59,7 @@ def _deserialize_object(value):
def deserialize_date(string): def deserialize_date(string):
""" """Deserializes string to date.
Deserializes string to date.
:param string: str. :param string: str.
:type string: str :type string: str
@ -77,8 +74,7 @@ def deserialize_date(string):
def deserialize_datetime(string): def deserialize_datetime(string):
""" """Deserializes string to datetime.
Deserializes string to datetime.
The string should be in iso8601 datetime format. The string should be in iso8601 datetime format.
@ -95,8 +91,7 @@ def deserialize_datetime(string):
def deserialize_model(data, klass): def deserialize_model(data, klass):
""" """Deserializes list or dict to model.
Deserializes list or dict to model.
:param data: dict, list. :param data: dict, list.
:type data: dict | list :type data: dict | list
@ -108,7 +103,7 @@ def deserialize_model(data, klass):
if not instance.swagger_types: if not instance.swagger_types:
return data return data
for attr, attr_type in iteritems(instance.swagger_types): for attr, attr_type in six.iteritems(instance.swagger_types):
if data is not None \ if data is not None \
and instance.attribute_map[attr] in data \ and instance.attribute_map[attr] in data \
and isinstance(data, (list, dict)): and isinstance(data, (list, dict)):
@ -119,8 +114,7 @@ def deserialize_model(data, klass):
def _deserialize_list(data, boxed_type): def _deserialize_list(data, boxed_type):
""" """Deserializes a list and its elements.
Deserializes a list and its elements.
:param data: list to deserialize. :param data: list to deserialize.
:type data: list :type data: list
@ -133,10 +127,8 @@ def _deserialize_list(data, boxed_type):
for sub_data in data] for sub_data in data]
def _deserialize_dict(data, boxed_type): def _deserialize_dict(data, boxed_type):
""" """Deserializes a dict and its elements.
Deserializes a dict and its elements.
:param data: dict to deserialize. :param data: dict to deserialize.
:type data: dict :type data: dict
@ -146,4 +138,4 @@ def _deserialize_dict(data, boxed_type):
:rtype: dict :rtype: dict
""" """
return {k: _deserialize(v, boxed_type) return {k: _deserialize(v, boxed_type)
for k, v in iteritems(data)} for k, v in six.iteritems(data)}

View File

@ -1,13 +1,14 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import connexion import connexion
from .encoder import JSONEncoder
from swagger_server import encoder
def main(): def main():
app = connexion.App(__name__, specification_dir='./swagger/') app = connexion.App(__name__, specification_dir='./swagger/')
app.app.json_encoder = JSONEncoder app.app.json_encoder = encoder.JSONEncoder
app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key &#x60;special-key&#x60; to test the authorization filters.'}) app.add_api('swagger.yaml', arguments={'title': 'Swagger Petstore'})
app.run(port=8080) app.run(port=8080)

View File

@ -1,30 +1,31 @@
import connexion import connexion
from swagger_server.models.api_response import ApiResponse import six
from swagger_server.models.pet import Pet
from datetime import date, datetime from swagger_server.models.api_response import ApiResponse # noqa: E501
from typing import List, Dict from swagger_server.models.pet import Pet # noqa: E501
from six import iteritems from swagger_server import util
from ..util import deserialize_date, deserialize_datetime
def add_pet(body): def add_pet(body): # noqa: E501
""" """Add a new pet to the store
Add a new pet to the store
# noqa: E501
:param body: Pet object that needs to be added to the store :param body: Pet object that needs to be added to the store
:type body: dict | bytes :type body: dict | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = Pet.from_dict(connexion.request.get_json()) body = Pet.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'
def delete_pet(petId, api_key=None): def delete_pet(petId, api_key=None): # noqa: E501
""" """Deletes a pet
Deletes a pet
# noqa: E501
:param petId: Pet id to delete :param petId: Pet id to delete
:type petId: int :type petId: int
:param api_key: :param api_key:
@ -35,10 +36,11 @@ def delete_pet(petId, api_key=None):
return 'do some magic!' return 'do some magic!'
def find_pets_by_status(status): def find_pets_by_status(status): # noqa: E501
""" """Finds Pets by status
Finds Pets by status
Multiple status values can be provided with comma separated strings Multiple status values can be provided with comma separated strings # noqa: E501
:param status: Status values that need to be considered for filter :param status: Status values that need to be considered for filter
:type status: List[str] :type status: List[str]
@ -47,10 +49,11 @@ def find_pets_by_status(status):
return 'do some magic!' return 'do some magic!'
def find_pets_by_tags(tags): def find_pets_by_tags(tags): # noqa: E501
""" """Finds Pets by tags
Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501
:param tags: Tags to filter by :param tags: Tags to filter by
:type tags: List[str] :type tags: List[str]
@ -59,10 +62,11 @@ def find_pets_by_tags(tags):
return 'do some magic!' return 'do some magic!'
def get_pet_by_id(petId): def get_pet_by_id(petId): # noqa: E501
""" """Find pet by ID
Find pet by ID
Returns a single pet Returns a single pet # noqa: E501
:param petId: ID of pet to return :param petId: ID of pet to return
:type petId: int :type petId: int
@ -71,24 +75,26 @@ def get_pet_by_id(petId):
return 'do some magic!' return 'do some magic!'
def update_pet(body): def update_pet(body): # noqa: E501
""" """Update an existing pet
Update an existing pet
# noqa: E501
:param body: Pet object that needs to be added to the store :param body: Pet object that needs to be added to the store
:type body: dict | bytes :type body: dict | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = Pet.from_dict(connexion.request.get_json()) body = Pet.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'
def update_pet_with_form(petId, name=None, status=None): def update_pet_with_form(petId, name=None, status=None): # noqa: E501
""" """Updates a pet in the store with form data
Updates a pet in the store with form data
# noqa: E501
:param petId: ID of pet that needs to be updated :param petId: ID of pet that needs to be updated
:type petId: int :type petId: int
:param name: Updated name of the pet :param name: Updated name of the pet
@ -101,10 +107,11 @@ def update_pet_with_form(petId, name=None, status=None):
return 'do some magic!' return 'do some magic!'
def upload_file(petId, additionalMetadata=None, file=None): def upload_file(petId, additionalMetadata=None, file=None): # noqa: E501
""" """uploads an image
uploads an image
# noqa: E501
:param petId: ID of pet to update :param petId: ID of pet to update
:type petId: int :type petId: int
:param additionalMetadata: Additional data to pass to server :param additionalMetadata: Additional data to pass to server

View File

@ -1,15 +1,15 @@
import connexion import connexion
from swagger_server.models.order import Order import six
from datetime import date, datetime
from typing import List, Dict from swagger_server.models.order import Order # noqa: E501
from six import iteritems from swagger_server import util
from ..util import deserialize_date, deserialize_datetime
def delete_order(orderId): def delete_order(orderId): # noqa: E501
""" """Delete purchase order by ID
Delete purchase order by ID
For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501
:param orderId: ID of the order that needs to be deleted :param orderId: ID of the order that needs to be deleted
:type orderId: str :type orderId: str
@ -18,20 +18,22 @@ def delete_order(orderId):
return 'do some magic!' return 'do some magic!'
def get_inventory(): def get_inventory(): # noqa: E501
""" """Returns pet inventories by status
Returns pet inventories by status
Returns a map of status codes to quantities Returns a map of status codes to quantities # noqa: E501
:rtype: Dict[str, int] :rtype: Dict[str, int]
""" """
return 'do some magic!' return 'do some magic!'
def get_order_by_id(orderId): def get_order_by_id(orderId): # noqa: E501
""" """Find purchase order by ID
Find purchase order by ID
For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions # noqa: E501
:param orderId: ID of pet that needs to be fetched :param orderId: ID of pet that needs to be fetched
:type orderId: int :type orderId: int
@ -40,15 +42,16 @@ def get_order_by_id(orderId):
return 'do some magic!' return 'do some magic!'
def place_order(body): def place_order(body): # noqa: E501
""" """Place an order for a pet
Place an order for a pet
# noqa: E501
:param body: order placed for purchasing the pet :param body: order placed for purchasing the pet
:type body: dict | bytes :type body: dict | bytes
:rtype: Order :rtype: Order
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = Order.from_dict(connexion.request.get_json()) body = Order.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'

View File

@ -1,57 +1,60 @@
import connexion import connexion
from swagger_server.models.user import User import six
from datetime import date, datetime
from typing import List, Dict from swagger_server.models.user import User # noqa: E501
from six import iteritems from swagger_server import util
from ..util import deserialize_date, deserialize_datetime
def create_user(body): def create_user(body): # noqa: E501
""" """Create user
Create user
This can only be done by the logged in user. This can only be done by the logged in user. # noqa: E501
:param body: Created user object :param body: Created user object
:type body: dict | bytes :type body: dict | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = User.from_dict(connexion.request.get_json()) body = User.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'
def create_users_with_array_input(body): def create_users_with_array_input(body): # noqa: E501
""" """Creates list of users with given input array
Creates list of users with given input array
# noqa: E501
:param body: List of user object :param body: List of user object
:type body: list | bytes :type body: list | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = [User.from_dict(d) for d in connexion.request.get_json()] body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
return 'do some magic!' return 'do some magic!'
def create_users_with_list_input(body): def create_users_with_list_input(body): # noqa: E501
""" """Creates list of users with given input array
Creates list of users with given input array
# noqa: E501
:param body: List of user object :param body: List of user object
:type body: list | bytes :type body: list | bytes
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = [User.from_dict(d) for d in connexion.request.get_json()] body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
return 'do some magic!' return 'do some magic!'
def delete_user(username): def delete_user(username): # noqa: E501
""" """Delete user
Delete user
This can only be done by the logged in user. This can only be done by the logged in user. # noqa: E501
:param username: The name that needs to be deleted :param username: The name that needs to be deleted
:type username: str :type username: str
@ -60,10 +63,11 @@ def delete_user(username):
return 'do some magic!' return 'do some magic!'
def get_user_by_name(username): def get_user_by_name(username): # noqa: E501
""" """Get user by user name
Get user by user name
# noqa: E501
:param username: The name that needs to be fetched. Use user1 for testing. :param username: The name that needs to be fetched. Use user1 for testing.
:type username: str :type username: str
@ -72,10 +76,11 @@ def get_user_by_name(username):
return 'do some magic!' return 'do some magic!'
def login_user(username, password): def login_user(username, password): # noqa: E501
""" """Logs user into the system
Logs user into the system
# noqa: E501
:param username: The user name for login :param username: The user name for login
:type username: str :type username: str
:param password: The password for login in clear text :param password: The password for login in clear text
@ -86,20 +91,22 @@ def login_user(username, password):
return 'do some magic!' return 'do some magic!'
def logout_user(): def logout_user(): # noqa: E501
""" """Logs out current logged in user session
Logs out current logged in user session
# noqa: E501
:rtype: None :rtype: None
""" """
return 'do some magic!' return 'do some magic!'
def update_user(username, body): def update_user(username, body): # noqa: E501
""" """Updated user
Updated user
This can only be done by the logged in user. This can only be done by the logged in user. # noqa: E501
:param username: name that need to be deleted :param username: name that need to be deleted
:type username: str :type username: str
:param body: Updated user object :param body: Updated user object
@ -108,5 +115,5 @@ def update_user(username, body):
:rtype: None :rtype: None
""" """
if connexion.request.is_json: if connexion.request.is_json:
body = User.from_dict(connexion.request.get_json()) body = User.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!' return 'do some magic!'

View File

@ -1,6 +1,8 @@
from six import iteritems
from swagger_server.models.base_model_ import Model
from connexion.apps.flask_app import FlaskJSONEncoder from connexion.apps.flask_app import FlaskJSONEncoder
import six
from swagger_server.models.base_model_ import Model
class JSONEncoder(FlaskJSONEncoder): class JSONEncoder(FlaskJSONEncoder):
include_nulls = False include_nulls = False
@ -8,11 +10,11 @@ class JSONEncoder(FlaskJSONEncoder):
def default(self, o): def default(self, o):
if isinstance(o, Model): if isinstance(o, Model):
dikt = {} dikt = {}
for attr, _ in iteritems(o.swagger_types): for attr, _ in six.iteritems(o.swagger_types):
value = getattr(o, attr) value = getattr(o, attr)
if value is None and not self.include_nulls: if value is None and not self.include_nulls:
continue continue
attr = o.attribute_map[attr] attr = o.attribute_map[attr]
dikt[attr] = value dikt[attr] = value
return dikt return dikt
return FlaskJSONEncoder.default(self, o) return FlaskJSONEncoder.default(self, o)

View File

@ -1,10 +1,11 @@
# coding: utf-8 # coding: utf-8
# flake8: noqa
from __future__ import absolute_import from __future__ import absolute_import
# import models into model package # import models into model package
from .api_response import ApiResponse from swagger_server.models.api_response import ApiResponse
from .category import Category from swagger_server.models.category import Category
from .order import Order from swagger_server.models.order import Order
from .pet import Pet from swagger_server.models.pet import Pet
from .tag import Tag from swagger_server.models.tag import Tag
from .user import User from swagger_server.models.user import User

View File

@ -1,28 +1,28 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class ApiResponse(Model): class ApiResponse(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, code: int=None, type: str=None, message: str=None): # noqa: E501
"""ApiResponse - a model defined in Swagger
def __init__(self, code: int=None, type: str=None, message: str=None): :param code: The code of this ApiResponse. # noqa: E501
"""
ApiResponse - a model defined in Swagger
:param code: The code of this ApiResponse.
:type code: int :type code: int
:param type: The type of this ApiResponse. :param type: The type of this ApiResponse. # noqa: E501
:type type: str :type type: str
:param message: The message of this ApiResponse. :param message: The message of this ApiResponse. # noqa: E501
:type message: str :type message: str
""" """
self.swagger_types = { self.swagger_types = {
@ -43,20 +43,19 @@ class ApiResponse(Model):
@classmethod @classmethod
def from_dict(cls, dikt) -> 'ApiResponse': def from_dict(cls, dikt) -> 'ApiResponse':
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The ApiResponse of this ApiResponse. :return: The ApiResponse of this ApiResponse. # noqa: E501
:rtype: ApiResponse :rtype: ApiResponse
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def code(self) -> int: def code(self) -> int:
""" """Gets the code of this ApiResponse.
Gets the code of this ApiResponse.
:return: The code of this ApiResponse. :return: The code of this ApiResponse.
:rtype: int :rtype: int
@ -65,8 +64,8 @@ class ApiResponse(Model):
@code.setter @code.setter
def code(self, code: int): def code(self, code: int):
""" """Sets the code of this ApiResponse.
Sets the code of this ApiResponse.
:param code: The code of this ApiResponse. :param code: The code of this ApiResponse.
:type code: int :type code: int
@ -76,8 +75,8 @@ class ApiResponse(Model):
@property @property
def type(self) -> str: def type(self) -> str:
""" """Gets the type of this ApiResponse.
Gets the type of this ApiResponse.
:return: The type of this ApiResponse. :return: The type of this ApiResponse.
:rtype: str :rtype: str
@ -86,8 +85,8 @@ class ApiResponse(Model):
@type.setter @type.setter
def type(self, type: str): def type(self, type: str):
""" """Sets the type of this ApiResponse.
Sets the type of this ApiResponse.
:param type: The type of this ApiResponse. :param type: The type of this ApiResponse.
:type type: str :type type: str
@ -97,8 +96,8 @@ class ApiResponse(Model):
@property @property
def message(self) -> str: def message(self) -> str:
""" """Gets the message of this ApiResponse.
Gets the message of this ApiResponse.
:return: The message of this ApiResponse. :return: The message of this ApiResponse.
:rtype: str :rtype: str
@ -107,12 +106,11 @@ class ApiResponse(Model):
@message.setter @message.setter
def message(self, message: str): def message(self, message: str):
""" """Sets the message of this ApiResponse.
Sets the message of this ApiResponse.
:param message: The message of this ApiResponse. :param message: The message of this ApiResponse.
:type message: str :type message: str
""" """
self._message = message self._message = message

View File

@ -1,34 +1,35 @@
from pprint import pformat import pprint
from typing import TypeVar, Type
from six import iteritems
from ..util import deserialize_model
T = TypeVar('T') import six
import typing
from swagger_server import util
T = typing.TypeVar('T')
class Model(object): class Model(object):
# swaggerTypes: The key is attribute name and the value is attribute type. # swaggerTypes: The key is attribute name and the
# value is attribute type.
swagger_types = {} swagger_types = {}
# attributeMap: The key is attribute name and the value is json key in definition. # attributeMap: The key is attribute name and the
# value is json key in definition.
attribute_map = {} attribute_map = {}
@classmethod @classmethod
def from_dict(cls: Type[T], dikt) -> T: def from_dict(cls: typing.Type[T], dikt) -> T:
""" """Returns the dict as a model"""
Returns the dict as a model return util.deserialize_model(dikt, cls)
"""
return deserialize_model(dikt, cls)
def to_dict(self): def to_dict(self):
""" """Returns the model properties as a dict
Returns the model properties as a dict
:rtype: dict :rtype: dict
""" """
result = {} result = {}
for attr, _ in iteritems(self.swagger_types): for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr) value = getattr(self, attr)
if isinstance(value, list): if isinstance(value, list):
result[attr] = list(map( result[attr] = list(map(
@ -49,27 +50,20 @@ class Model(object):
return result return result
def to_str(self): def to_str(self):
""" """Returns the string representation of the model
Returns the string representation of the model
:rtype: str :rtype: str
""" """
return pformat(self.to_dict()) return pprint.pformat(self.to_dict())
def __repr__(self): def __repr__(self):
""" """For `print` and `pprint`"""
For `print` and `pprint`
"""
return self.to_str() return self.to_str()
def __eq__(self, other): def __eq__(self, other):
""" """Returns true if both objects are equal"""
Returns true if both objects are equal
"""
return self.__dict__ == other.__dict__ return self.__dict__ == other.__dict__
def __ne__(self, other): def __ne__(self, other):
""" """Returns true if both objects are not equal"""
Returns true if both objects are not equal return not self == other
"""
return not self == other

View File

@ -1,26 +1,26 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class Category(Model): class Category(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id: int=None, name: str=None): # noqa: E501
"""Category - a model defined in Swagger
def __init__(self, id: int=None, name: str=None): :param id: The id of this Category. # noqa: E501
"""
Category - a model defined in Swagger
:param id: The id of this Category.
:type id: int :type id: int
:param name: The name of this Category. :param name: The name of this Category. # noqa: E501
:type name: str :type name: str
""" """
self.swagger_types = { self.swagger_types = {
@ -38,20 +38,19 @@ class Category(Model):
@classmethod @classmethod
def from_dict(cls, dikt) -> 'Category': def from_dict(cls, dikt) -> 'Category':
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The Category of this Category. :return: The Category of this Category. # noqa: E501
:rtype: Category :rtype: Category
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self) -> int: def id(self) -> int:
""" """Gets the id of this Category.
Gets the id of this Category.
:return: The id of this Category. :return: The id of this Category.
:rtype: int :rtype: int
@ -60,8 +59,8 @@ class Category(Model):
@id.setter @id.setter
def id(self, id: int): def id(self, id: int):
""" """Sets the id of this Category.
Sets the id of this Category.
:param id: The id of this Category. :param id: The id of this Category.
:type id: int :type id: int
@ -71,8 +70,8 @@ class Category(Model):
@property @property
def name(self) -> str: def name(self) -> str:
""" """Gets the name of this Category.
Gets the name of this Category.
:return: The name of this Category. :return: The name of this Category.
:rtype: str :rtype: str
@ -81,12 +80,11 @@ class Category(Model):
@name.setter @name.setter
def name(self, name: str): def name(self, name: str):
""" """Sets the name of this Category.
Sets the name of this Category.
:param name: The name of this Category. :param name: The name of this Category.
:type name: str :type name: str
""" """
self._name = name self._name = name

View File

@ -1,34 +1,34 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class Order(Model): class Order(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id: int=None, pet_id: int=None, quantity: int=None, ship_date: datetime=None, status: str=None, complete: bool=False): # noqa: E501
"""Order - a model defined in Swagger
def __init__(self, id: int=None, pet_id: int=None, quantity: int=None, ship_date: datetime=None, status: str=None, complete: bool=False): :param id: The id of this Order. # noqa: E501
"""
Order - a model defined in Swagger
:param id: The id of this Order.
:type id: int :type id: int
:param pet_id: The pet_id of this Order. :param pet_id: The pet_id of this Order. # noqa: E501
:type pet_id: int :type pet_id: int
:param quantity: The quantity of this Order. :param quantity: The quantity of this Order. # noqa: E501
:type quantity: int :type quantity: int
:param ship_date: The ship_date of this Order. :param ship_date: The ship_date of this Order. # noqa: E501
:type ship_date: datetime :type ship_date: datetime
:param status: The status of this Order. :param status: The status of this Order. # noqa: E501
:type status: str :type status: str
:param complete: The complete of this Order. :param complete: The complete of this Order. # noqa: E501
:type complete: bool :type complete: bool
""" """
self.swagger_types = { self.swagger_types = {
@ -58,20 +58,19 @@ class Order(Model):
@classmethod @classmethod
def from_dict(cls, dikt) -> 'Order': def from_dict(cls, dikt) -> 'Order':
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The Order of this Order. :return: The Order of this Order. # noqa: E501
:rtype: Order :rtype: Order
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self) -> int: def id(self) -> int:
""" """Gets the id of this Order.
Gets the id of this Order.
:return: The id of this Order. :return: The id of this Order.
:rtype: int :rtype: int
@ -80,8 +79,8 @@ class Order(Model):
@id.setter @id.setter
def id(self, id: int): def id(self, id: int):
""" """Sets the id of this Order.
Sets the id of this Order.
:param id: The id of this Order. :param id: The id of this Order.
:type id: int :type id: int
@ -91,8 +90,8 @@ class Order(Model):
@property @property
def pet_id(self) -> int: def pet_id(self) -> int:
""" """Gets the pet_id of this Order.
Gets the pet_id of this Order.
:return: The pet_id of this Order. :return: The pet_id of this Order.
:rtype: int :rtype: int
@ -101,8 +100,8 @@ class Order(Model):
@pet_id.setter @pet_id.setter
def pet_id(self, pet_id: int): def pet_id(self, pet_id: int):
""" """Sets the pet_id of this Order.
Sets the pet_id of this Order.
:param pet_id: The pet_id of this Order. :param pet_id: The pet_id of this Order.
:type pet_id: int :type pet_id: int
@ -112,8 +111,8 @@ class Order(Model):
@property @property
def quantity(self) -> int: def quantity(self) -> int:
""" """Gets the quantity of this Order.
Gets the quantity of this Order.
:return: The quantity of this Order. :return: The quantity of this Order.
:rtype: int :rtype: int
@ -122,8 +121,8 @@ class Order(Model):
@quantity.setter @quantity.setter
def quantity(self, quantity: int): def quantity(self, quantity: int):
""" """Sets the quantity of this Order.
Sets the quantity of this Order.
:param quantity: The quantity of this Order. :param quantity: The quantity of this Order.
:type quantity: int :type quantity: int
@ -133,8 +132,8 @@ class Order(Model):
@property @property
def ship_date(self) -> datetime: def ship_date(self) -> datetime:
""" """Gets the ship_date of this Order.
Gets the ship_date of this Order.
:return: The ship_date of this Order. :return: The ship_date of this Order.
:rtype: datetime :rtype: datetime
@ -143,8 +142,8 @@ class Order(Model):
@ship_date.setter @ship_date.setter
def ship_date(self, ship_date: datetime): def ship_date(self, ship_date: datetime):
""" """Sets the ship_date of this Order.
Sets the ship_date of this Order.
:param ship_date: The ship_date of this Order. :param ship_date: The ship_date of this Order.
:type ship_date: datetime :type ship_date: datetime
@ -154,9 +153,9 @@ class Order(Model):
@property @property
def status(self) -> str: def status(self) -> str:
""" """Gets the status of this Order.
Gets the status of this Order.
Order Status Order Status # noqa: E501
:return: The status of this Order. :return: The status of this Order.
:rtype: str :rtype: str
@ -165,14 +164,14 @@ class Order(Model):
@status.setter @status.setter
def status(self, status: str): def status(self, status: str):
""" """Sets the status of this Order.
Sets the status of this Order.
Order Status Order Status # noqa: E501
:param status: The status of this Order. :param status: The status of this Order.
:type status: str :type status: str
""" """
allowed_values = ["placed", "approved", "delivered"] allowed_values = ["placed", "approved", "delivered"] # noqa: E501
if status not in allowed_values: if status not in allowed_values:
raise ValueError( raise ValueError(
"Invalid value for `status` ({0}), must be one of {1}" "Invalid value for `status` ({0}), must be one of {1}"
@ -183,8 +182,8 @@ class Order(Model):
@property @property
def complete(self) -> bool: def complete(self) -> bool:
""" """Gets the complete of this Order.
Gets the complete of this Order.
:return: The complete of this Order. :return: The complete of this Order.
:rtype: bool :rtype: bool
@ -193,12 +192,11 @@ class Order(Model):
@complete.setter @complete.setter
def complete(self, complete: bool): def complete(self, complete: bool):
""" """Sets the complete of this Order.
Sets the complete of this Order.
:param complete: The complete of this Order. :param complete: The complete of this Order.
:type complete: bool :type complete: bool
""" """
self._complete = complete self._complete = complete

View File

@ -1,36 +1,36 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from swagger_server.models.category import Category from datetime import date, datetime # noqa: F401
from swagger_server.models.tag import Tag
from .base_model_ import Model from typing import List, Dict # noqa: F401
from datetime import date, datetime
from typing import List, Dict from swagger_server.models.base_model_ import Model
from ..util import deserialize_model from swagger_server.models.category import Category # noqa: E501
from swagger_server.models.tag import Tag # noqa: E501
from swagger_server import util
class Pet(Model): class Pet(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id: int=None, category: Category=None, name: str=None, photo_urls: List[str]=None, tags: List[Tag]=None, status: str=None): # noqa: E501
"""Pet - a model defined in Swagger
def __init__(self, id: int=None, category: Category=None, name: str=None, photo_urls: List[str]=None, tags: List[Tag]=None, status: str=None): :param id: The id of this Pet. # noqa: E501
"""
Pet - a model defined in Swagger
:param id: The id of this Pet.
:type id: int :type id: int
:param category: The category of this Pet. :param category: The category of this Pet. # noqa: E501
:type category: Category :type category: Category
:param name: The name of this Pet. :param name: The name of this Pet. # noqa: E501
:type name: str :type name: str
:param photo_urls: The photo_urls of this Pet. :param photo_urls: The photo_urls of this Pet. # noqa: E501
:type photo_urls: List[str] :type photo_urls: List[str]
:param tags: The tags of this Pet. :param tags: The tags of this Pet. # noqa: E501
:type tags: List[Tag] :type tags: List[Tag]
:param status: The status of this Pet. :param status: The status of this Pet. # noqa: E501
:type status: str :type status: str
""" """
self.swagger_types = { self.swagger_types = {
@ -60,20 +60,19 @@ class Pet(Model):
@classmethod @classmethod
def from_dict(cls, dikt) -> 'Pet': def from_dict(cls, dikt) -> 'Pet':
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The Pet of this Pet. :return: The Pet of this Pet. # noqa: E501
:rtype: Pet :rtype: Pet
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self) -> int: def id(self) -> int:
""" """Gets the id of this Pet.
Gets the id of this Pet.
:return: The id of this Pet. :return: The id of this Pet.
:rtype: int :rtype: int
@ -82,8 +81,8 @@ class Pet(Model):
@id.setter @id.setter
def id(self, id: int): def id(self, id: int):
""" """Sets the id of this Pet.
Sets the id of this Pet.
:param id: The id of this Pet. :param id: The id of this Pet.
:type id: int :type id: int
@ -93,8 +92,8 @@ class Pet(Model):
@property @property
def category(self) -> Category: def category(self) -> Category:
""" """Gets the category of this Pet.
Gets the category of this Pet.
:return: The category of this Pet. :return: The category of this Pet.
:rtype: Category :rtype: Category
@ -103,8 +102,8 @@ class Pet(Model):
@category.setter @category.setter
def category(self, category: Category): def category(self, category: Category):
""" """Sets the category of this Pet.
Sets the category of this Pet.
:param category: The category of this Pet. :param category: The category of this Pet.
:type category: Category :type category: Category
@ -114,8 +113,8 @@ class Pet(Model):
@property @property
def name(self) -> str: def name(self) -> str:
""" """Gets the name of this Pet.
Gets the name of this Pet.
:return: The name of this Pet. :return: The name of this Pet.
:rtype: str :rtype: str
@ -124,21 +123,21 @@ class Pet(Model):
@name.setter @name.setter
def name(self, name: str): def name(self, name: str):
""" """Sets the name of this Pet.
Sets the name of this Pet.
:param name: The name of this Pet. :param name: The name of this Pet.
:type name: str :type name: str
""" """
if name is None: if name is None:
raise ValueError("Invalid value for `name`, must not be `None`") raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501
self._name = name self._name = name
@property @property
def photo_urls(self) -> List[str]: def photo_urls(self) -> List[str]:
""" """Gets the photo_urls of this Pet.
Gets the photo_urls of this Pet.
:return: The photo_urls of this Pet. :return: The photo_urls of this Pet.
:rtype: List[str] :rtype: List[str]
@ -147,21 +146,21 @@ class Pet(Model):
@photo_urls.setter @photo_urls.setter
def photo_urls(self, photo_urls: List[str]): def photo_urls(self, photo_urls: List[str]):
""" """Sets the photo_urls of this Pet.
Sets the photo_urls of this Pet.
:param photo_urls: The photo_urls of this Pet. :param photo_urls: The photo_urls of this Pet.
:type photo_urls: List[str] :type photo_urls: List[str]
""" """
if photo_urls is None: if photo_urls is None:
raise ValueError("Invalid value for `photo_urls`, must not be `None`") raise ValueError("Invalid value for `photo_urls`, must not be `None`") # noqa: E501
self._photo_urls = photo_urls self._photo_urls = photo_urls
@property @property
def tags(self) -> List[Tag]: def tags(self) -> List[Tag]:
""" """Gets the tags of this Pet.
Gets the tags of this Pet.
:return: The tags of this Pet. :return: The tags of this Pet.
:rtype: List[Tag] :rtype: List[Tag]
@ -170,8 +169,8 @@ class Pet(Model):
@tags.setter @tags.setter
def tags(self, tags: List[Tag]): def tags(self, tags: List[Tag]):
""" """Sets the tags of this Pet.
Sets the tags of this Pet.
:param tags: The tags of this Pet. :param tags: The tags of this Pet.
:type tags: List[Tag] :type tags: List[Tag]
@ -181,9 +180,9 @@ class Pet(Model):
@property @property
def status(self) -> str: def status(self) -> str:
""" """Gets the status of this Pet.
Gets the status of this Pet.
pet status in the store pet status in the store # noqa: E501
:return: The status of this Pet. :return: The status of this Pet.
:rtype: str :rtype: str
@ -192,14 +191,14 @@ class Pet(Model):
@status.setter @status.setter
def status(self, status: str): def status(self, status: str):
""" """Sets the status of this Pet.
Sets the status of this Pet.
pet status in the store pet status in the store # noqa: E501
:param status: The status of this Pet. :param status: The status of this Pet.
:type status: str :type status: str
""" """
allowed_values = ["available", "pending", "sold"] allowed_values = ["available", "pending", "sold"] # noqa: E501
if status not in allowed_values: if status not in allowed_values:
raise ValueError( raise ValueError(
"Invalid value for `status` ({0}), must be one of {1}" "Invalid value for `status` ({0}), must be one of {1}"
@ -207,4 +206,3 @@ class Pet(Model):
) )
self._status = status self._status = status

View File

@ -1,26 +1,26 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class Tag(Model): class Tag(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id: int=None, name: str=None): # noqa: E501
"""Tag - a model defined in Swagger
def __init__(self, id: int=None, name: str=None): :param id: The id of this Tag. # noqa: E501
"""
Tag - a model defined in Swagger
:param id: The id of this Tag.
:type id: int :type id: int
:param name: The name of this Tag. :param name: The name of this Tag. # noqa: E501
:type name: str :type name: str
""" """
self.swagger_types = { self.swagger_types = {
@ -38,20 +38,19 @@ class Tag(Model):
@classmethod @classmethod
def from_dict(cls, dikt) -> 'Tag': def from_dict(cls, dikt) -> 'Tag':
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The Tag of this Tag. :return: The Tag of this Tag. # noqa: E501
:rtype: Tag :rtype: Tag
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self) -> int: def id(self) -> int:
""" """Gets the id of this Tag.
Gets the id of this Tag.
:return: The id of this Tag. :return: The id of this Tag.
:rtype: int :rtype: int
@ -60,8 +59,8 @@ class Tag(Model):
@id.setter @id.setter
def id(self, id: int): def id(self, id: int):
""" """Sets the id of this Tag.
Sets the id of this Tag.
:param id: The id of this Tag. :param id: The id of this Tag.
:type id: int :type id: int
@ -71,8 +70,8 @@ class Tag(Model):
@property @property
def name(self) -> str: def name(self) -> str:
""" """Gets the name of this Tag.
Gets the name of this Tag.
:return: The name of this Tag. :return: The name of this Tag.
:rtype: str :rtype: str
@ -81,12 +80,11 @@ class Tag(Model):
@name.setter @name.setter
def name(self, name: str): def name(self, name: str):
""" """Sets the name of this Tag.
Sets the name of this Tag.
:param name: The name of this Tag. :param name: The name of this Tag.
:type name: str :type name: str
""" """
self._name = name self._name = name

View File

@ -1,38 +1,38 @@
# coding: utf-8 # coding: utf-8
from __future__ import absolute_import from __future__ import absolute_import
from .base_model_ import Model from datetime import date, datetime # noqa: F401
from datetime import date, datetime
from typing import List, Dict from typing import List, Dict # noqa: F401
from ..util import deserialize_model
from swagger_server.models.base_model_ import Model
from swagger_server import util
class User(Model): class User(Model):
""" """NOTE: This class is auto generated by the swagger code generator program.
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, id: int=None, username: str=None, first_name: str=None, last_name: str=None, email: str=None, password: str=None, phone: str=None, user_status: int=None): # noqa: E501
"""User - a model defined in Swagger
def __init__(self, id: int=None, username: str=None, first_name: str=None, last_name: str=None, email: str=None, password: str=None, phone: str=None, user_status: int=None): :param id: The id of this User. # noqa: E501
"""
User - a model defined in Swagger
:param id: The id of this User.
:type id: int :type id: int
:param username: The username of this User. :param username: The username of this User. # noqa: E501
:type username: str :type username: str
:param first_name: The first_name of this User. :param first_name: The first_name of this User. # noqa: E501
:type first_name: str :type first_name: str
:param last_name: The last_name of this User. :param last_name: The last_name of this User. # noqa: E501
:type last_name: str :type last_name: str
:param email: The email of this User. :param email: The email of this User. # noqa: E501
:type email: str :type email: str
:param password: The password of this User. :param password: The password of this User. # noqa: E501
:type password: str :type password: str
:param phone: The phone of this User. :param phone: The phone of this User. # noqa: E501
:type phone: str :type phone: str
:param user_status: The user_status of this User. :param user_status: The user_status of this User. # noqa: E501
:type user_status: int :type user_status: int
""" """
self.swagger_types = { self.swagger_types = {
@ -68,20 +68,19 @@ class User(Model):
@classmethod @classmethod
def from_dict(cls, dikt) -> 'User': def from_dict(cls, dikt) -> 'User':
""" """Returns the dict as a model
Returns the dict as a model
:param dikt: A dict. :param dikt: A dict.
:type: dict :type: dict
:return: The User of this User. :return: The User of this User. # noqa: E501
:rtype: User :rtype: User
""" """
return deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def id(self) -> int: def id(self) -> int:
""" """Gets the id of this User.
Gets the id of this User.
:return: The id of this User. :return: The id of this User.
:rtype: int :rtype: int
@ -90,8 +89,8 @@ class User(Model):
@id.setter @id.setter
def id(self, id: int): def id(self, id: int):
""" """Sets the id of this User.
Sets the id of this User.
:param id: The id of this User. :param id: The id of this User.
:type id: int :type id: int
@ -101,8 +100,8 @@ class User(Model):
@property @property
def username(self) -> str: def username(self) -> str:
""" """Gets the username of this User.
Gets the username of this User.
:return: The username of this User. :return: The username of this User.
:rtype: str :rtype: str
@ -111,8 +110,8 @@ class User(Model):
@username.setter @username.setter
def username(self, username: str): def username(self, username: str):
""" """Sets the username of this User.
Sets the username of this User.
:param username: The username of this User. :param username: The username of this User.
:type username: str :type username: str
@ -122,8 +121,8 @@ class User(Model):
@property @property
def first_name(self) -> str: def first_name(self) -> str:
""" """Gets the first_name of this User.
Gets the first_name of this User.
:return: The first_name of this User. :return: The first_name of this User.
:rtype: str :rtype: str
@ -132,8 +131,8 @@ class User(Model):
@first_name.setter @first_name.setter
def first_name(self, first_name: str): def first_name(self, first_name: str):
""" """Sets the first_name of this User.
Sets the first_name of this User.
:param first_name: The first_name of this User. :param first_name: The first_name of this User.
:type first_name: str :type first_name: str
@ -143,8 +142,8 @@ class User(Model):
@property @property
def last_name(self) -> str: def last_name(self) -> str:
""" """Gets the last_name of this User.
Gets the last_name of this User.
:return: The last_name of this User. :return: The last_name of this User.
:rtype: str :rtype: str
@ -153,8 +152,8 @@ class User(Model):
@last_name.setter @last_name.setter
def last_name(self, last_name: str): def last_name(self, last_name: str):
""" """Sets the last_name of this User.
Sets the last_name of this User.
:param last_name: The last_name of this User. :param last_name: The last_name of this User.
:type last_name: str :type last_name: str
@ -164,8 +163,8 @@ class User(Model):
@property @property
def email(self) -> str: def email(self) -> str:
""" """Gets the email of this User.
Gets the email of this User.
:return: The email of this User. :return: The email of this User.
:rtype: str :rtype: str
@ -174,8 +173,8 @@ class User(Model):
@email.setter @email.setter
def email(self, email: str): def email(self, email: str):
""" """Sets the email of this User.
Sets the email of this User.
:param email: The email of this User. :param email: The email of this User.
:type email: str :type email: str
@ -185,8 +184,8 @@ class User(Model):
@property @property
def password(self) -> str: def password(self) -> str:
""" """Gets the password of this User.
Gets the password of this User.
:return: The password of this User. :return: The password of this User.
:rtype: str :rtype: str
@ -195,8 +194,8 @@ class User(Model):
@password.setter @password.setter
def password(self, password: str): def password(self, password: str):
""" """Sets the password of this User.
Sets the password of this User.
:param password: The password of this User. :param password: The password of this User.
:type password: str :type password: str
@ -206,8 +205,8 @@ class User(Model):
@property @property
def phone(self) -> str: def phone(self) -> str:
""" """Gets the phone of this User.
Gets the phone of this User.
:return: The phone of this User. :return: The phone of this User.
:rtype: str :rtype: str
@ -216,8 +215,8 @@ class User(Model):
@phone.setter @phone.setter
def phone(self, phone: str): def phone(self, phone: str):
""" """Sets the phone of this User.
Sets the phone of this User.
:param phone: The phone of this User. :param phone: The phone of this User.
:type phone: str :type phone: str
@ -227,9 +226,9 @@ class User(Model):
@property @property
def user_status(self) -> int: def user_status(self) -> int:
""" """Gets the user_status of this User.
Gets the user_status of this User.
User Status User Status # noqa: E501
:return: The user_status of this User. :return: The user_status of this User.
:rtype: int :rtype: int
@ -238,13 +237,12 @@ class User(Model):
@user_status.setter @user_status.setter
def user_status(self, user_status: int): def user_status(self, user_status: int):
""" """Sets the user_status of this User.
Sets the user_status of this User.
User Status User Status # noqa: E501
:param user_status: The user_status of this User. :param user_status: The user_status of this User.
:type user_status: int :type user_status: int
""" """
self._user_status = user_status self._user_status = user_status

View File

@ -1,8 +1,10 @@
from flask_testing import TestCase
from ..encoder import JSONEncoder
import connexion
import logging import logging
import connexion
from flask_testing import TestCase
from swagger_server.encoder import JSONEncoder
class BaseTestCase(TestCase): class BaseTestCase(TestCase):

View File

@ -2,115 +2,124 @@
from __future__ import absolute_import from __future__ import absolute_import
from swagger_server.models.api_response import ApiResponse
from swagger_server.models.pet import Pet
from . import BaseTestCase
from six import BytesIO
from flask import json from flask import json
from six import BytesIO
from swagger_server.models.api_response import ApiResponse # noqa: E501
from swagger_server.models.pet import Pet # noqa: E501
from swagger_server.test import BaseTestCase
class TestPetController(BaseTestCase): class TestPetController(BaseTestCase):
""" PetController integration test stubs """ """PetController integration test stubs"""
def test_add_pet(self): def test_add_pet(self):
""" """Test case for add_pet
Test case for add_pet
Add a new pet to the store Add a new pet to the store
""" """
body = Pet() body = Pet()
response = self.client.open('/v2/pet', response = self.client.open(
method='POST', '/v2/pet',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_delete_pet(self): def test_delete_pet(self):
""" """Test case for delete_pet
Test case for delete_pet
Deletes a pet Deletes a pet
""" """
headers = [('api_key', 'api_key_example')] headers = [('api_key', 'api_key_example')]
response = self.client.open('/v2/pet/{petId}'.format(petId=789), response = self.client.open(
method='DELETE', '/v2/pet/{petId}'.format(petId=789),
headers=headers) method='DELETE',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) headers=headers)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_find_pets_by_status(self): def test_find_pets_by_status(self):
""" """Test case for find_pets_by_status
Test case for find_pets_by_status
Finds Pets by status Finds Pets by status
""" """
query_string = [('status', 'available')] query_string = [('status', 'available')]
response = self.client.open('/v2/pet/findByStatus', response = self.client.open(
method='GET', '/v2/pet/findByStatus',
query_string=query_string) method='GET',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) query_string=query_string)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_find_pets_by_tags(self): def test_find_pets_by_tags(self):
""" """Test case for find_pets_by_tags
Test case for find_pets_by_tags
Finds Pets by tags Finds Pets by tags
""" """
query_string = [('tags', 'tags_example')] query_string = [('tags', 'tags_example')]
response = self.client.open('/v2/pet/findByTags', response = self.client.open(
method='GET', '/v2/pet/findByTags',
query_string=query_string) method='GET',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) query_string=query_string)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_pet_by_id(self): def test_get_pet_by_id(self):
""" """Test case for get_pet_by_id
Test case for get_pet_by_id
Find pet by ID Find pet by ID
""" """
response = self.client.open('/v2/pet/{petId}'.format(petId=789), response = self.client.open(
method='GET') '/v2/pet/{petId}'.format(petId=789),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_update_pet(self): def test_update_pet(self):
""" """Test case for update_pet
Test case for update_pet
Update an existing pet Update an existing pet
""" """
body = Pet() body = Pet()
response = self.client.open('/v2/pet', response = self.client.open(
method='PUT', '/v2/pet',
data=json.dumps(body), method='PUT',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_update_pet_with_form(self): def test_update_pet_with_form(self):
""" """Test case for update_pet_with_form
Test case for update_pet_with_form
Updates a pet in the store with form data Updates a pet in the store with form data
""" """
data = dict(name='name_example', data = dict(name='name_example',
status='status_example') status='status_example')
response = self.client.open('/v2/pet/{petId}'.format(petId=789), response = self.client.open(
method='POST', '/v2/pet/{petId}'.format(petId=789),
data=data, method='POST',
content_type='application/x-www-form-urlencoded') data=data,
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/x-www-form-urlencoded')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_upload_file(self): def test_upload_file(self):
""" """Test case for upload_file
Test case for upload_file
uploads an image uploads an image
""" """
data = dict(additionalMetadata='additionalMetadata_example', data = dict(additionalMetadata='additionalMetadata_example',
file=(BytesIO(b'some file data'), 'file.txt')) file=(BytesIO(b'some file data'), 'file.txt'))
response = self.client.open('/v2/pet/{petId}/uploadImage'.format(petId=789), response = self.client.open(
method='POST', '/v2/pet/{petId}/uploadImage'.format(petId=789),
data=data, method='POST',
content_type='multipart/form-data') data=data,
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='multipart/form-data')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -2,57 +2,62 @@
from __future__ import absolute_import from __future__ import absolute_import
from swagger_server.models.order import Order
from . import BaseTestCase
from six import BytesIO
from flask import json from flask import json
from six import BytesIO
from swagger_server.models.order import Order # noqa: E501
from swagger_server.test import BaseTestCase
class TestStoreController(BaseTestCase): class TestStoreController(BaseTestCase):
""" StoreController integration test stubs """ """StoreController integration test stubs"""
def test_delete_order(self): def test_delete_order(self):
""" """Test case for delete_order
Test case for delete_order
Delete purchase order by ID Delete purchase order by ID
""" """
response = self.client.open('/v2/store/order/{orderId}'.format(orderId='orderId_example'), response = self.client.open(
method='DELETE') '/v2/store/order/{orderId}'.format(orderId='orderId_example'),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='DELETE')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_inventory(self): def test_get_inventory(self):
""" """Test case for get_inventory
Test case for get_inventory
Returns pet inventories by status Returns pet inventories by status
""" """
response = self.client.open('/v2/store/inventory', response = self.client.open(
method='GET') '/v2/store/inventory',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_order_by_id(self): def test_get_order_by_id(self):
""" """Test case for get_order_by_id
Test case for get_order_by_id
Find purchase order by ID Find purchase order by ID
""" """
response = self.client.open('/v2/store/order/{orderId}'.format(orderId=5), response = self.client.open(
method='GET') '/v2/store/order/{orderId}'.format(orderId=5),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_place_order(self): def test_place_order(self):
""" """Test case for place_order
Test case for place_order
Place an order for a pet Place an order for a pet
""" """
body = Order() body = Order()
response = self.client.open('/v2/store/order', response = self.client.open(
method='POST', '/v2/store/order',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -2,109 +2,118 @@
from __future__ import absolute_import from __future__ import absolute_import
from swagger_server.models.user import User
from . import BaseTestCase
from six import BytesIO
from flask import json from flask import json
from six import BytesIO
from swagger_server.models.user import User # noqa: E501
from swagger_server.test import BaseTestCase
class TestUserController(BaseTestCase): class TestUserController(BaseTestCase):
""" UserController integration test stubs """ """UserController integration test stubs"""
def test_create_user(self): def test_create_user(self):
""" """Test case for create_user
Test case for create_user
Create user Create user
""" """
body = User() body = User()
response = self.client.open('/v2/user', response = self.client.open(
method='POST', '/v2/user',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_create_users_with_array_input(self): def test_create_users_with_array_input(self):
""" """Test case for create_users_with_array_input
Test case for create_users_with_array_input
Creates list of users with given input array Creates list of users with given input array
""" """
body = [User()] body = [User()]
response = self.client.open('/v2/user/createWithArray', response = self.client.open(
method='POST', '/v2/user/createWithArray',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_create_users_with_list_input(self): def test_create_users_with_list_input(self):
""" """Test case for create_users_with_list_input
Test case for create_users_with_list_input
Creates list of users with given input array Creates list of users with given input array
""" """
body = [User()] body = [User()]
response = self.client.open('/v2/user/createWithList', response = self.client.open(
method='POST', '/v2/user/createWithList',
data=json.dumps(body), method='POST',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_delete_user(self): def test_delete_user(self):
""" """Test case for delete_user
Test case for delete_user
Delete user Delete user
""" """
response = self.client.open('/v2/user/{username}'.format(username='username_example'), response = self.client.open(
method='DELETE') '/v2/user/{username}'.format(username='username_example'),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='DELETE')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_user_by_name(self): def test_get_user_by_name(self):
""" """Test case for get_user_by_name
Test case for get_user_by_name
Get user by user name Get user by user name
""" """
response = self.client.open('/v2/user/{username}'.format(username='username_example'), response = self.client.open(
method='GET') '/v2/user/{username}'.format(username='username_example'),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_login_user(self): def test_login_user(self):
""" """Test case for login_user
Test case for login_user
Logs user into the system Logs user into the system
""" """
query_string = [('username', 'username_example'), query_string = [('username', 'username_example'),
('password', 'password_example')] ('password', 'password_example')]
response = self.client.open('/v2/user/login', response = self.client.open(
method='GET', '/v2/user/login',
query_string=query_string) method='GET',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) query_string=query_string)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_logout_user(self): def test_logout_user(self):
""" """Test case for logout_user
Test case for logout_user
Logs out current logged in user session Logs out current logged in user session
""" """
response = self.client.open('/v2/user/logout', response = self.client.open(
method='GET') '/v2/user/logout',
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) method='GET')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_update_user(self): def test_update_user(self):
""" """Test case for update_user
Test case for update_user
Updated user Updated user
""" """
body = User() body = User()
response = self.client.open('/v2/user/{username}'.format(username='username_example'), response = self.client.open(
method='PUT', '/v2/user/{username}'.format(username='username_example'),
data=json.dumps(body), method='PUT',
content_type='application/json') data=json.dumps(body),
self.assert200(response, "Response body is : " + response.data.decode('utf-8')) content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1,11 +1,11 @@
from typing import GenericMeta import datetime
from datetime import datetime, date
from six import integer_types, iteritems import six
import typing
def _deserialize(data, klass): def _deserialize(data, klass):
""" """Deserializes dict, list, str into an object.
Deserializes dict, list, str into an object.
:param data: dict, list or str. :param data: dict, list or str.
:param klass: class literal, or string of class name. :param klass: class literal, or string of class name.
@ -15,15 +15,15 @@ def _deserialize(data, klass):
if data is None: if data is None:
return None return None
if klass in integer_types or klass in (float, str, bool): if klass in six.integer_types or klass in (float, str, bool):
return _deserialize_primitive(data, klass) return _deserialize_primitive(data, klass)
elif klass == object: elif klass == object:
return _deserialize_object(data) return _deserialize_object(data)
elif klass == date: elif klass == datetime.date:
return deserialize_date(data) return deserialize_date(data)
elif klass == datetime: elif klass == datetime.datetime:
return deserialize_datetime(data) return deserialize_datetime(data)
elif type(klass) == GenericMeta: elif type(klass) == typing.GenericMeta:
if klass.__extra__ == list: if klass.__extra__ == list:
return _deserialize_list(data, klass.__args__[0]) return _deserialize_list(data, klass.__args__[0])
if klass.__extra__ == dict: if klass.__extra__ == dict:
@ -33,8 +33,7 @@ def _deserialize(data, klass):
def _deserialize_primitive(data, klass): def _deserialize_primitive(data, klass):
""" """Deserializes to primitive type.
Deserializes to primitive type.
:param data: data to deserialize. :param data: data to deserialize.
:param klass: class literal. :param klass: class literal.
@ -52,8 +51,7 @@ def _deserialize_primitive(data, klass):
def _deserialize_object(value): def _deserialize_object(value):
""" """Return a original value.
Return a original value.
:return: object. :return: object.
""" """
@ -61,8 +59,7 @@ def _deserialize_object(value):
def deserialize_date(string): def deserialize_date(string):
""" """Deserializes string to date.
Deserializes string to date.
:param string: str. :param string: str.
:type string: str :type string: str
@ -77,8 +74,7 @@ def deserialize_date(string):
def deserialize_datetime(string): def deserialize_datetime(string):
""" """Deserializes string to datetime.
Deserializes string to datetime.
The string should be in iso8601 datetime format. The string should be in iso8601 datetime format.
@ -95,8 +91,7 @@ def deserialize_datetime(string):
def deserialize_model(data, klass): def deserialize_model(data, klass):
""" """Deserializes list or dict to model.
Deserializes list or dict to model.
:param data: dict, list. :param data: dict, list.
:type data: dict | list :type data: dict | list
@ -108,7 +103,7 @@ def deserialize_model(data, klass):
if not instance.swagger_types: if not instance.swagger_types:
return data return data
for attr, attr_type in iteritems(instance.swagger_types): for attr, attr_type in six.iteritems(instance.swagger_types):
if data is not None \ if data is not None \
and instance.attribute_map[attr] in data \ and instance.attribute_map[attr] in data \
and isinstance(data, (list, dict)): and isinstance(data, (list, dict)):
@ -119,8 +114,7 @@ def deserialize_model(data, klass):
def _deserialize_list(data, boxed_type): def _deserialize_list(data, boxed_type):
""" """Deserializes a list and its elements.
Deserializes a list and its elements.
:param data: list to deserialize. :param data: list to deserialize.
:type data: list :type data: list
@ -133,10 +127,8 @@ def _deserialize_list(data, boxed_type):
for sub_data in data] for sub_data in data]
def _deserialize_dict(data, boxed_type): def _deserialize_dict(data, boxed_type):
""" """Deserializes a dict and its elements.
Deserializes a dict and its elements.
:param data: dict to deserialize. :param data: dict to deserialize.
:type data: dict :type data: dict
@ -146,4 +138,4 @@ def _deserialize_dict(data, boxed_type):
:rtype: dict :rtype: dict
""" """
return {k: _deserialize(v, boxed_type) return {k: _deserialize(v, boxed_type)
for k, v in iteritems(data)} for k, v in six.iteritems(data)}