Skip to content

Commit 59da358

Browse files
committed
Merge branch 'master' of github.com:wordnik/swagger-codegen
2 parents b815ffa + af96f33 commit 59da358

File tree

20 files changed

+293
-103
lines changed

20 files changed

+293
-103
lines changed

samples/client/petstore/python/swagger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def deserialize(self, obj, objClass):
159159
instance = objClass()
160160

161161
for attr, attrType in instance.swaggerTypes.iteritems():
162-
if attr in obj:
162+
if obj is not None and attr in obj and type(obj) in [list, dict]:
163163
value = obj[attr]
164164
if attrType in ['str', 'int', 'long', 'float', 'bool']:
165165
attrType = eval(attrType)

samples/client/petstore/python3/PetApi.py

Lines changed: 159 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def getPetById(self, petId, **kwargs):
3333
"""Find pet by ID
3434
3535
Args:
36-
petId, str: ID of pet that needs to be fetched (required)
36+
petId, int: ID of pet that needs to be fetched (required)
3737
3838
Returns: Pet
3939
"""
@@ -47,7 +47,7 @@ def getPetById(self, petId, **kwargs):
4747
params[key] = val
4848
del params['kwargs']
4949

50-
resourcePath = '/pet.{format}/{petId}'
50+
resourcePath = '/pet/{petId}'
5151
resourcePath = resourcePath.replace('{format}', 'json')
5252
method = 'GET'
5353

@@ -70,6 +70,155 @@ def getPetById(self, petId, **kwargs):
7070
return responseObject
7171

7272

73+
def deletePet(self, petId, **kwargs):
74+
"""Deletes a pet
75+
76+
Args:
77+
petId, str: Pet id to delete (required)
78+
79+
Returns:
80+
"""
81+
82+
allParams = ['petId']
83+
84+
params = locals()
85+
for (key, val) in params['kwargs'].items():
86+
if key not in allParams:
87+
raise TypeError("Got an unexpected keyword argument '%s' to method deletePet" % key)
88+
params[key] = val
89+
del params['kwargs']
90+
91+
resourcePath = '/pet/{petId}'
92+
resourcePath = resourcePath.replace('{format}', 'json')
93+
method = 'DELETE'
94+
95+
queryParams = {}
96+
headerParams = {}
97+
98+
if ('petId' in params):
99+
replacement = str(self.apiClient.toPathValue(params['petId']))
100+
resourcePath = resourcePath.replace('{' + 'petId' + '}',
101+
replacement)
102+
postData = (params['body'] if 'body' in params else None)
103+
104+
response = self.apiClient.callAPI(resourcePath, method, queryParams,
105+
postData, headerParams)
106+
107+
108+
109+
def partialUpdate(self, petId, body, **kwargs):
110+
"""partial updates to a pet
111+
112+
Args:
113+
petId, str: ID of pet that needs to be fetched (required)
114+
body, Pet: Pet object that needs to be added to the store (required)
115+
116+
Returns: Array[Pet]
117+
"""
118+
119+
allParams = ['petId', 'body']
120+
121+
params = locals()
122+
for (key, val) in params['kwargs'].items():
123+
if key not in allParams:
124+
raise TypeError("Got an unexpected keyword argument '%s' to method partialUpdate" % key)
125+
params[key] = val
126+
del params['kwargs']
127+
128+
resourcePath = '/pet/{petId}'
129+
resourcePath = resourcePath.replace('{format}', 'json')
130+
method = 'PATCH'
131+
132+
queryParams = {}
133+
headerParams = {}
134+
135+
if ('petId' in params):
136+
replacement = str(self.apiClient.toPathValue(params['petId']))
137+
resourcePath = resourcePath.replace('{' + 'petId' + '}',
138+
replacement)
139+
postData = (params['body'] if 'body' in params else None)
140+
141+
response = self.apiClient.callAPI(resourcePath, method, queryParams,
142+
postData, headerParams)
143+
144+
if not response:
145+
return None
146+
147+
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
148+
return responseObject
149+
150+
151+
def updatePetWithForm(self, petId, **kwargs):
152+
"""Updates a pet in the store with form data
153+
154+
Args:
155+
petId, str: ID of pet that needs to be updated (required)
156+
name, str: Updated name of the pet (optional)
157+
status, str: Updated status of the pet (optional)
158+
159+
Returns:
160+
"""
161+
162+
allParams = ['petId', 'name', 'status']
163+
164+
params = locals()
165+
for (key, val) in params['kwargs'].items():
166+
if key not in allParams:
167+
raise TypeError("Got an unexpected keyword argument '%s' to method updatePetWithForm" % key)
168+
params[key] = val
169+
del params['kwargs']
170+
171+
resourcePath = '/pet/{petId}'
172+
resourcePath = resourcePath.replace('{format}', 'json')
173+
method = 'POST'
174+
175+
queryParams = {}
176+
headerParams = {}
177+
178+
if ('petId' in params):
179+
replacement = str(self.apiClient.toPathValue(params['petId']))
180+
resourcePath = resourcePath.replace('{' + 'petId' + '}',
181+
replacement)
182+
postData = (params['body'] if 'body' in params else None)
183+
184+
response = self.apiClient.callAPI(resourcePath, method, queryParams,
185+
postData, headerParams)
186+
187+
188+
189+
def uploadFile(self, **kwargs):
190+
"""uploads an image
191+
192+
Args:
193+
additionalMetadata, str: Additional data to pass to server (optional)
194+
body, File: file to upload (optional)
195+
196+
Returns:
197+
"""
198+
199+
allParams = ['additionalMetadata', 'body']
200+
201+
params = locals()
202+
for (key, val) in params['kwargs'].items():
203+
if key not in allParams:
204+
raise TypeError("Got an unexpected keyword argument '%s' to method uploadFile" % key)
205+
params[key] = val
206+
del params['kwargs']
207+
208+
resourcePath = '/pet/uploadImage'
209+
resourcePath = resourcePath.replace('{format}', 'json')
210+
method = 'POST'
211+
212+
queryParams = {}
213+
headerParams = {}
214+
215+
postData = (params['body'] if 'body' in params else None)
216+
217+
response = self.apiClient.callAPI(resourcePath, method, queryParams,
218+
postData, headerParams)
219+
220+
221+
73222
def addPet(self, body, **kwargs):
74223
"""Add a new pet to the store
75224
@@ -88,7 +237,7 @@ def addPet(self, body, **kwargs):
88237
params[key] = val
89238
del params['kwargs']
90239

91-
resourcePath = '/pet.{format}'
240+
resourcePath = '/pet'
92241
resourcePath = resourcePath.replace('{format}', 'json')
93242
method = 'POST'
94243

@@ -120,7 +269,7 @@ def updatePet(self, body, **kwargs):
120269
params[key] = val
121270
del params['kwargs']
122271

123-
resourcePath = '/pet.{format}'
272+
resourcePath = '/pet'
124273
resourcePath = resourcePath.replace('{format}', 'json')
125274
method = 'PUT'
126275

@@ -140,7 +289,7 @@ def findPetsByStatus(self, status= None, **kwargs):
140289
Args:
141290
status, str: Status values that need to be considered for filter (required)
142291
143-
Returns: list[Pet]
292+
Returns: Array[Pet]
144293
"""
145294

146295
allParams = ['status']
@@ -152,7 +301,7 @@ def findPetsByStatus(self, status= None, **kwargs):
152301
params[key] = val
153302
del params['kwargs']
154303

155-
resourcePath = '/pet.{format}/findByStatus'
304+
resourcePath = '/pet/findByStatus'
156305
resourcePath = resourcePath.replace('{format}', 'json')
157306
method = 'GET'
158307

@@ -169,7 +318,7 @@ def findPetsByStatus(self, status= None, **kwargs):
169318
if not response:
170319
return None
171320

172-
responseObject = self.apiClient.deserialize(response, 'list[Pet]')
321+
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
173322
return responseObject
174323

175324

@@ -179,7 +328,7 @@ def findPetsByTags(self, tags, **kwargs):
179328
Args:
180329
tags, str: Tags to filter by (required)
181330
182-
Returns: list[Pet]
331+
Returns: Array[Pet]
183332
"""
184333

185334
allParams = ['tags']
@@ -191,7 +340,7 @@ def findPetsByTags(self, tags, **kwargs):
191340
params[key] = val
192341
del params['kwargs']
193342

194-
resourcePath = '/pet.{format}/findByTags'
343+
resourcePath = '/pet/findByTags'
195344
resourcePath = resourcePath.replace('{format}', 'json')
196345
method = 'GET'
197346

@@ -208,7 +357,7 @@ def findPetsByTags(self, tags, **kwargs):
208357
if not response:
209358
return None
210359

211-
responseObject = self.apiClient.deserialize(response, 'list[Pet]')
360+
responseObject = self.apiClient.deserialize(response, 'Array[Pet]')
212361
return responseObject
213362

214363

samples/client/petstore/python3/StoreApi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def getOrderById(self, orderId, **kwargs):
4747
params[key] = val
4848
del params['kwargs']
4949

50-
resourcePath = '/store.{format}/order/{orderId}'
50+
resourcePath = '/store/order/{orderId}'
5151
resourcePath = resourcePath.replace('{format}', 'json')
5252
method = 'GET'
5353

@@ -88,7 +88,7 @@ def deleteOrder(self, orderId, **kwargs):
8888
params[key] = val
8989
del params['kwargs']
9090

91-
resourcePath = '/store.{format}/order/{orderId}'
91+
resourcePath = '/store/order/{orderId}'
9292
resourcePath = resourcePath.replace('{format}', 'json')
9393
method = 'DELETE'
9494

@@ -124,7 +124,7 @@ def placeOrder(self, body, **kwargs):
124124
params[key] = val
125125
del params['kwargs']
126126

127-
resourcePath = '/store.{format}/order'
127+
resourcePath = '/store/order'
128128
resourcePath = resourcePath.replace('{format}', 'json')
129129
method = 'POST'
130130

0 commit comments

Comments
 (0)