Skip to content

Commit 82c3963

Browse files
committed
Merge branch 'maneeshsahu-master'
2 parents ef1666d + 89befeb commit 82c3963

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

modules/swagger-codegen/src/main/resources/python/api_client.mustache

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ except ImportError:
4646
# for python2
4747
from urllib import quote
4848

49+
# special handling of `long` (python2 only)
50+
try:
51+
# Python 2
52+
long
53+
except NameError:
54+
# Python 3
55+
long = int
56+
4957
from .configuration import Configuration
5058

5159

@@ -183,7 +191,7 @@ class ApiClient(object):
183191
Builds a JSON POST object.
184192

185193
If obj is None, return None.
186-
If obj is str, int, float, bool, return directly.
194+
If obj is str, int, long, float, bool, return directly.
187195
If obj is datetime.datetime, datetime.date
188196
convert to string in iso8601 format.
189197
If obj is list, sanitize each element in the list.
@@ -193,7 +201,7 @@ class ApiClient(object):
193201
:param obj: The data to serialize.
194202
:return: The serialized form of data.
195203
"""
196-
types = (str, int, float, bool, tuple)
204+
types = (str, int, long, float, bool, tuple)
197205
if sys.version_info < (3, 0):
198206
types = types + (unicode,)
199207
if isinstance(obj, type(None)):
@@ -269,14 +277,14 @@ class ApiClient(object):
269277

270278
# convert str to class
271279
# for native types
272-
if klass in ['int', 'float', 'str', 'bool',
280+
if klass in ['int', 'long', 'float', 'str', 'bool',
273281
"date", 'datetime', "object"]:
274282
klass = eval(klass)
275283
# for model types
276284
else:
277285
klass = eval('models.' + klass)
278286

279-
if klass in [int, float, str, bool]:
287+
if klass in [int, long, float, str, bool]:
280288
return self.__deserialize_primitive(data, klass)
281289
elif klass == object:
282290
return self.__deserialize_object(data)
@@ -505,7 +513,7 @@ class ApiClient(object):
505513
:param data: str.
506514
:param klass: class literal.
507515

508-
:return: int, float, str, bool.
516+
:return: int, long, float, str, bool.
509517
"""
510518
try:
511519
value = klass(data)

samples/client/petstore/python/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https://
55

66
- API version: 1.0.0
77
- Package version: 1.0.0
8-
- Build date: 2016-07-06T16:27:27.842+08:00
8+
- Build date: 2016-07-07T22:03:52.761+08:00
99
- Build package: class io.swagger.codegen.languages.PythonClientCodegen
1010

1111
## Requirements.

samples/client/petstore/python/petstore_api/api_client.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
# for python2
4747
from urllib import quote
4848

49+
# special handling of `long` (python2 only)
50+
try:
51+
# Python 2
52+
long
53+
except NameError:
54+
# Python 3
55+
long = int
56+
4957
from .configuration import Configuration
5058

5159

@@ -183,7 +191,7 @@ def sanitize_for_serialization(self, obj):
183191
Builds a JSON POST object.
184192
185193
If obj is None, return None.
186-
If obj is str, int, float, bool, return directly.
194+
If obj is str, int, long, float, bool, return directly.
187195
If obj is datetime.datetime, datetime.date
188196
convert to string in iso8601 format.
189197
If obj is list, sanitize each element in the list.
@@ -193,7 +201,7 @@ def sanitize_for_serialization(self, obj):
193201
:param obj: The data to serialize.
194202
:return: The serialized form of data.
195203
"""
196-
types = (str, int, float, bool, tuple)
204+
types = (str, int, long, float, bool, tuple)
197205
if sys.version_info < (3, 0):
198206
types = types + (unicode,)
199207
if isinstance(obj, type(None)):
@@ -269,14 +277,14 @@ def __deserialize(self, data, klass):
269277

270278
# convert str to class
271279
# for native types
272-
if klass in ['int', 'float', 'str', 'bool',
280+
if klass in ['int', 'long', 'float', 'str', 'bool',
273281
"date", 'datetime', "object"]:
274282
klass = eval(klass)
275283
# for model types
276284
else:
277285
klass = eval('models.' + klass)
278286

279-
if klass in [int, float, str, bool]:
287+
if klass in [int, long, float, str, bool]:
280288
return self.__deserialize_primitive(data, klass)
281289
elif klass == object:
282290
return self.__deserialize_object(data)
@@ -505,7 +513,7 @@ def __deserialize_primitive(self, data, klass):
505513
:param data: str.
506514
:param klass: class literal.
507515
508-
:return: int, float, str, bool.
516+
:return: int, long, float, str, bool.
509517
"""
510518
try:
511519
value = klass(data)

0 commit comments

Comments
 (0)