Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,13 @@ samples/client/petstore/csharp-refactor/OpenAPIClient/nuget.exe
# Python
*.pyc
__pycache__
.venv/
samples/client/petstore/python/dev-requirements.txt.log
samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt
samples/client/petstore/python/.coverage
samples/client/petstore/python/.projectile
samples/client/petstore/python/.venv/
samples/client/petstore/python-asyncio/.venv/
samples/client/petstore/python-asyncio/.pytest_cache/
samples/client/petstore/python-tornado/.venv/


# PHP
samples/client/petstore/php/OpenAPIClient-php/composer.lock
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# coding: utf-8

# flake8: noqa
from __future__ import absolute_import
# import models into model package
{{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}}
{{/models}}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import pprint

import six
import typing

from {{packageName}} import util

T = typing.TypeVar('T')


class Model(object):
class Model:
# openapiTypes: The key is attribute name and the
# value is attribute type.
openapi_types: typing.Dict[str, type] = {}
Expand All @@ -29,7 +28,7 @@ class Model(object):
"""
result = {}

for attr, _ in six.iteritems(self.openapi_types):
for attr in self.openapi_types:
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import connexion
import six
from typing import Dict
from typing import Tuple
from typing import Union
Expand Down Expand Up @@ -97,15 +96,15 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{
{{#items}}
{{#isDate}}
if connexion.request.is_json:
{{paramName}} = {k: util.deserialize_date(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{paramName}} = {k: util.deserialize_date(v) for k, v in connexion.request.get_json().items()} # noqa: E501
{{/isDate}}
{{#isDateTime}}
if connexion.request.is_json:
{{paramName}} = {k: util.deserialize_datetime(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{paramName}} = {k: util.deserialize_datetime(v) for k, v in connexion.request.get_json().items()} # noqa: E501
{{/isDateTime}}
{{#complexType}}
if connexion.request.is_json:
{{paramName}} = {k: {{baseType}}.from_dict(v) for k, v in six.iteritems(connexion.request.get_json())} # noqa: E501
{{paramName}} = {k: {{baseType}}.from_dict(v) for k, v in connexion.request.get_json().items()} # noqa: E501
{{/complexType}}
{{/items}}
{{/isMap}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# coding: utf-8

from __future__ import absolute_import
import unittest

from flask import json
from six import BytesIO

{{#imports}}{{import}} # noqa: E501
{{/imports}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from connexion.apps.flask_app import FlaskJSONEncoder
import six

from {{modelPackage}}.base_model import Model

Expand All @@ -10,7 +9,7 @@ class JSONEncoder(FlaskJSONEncoder):
def default(self, o):
if isinstance(o, Model):
dikt = {}
for attr, _ in six.iteritems(o.openapi_types):
for attr in o.openapi_types:
value = getattr(o, attr)
if value is None and not self.include_nulls:
continue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import absolute_import
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# coding: utf-8

import sys
from setuptools import setup, find_packages

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# coding: utf-8

import sys

if sys.version_info < (3, 7):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime

import six
import typing
from {{packageName}} import typing_utils

Expand All @@ -16,7 +15,7 @@ def _deserialize(data, klass):
if data is None:
return None

if klass in six.integer_types or klass in (float, str, bool, bytearray):
if klass in (int, float, str, bool, bytearray):
return _deserialize_primitive(data, klass)
elif klass == object:
return _deserialize_object(data)
Expand Down Expand Up @@ -45,7 +44,7 @@ def _deserialize_primitive(data, klass):
try:
value = klass(data)
except UnicodeEncodeError:
value = six.u(data)
value = data
except TypeError:
value = data
return value
Expand Down Expand Up @@ -110,7 +109,7 @@ def deserialize_model(data, klass):
if not instance.openapi_types:
return data

for attr, attr_type in six.iteritems(instance.openapi_types):
for attr, attr_type in instance.openapi_types.items():
if data is not None \
and instance.attribute_map[attr] in data \
and isinstance(data, (list, dict)):
Expand Down Expand Up @@ -145,4 +144,4 @@ def _deserialize_dict(data, boxed_type):
:rtype: dict
"""
return {k: _deserialize(v, boxed_type)
for k, v in six.iteritems(data)}
for k, v in data.items() }
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import connexion
import six
from typing import Dict
from typing import Tuple
from typing import Union
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import connexion
import six
from typing import Dict
from typing import Tuple
from typing import Union
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import connexion
import six
from typing import Dict
from typing import Tuple
from typing import Union
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from connexion.apps.flask_app import FlaskJSONEncoder
import six

from openapi_server.models.base_model import Model

Expand All @@ -10,7 +9,7 @@ class JSONEncoder(FlaskJSONEncoder):
def default(self, o):
if isinstance(o, Model):
dikt = {}
for attr, _ in six.iteritems(o.openapi_types):
for attr in o.openapi_types:
value = getattr(o, attr)
if value is None and not self.include_nulls:
continue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# coding: utf-8

# flake8: noqa
from __future__ import absolute_import
# import models into model package
from openapi_server.models.api_response import ApiResponse
from openapi_server.models.category import Category
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import absolute_import
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import pprint

import six
import typing

from openapi_server import util

T = typing.TypeVar('T')


class Model(object):
class Model:
# openapiTypes: The key is attribute name and the
# value is attribute type.
openapi_types: typing.Dict[str, type] = {}
Expand All @@ -29,7 +28,7 @@ def to_dict(self):
"""
result = {}

for attr, _ in six.iteritems(self.openapi_types):
for attr in self.openapi_types:
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import absolute_import
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import absolute_import
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import absolute_import
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import absolute_import
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# coding: utf-8

from __future__ import absolute_import
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# coding: utf-8

from __future__ import absolute_import
import unittest

from flask import json
from six import BytesIO

from openapi_server.models.api_response import ApiResponse # noqa: E501
from openapi_server.models.pet import Pet # noqa: E501
Expand All @@ -20,23 +16,7 @@ def test_add_pet(self):

Add a new pet to the store
"""
body = {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
}
body = {"photoUrls":["photoUrls","photoUrls"],"name":"doggie","id":0,"category":{"name":"name","id":6},"tags":[{"name":"name","id":1},{"name":"name","id":1}],"status":"available"}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer special-key',
Expand Down Expand Up @@ -71,7 +51,7 @@ def test_find_pets_by_status(self):

Finds Pets by status
"""
query_string = [('status', 'available')]
query_string = [('status', ['status_example'])]
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer special-key',
Expand Down Expand Up @@ -124,23 +104,7 @@ def test_update_pet(self):

Update an existing pet
"""
body = {
"photoUrls" : [ "photoUrls", "photoUrls" ],
"name" : "doggie",
"id" : 0,
"category" : {
"name" : "name",
"id" : 6
},
"tags" : [ {
"name" : "name",
"id" : 1
}, {
"name" : "name",
"id" : 1
} ],
"status" : "available"
}
body = {"photoUrls":["photoUrls","photoUrls"],"name":"doggie","id":0,"category":{"name":"name","id":6},"tags":[{"name":"name","id":1},{"name":"name","id":1}],"status":"available"}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer special-key',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# coding: utf-8

from __future__ import absolute_import
import unittest

from flask import json
from six import BytesIO

from openapi_server.models.order import Order # noqa: E501
from openapi_server.test import BaseTestCase
Expand Down Expand Up @@ -52,7 +48,7 @@ def test_get_order_by_id(self):
'Accept': 'application/json',
}
response = self.client.open(
'/v2/store/order/{order_id}'.format(order_id=1),
'/v2/store/order/{order_id}'.format(order_id=56),
method='GET',
headers=headers)
self.assert200(response,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# coding: utf-8

from __future__ import absolute_import
import unittest

from flask import json
from six import BytesIO

from openapi_server.models.user import User # noqa: E501
from openapi_server.test import BaseTestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# coding: utf-8

import sys

if sys.version_info < (3, 7):
Expand Down
Loading