Skip to content

Commit 7d69107

Browse files
committed
Merge pull request #1356 from arnested/deserialize-httpHeader
Deserialize httpHeader.
2 parents 4d2fb1c + 3bd4502 commit 7d69107

File tree

4 files changed

+84
-45
lines changed

4 files changed

+84
-45
lines changed

modules/swagger-codegen/src/main/resources/php/api.mustache

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ use \{{invokerPackage}}\ObjectSerializer;
170170
$queryParams, $httpBody,
171171
$headerParams{{#returnType}}, '{{returnType}}'{{/returnType}}
172172
);
173+
{{#returnType}}
174+
if (!$response) {
175+
return null;
176+
}
177+
178+
return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader);
179+
{{/returnType}}
173180
} catch (ApiException $e) {
174181
switch ($e->getCode()) { {{#responses}}{{#dataType}}
175182
case {{code}}:
@@ -181,11 +188,7 @@ use \{{invokerPackage}}\ObjectSerializer;
181188
throw $e;
182189
}
183190
{{#returnType}}
184-
if (!$response) {
185-
return null;
186-
}
187-
188-
return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}');
191+
return null;
189192
{{/returnType}}
190193
}
191194
{{/operation}}

samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public function updatePet($body=null)
146146
$queryParams, $httpBody,
147147
$headerParams
148148
);
149+
149150
} catch (ApiException $e) {
150151
switch ($e->getCode()) {
151152
}
@@ -210,6 +211,7 @@ public function addPet($body=null)
210211
$queryParams, $httpBody,
211212
$headerParams
212213
);
214+
213215
} catch (ApiException $e) {
214216
switch ($e->getCode()) {
215217
}
@@ -273,6 +275,13 @@ public function findPetsByStatus($status=null)
273275
$queryParams, $httpBody,
274276
$headerParams, '\Swagger\Client\Model\Pet[]'
275277
);
278+
279+
if (!$response) {
280+
return null;
281+
}
282+
283+
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader);
284+
276285
} catch (ApiException $e) {
277286
switch ($e->getCode()) {
278287
case 200:
@@ -284,11 +293,7 @@ public function findPetsByStatus($status=null)
284293
throw $e;
285294
}
286295

287-
if (!$response) {
288-
return null;
289-
}
290-
291-
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]');
296+
return null;
292297

293298
}
294299

@@ -346,6 +351,13 @@ public function findPetsByTags($tags=null)
346351
$queryParams, $httpBody,
347352
$headerParams, '\Swagger\Client\Model\Pet[]'
348353
);
354+
355+
if (!$response) {
356+
return null;
357+
}
358+
359+
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader);
360+
349361
} catch (ApiException $e) {
350362
switch ($e->getCode()) {
351363
case 200:
@@ -357,11 +369,7 @@ public function findPetsByTags($tags=null)
357369
throw $e;
358370
}
359371

360-
if (!$response) {
361-
return null;
362-
}
363-
364-
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]');
372+
return null;
365373

366374
}
367375

@@ -434,6 +442,13 @@ public function getPetById($pet_id)
434442
$queryParams, $httpBody,
435443
$headerParams, '\Swagger\Client\Model\Pet'
436444
);
445+
446+
if (!$response) {
447+
return null;
448+
}
449+
450+
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader);
451+
437452
} catch (ApiException $e) {
438453
switch ($e->getCode()) {
439454
case 200:
@@ -445,11 +460,7 @@ public function getPetById($pet_id)
445460
throw $e;
446461
}
447462

448-
if (!$response) {
449-
return null;
450-
}
451-
452-
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet');
463+
return null;
453464

454465
}
455466

@@ -523,6 +534,7 @@ public function updatePetWithForm($pet_id, $name=null, $status=null)
523534
$queryParams, $httpBody,
524535
$headerParams
525536
);
537+
526538
} catch (ApiException $e) {
527539
switch ($e->getCode()) {
528540
}
@@ -598,6 +610,7 @@ public function deletePet($pet_id, $api_key=null)
598610
$queryParams, $httpBody,
599611
$headerParams
600612
);
613+
601614
} catch (ApiException $e) {
602615
switch ($e->getCode()) {
603616
}
@@ -677,6 +690,7 @@ public function uploadFile($pet_id, $additional_metadata=null, $file=null)
677690
$queryParams, $httpBody,
678691
$headerParams
679692
);
693+
680694
} catch (ApiException $e) {
681695
switch ($e->getCode()) {
682696
}

samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ public function getInventory()
145145
$queryParams, $httpBody,
146146
$headerParams, 'map[string,int]'
147147
);
148+
149+
if (!$response) {
150+
return null;
151+
}
152+
153+
return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader);
154+
148155
} catch (ApiException $e) {
149156
switch ($e->getCode()) {
150157
case 200:
@@ -156,11 +163,7 @@ public function getInventory()
156163
throw $e;
157164
}
158165

159-
if (!$response) {
160-
return null;
161-
}
162-
163-
return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]');
166+
return null;
164167

165168
}
166169

@@ -216,6 +219,13 @@ public function placeOrder($body=null)
216219
$queryParams, $httpBody,
217220
$headerParams, '\Swagger\Client\Model\Order'
218221
);
222+
223+
if (!$response) {
224+
return null;
225+
}
226+
227+
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader);
228+
219229
} catch (ApiException $e) {
220230
switch ($e->getCode()) {
221231
case 200:
@@ -227,11 +237,7 @@ public function placeOrder($body=null)
227237
throw $e;
228238
}
229239

230-
if (!$response) {
231-
return null;
232-
}
233-
234-
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order');
240+
return null;
235241

236242
}
237243

@@ -294,6 +300,13 @@ public function getOrderById($order_id)
294300
$queryParams, $httpBody,
295301
$headerParams, '\Swagger\Client\Model\Order'
296302
);
303+
304+
if (!$response) {
305+
return null;
306+
}
307+
308+
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader);
309+
297310
} catch (ApiException $e) {
298311
switch ($e->getCode()) {
299312
case 200:
@@ -305,11 +318,7 @@ public function getOrderById($order_id)
305318
throw $e;
306319
}
307320

308-
if (!$response) {
309-
return null;
310-
}
311-
312-
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order');
321+
return null;
313322

314323
}
315324

@@ -372,6 +381,7 @@ public function deleteOrder($order_id)
372381
$queryParams, $httpBody,
373382
$headerParams
374383
);
384+
375385
} catch (ApiException $e) {
376386
switch ($e->getCode()) {
377387
}

samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public function createUser($body=null)
143143
$queryParams, $httpBody,
144144
$headerParams
145145
);
146+
146147
} catch (ApiException $e) {
147148
switch ($e->getCode()) {
148149
}
@@ -204,6 +205,7 @@ public function createUsersWithArrayInput($body=null)
204205
$queryParams, $httpBody,
205206
$headerParams
206207
);
208+
207209
} catch (ApiException $e) {
208210
switch ($e->getCode()) {
209211
}
@@ -265,6 +267,7 @@ public function createUsersWithListInput($body=null)
265267
$queryParams, $httpBody,
266268
$headerParams
267269
);
270+
268271
} catch (ApiException $e) {
269272
switch ($e->getCode()) {
270273
}
@@ -329,6 +332,13 @@ public function loginUser($username=null, $password=null)
329332
$queryParams, $httpBody,
330333
$headerParams, 'string'
331334
);
335+
336+
if (!$response) {
337+
return null;
338+
}
339+
340+
return $this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader);
341+
332342
} catch (ApiException $e) {
333343
switch ($e->getCode()) {
334344
case 200:
@@ -340,11 +350,7 @@ public function loginUser($username=null, $password=null)
340350
throw $e;
341351
}
342352

343-
if (!$response) {
344-
return null;
345-
}
346-
347-
return $this->apiClient->getSerializer()->deserialize($response, 'string');
353+
return null;
348354

349355
}
350356

@@ -395,6 +401,7 @@ public function logoutUser()
395401
$queryParams, $httpBody,
396402
$headerParams
397403
);
404+
398405
} catch (ApiException $e) {
399406
switch ($e->getCode()) {
400407
}
@@ -463,6 +470,13 @@ public function getUserByName($username)
463470
$queryParams, $httpBody,
464471
$headerParams, '\Swagger\Client\Model\User'
465472
);
473+
474+
if (!$response) {
475+
return null;
476+
}
477+
478+
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader);
479+
466480
} catch (ApiException $e) {
467481
switch ($e->getCode()) {
468482
case 200:
@@ -474,11 +488,7 @@ public function getUserByName($username)
474488
throw $e;
475489
}
476490

477-
if (!$response) {
478-
return null;
479-
}
480-
481-
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User');
491+
return null;
482492

483493
}
484494

@@ -546,6 +556,7 @@ public function updateUser($username, $body=null)
546556
$queryParams, $httpBody,
547557
$headerParams
548558
);
559+
549560
} catch (ApiException $e) {
550561
switch ($e->getCode()) {
551562
}
@@ -614,6 +625,7 @@ public function deleteUser($username)
614625
$queryParams, $httpBody,
615626
$headerParams
616627
);
628+
617629
} catch (ApiException $e) {
618630
switch ($e->getCode()) {
619631
}

0 commit comments

Comments
 (0)