Skip to content

Commit 64292cd

Browse files
committed
Merge branch 'develop_2.0' of github.com:swagger-api/swagger-codegen into develop_2.0
2 parents df771b5 + 8b8e8d7 commit 64292cd

File tree

4 files changed

+126
-42
lines changed

4 files changed

+126
-42
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ class {{classname}} {
4444
$queryParams = array();
4545
$headerParams = array();
4646
$formParams = array();
47-
$headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
48-
$headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
47+
$_header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}';
48+
if ($_header_accept !== '') {
49+
$headerParams['Accept'] = $_header_accept;
50+
}
51+
$_header_content_type = array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}});
52+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
4953

5054
{{#queryParams}}// query params
5155
if(${{paramName}} !== null) {

samples/client/petstore/php/PetApi.php

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ public function updatePet($body) {
4343
$queryParams = array();
4444
$headerParams = array();
4545
$formParams = array();
46-
$headerParams['Accept'] = 'application/json,application/xml';
47-
$headerParams['Content-Type'] = 'application/json,application/xml';
46+
$_header_accept = 'application/json, application/xml';
47+
if ($_header_accept !== '') {
48+
$headerParams['Accept'] = $_header_accept;
49+
}
50+
$_header_content_type = array('application/json','application/xml');
51+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
4852

4953

5054

@@ -88,8 +92,12 @@ public function addPet($body) {
8892
$queryParams = array();
8993
$headerParams = array();
9094
$formParams = array();
91-
$headerParams['Accept'] = 'application/json,application/xml';
92-
$headerParams['Content-Type'] = 'application/json,application/xml';
95+
$_header_accept = 'application/json, application/xml';
96+
if ($_header_accept !== '') {
97+
$headerParams['Accept'] = $_header_accept;
98+
}
99+
$_header_content_type = array('application/json','application/xml');
100+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
93101

94102

95103

@@ -133,8 +141,12 @@ public function findPetsByStatus($status) {
133141
$queryParams = array();
134142
$headerParams = array();
135143
$formParams = array();
136-
$headerParams['Accept'] = 'application/json,application/xml';
137-
$headerParams['Content-Type'] = '';
144+
$_header_accept = 'application/json, application/xml';
145+
if ($_header_accept !== '') {
146+
$headerParams['Accept'] = $_header_accept;
147+
}
148+
$_header_content_type = array();
149+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
138150

139151
// query params
140152
if($status !== null) {
@@ -183,8 +195,12 @@ public function findPetsByTags($tags) {
183195
$queryParams = array();
184196
$headerParams = array();
185197
$formParams = array();
186-
$headerParams['Accept'] = 'application/json,application/xml';
187-
$headerParams['Content-Type'] = '';
198+
$_header_accept = 'application/json, application/xml';
199+
if ($_header_accept !== '') {
200+
$headerParams['Accept'] = $_header_accept;
201+
}
202+
$_header_content_type = array();
203+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
188204

189205
// query params
190206
if($tags !== null) {
@@ -233,8 +249,12 @@ public function getPetById($pet_id) {
233249
$queryParams = array();
234250
$headerParams = array();
235251
$formParams = array();
236-
$headerParams['Accept'] = 'application/json,application/xml';
237-
$headerParams['Content-Type'] = '';
252+
$_header_accept = 'application/json, application/xml';
253+
if ($_header_accept !== '') {
254+
$headerParams['Accept'] = $_header_accept;
255+
}
256+
$_header_content_type = array();
257+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
238258

239259

240260

@@ -286,8 +306,12 @@ public function updatePetWithForm($pet_id, $name, $status) {
286306
$queryParams = array();
287307
$headerParams = array();
288308
$formParams = array();
289-
$headerParams['Accept'] = 'application/json,application/xml';
290-
$headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
309+
$_header_accept = 'application/json, application/xml';
310+
if ($_header_accept !== '') {
311+
$headerParams['Accept'] = $_header_accept;
312+
}
313+
$_header_content_type = array('application/x-www-form-urlencoded');
314+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
291315

292316

293317

@@ -338,8 +362,12 @@ public function deletePet($api_key, $pet_id) {
338362
$queryParams = array();
339363
$headerParams = array();
340364
$formParams = array();
341-
$headerParams['Accept'] = 'application/json,application/xml';
342-
$headerParams['Content-Type'] = '';
365+
$_header_accept = 'application/json, application/xml';
366+
if ($_header_accept !== '') {
367+
$headerParams['Accept'] = $_header_accept;
368+
}
369+
$_header_content_type = array();
370+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
343371

344372

345373
// header params
@@ -388,8 +416,12 @@ public function uploadFile($pet_id, $additional_metadata, $file) {
388416
$queryParams = array();
389417
$headerParams = array();
390418
$formParams = array();
391-
$headerParams['Accept'] = 'application/json,application/xml';
392-
$headerParams['Content-Type'] = 'multipart/form-data';
419+
$_header_accept = 'application/json, application/xml';
420+
if ($_header_accept !== '') {
421+
$headerParams['Accept'] = $_header_accept;
422+
}
423+
$_header_content_type = array('multipart/form-data');
424+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
393425

394426

395427

samples/client/petstore/php/StoreApi.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ public function getInventory() {
4242
$queryParams = array();
4343
$headerParams = array();
4444
$formParams = array();
45-
$headerParams['Accept'] = 'application/json,application/xml';
46-
$headerParams['Content-Type'] = '';
45+
$_header_accept = 'application/json, application/xml';
46+
if ($_header_accept !== '') {
47+
$headerParams['Accept'] = $_header_accept;
48+
}
49+
$_header_content_type = array();
50+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
4751

4852

4953

@@ -89,8 +93,12 @@ public function placeOrder($body) {
8993
$queryParams = array();
9094
$headerParams = array();
9195
$formParams = array();
92-
$headerParams['Accept'] = 'application/json,application/xml';
93-
$headerParams['Content-Type'] = '';
96+
$_header_accept = 'application/json, application/xml';
97+
if ($_header_accept !== '') {
98+
$headerParams['Accept'] = $_header_accept;
99+
}
100+
$_header_content_type = array();
101+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
94102

95103

96104

@@ -140,8 +148,12 @@ public function getOrderById($order_id) {
140148
$queryParams = array();
141149
$headerParams = array();
142150
$formParams = array();
143-
$headerParams['Accept'] = 'application/json,application/xml';
144-
$headerParams['Content-Type'] = '';
151+
$_header_accept = 'application/json, application/xml';
152+
if ($_header_accept !== '') {
153+
$headerParams['Accept'] = $_header_accept;
154+
}
155+
$_header_content_type = array();
156+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
145157

146158

147159

@@ -191,8 +203,12 @@ public function deleteOrder($order_id) {
191203
$queryParams = array();
192204
$headerParams = array();
193205
$formParams = array();
194-
$headerParams['Accept'] = 'application/json,application/xml';
195-
$headerParams['Content-Type'] = '';
206+
$_header_accept = 'application/json, application/xml';
207+
if ($_header_accept !== '') {
208+
$headerParams['Accept'] = $_header_accept;
209+
}
210+
$_header_content_type = array();
211+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
196212

197213

198214

samples/client/petstore/php/UserApi.php

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ public function createUser($body) {
4343
$queryParams = array();
4444
$headerParams = array();
4545
$formParams = array();
46-
$headerParams['Accept'] = 'application/json,application/xml';
47-
$headerParams['Content-Type'] = '';
46+
$_header_accept = 'application/json, application/xml';
47+
if ($_header_accept !== '') {
48+
$headerParams['Accept'] = $_header_accept;
49+
}
50+
$_header_content_type = array();
51+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
4852

4953

5054

@@ -88,8 +92,12 @@ public function createUsersWithArrayInput($body) {
8892
$queryParams = array();
8993
$headerParams = array();
9094
$formParams = array();
91-
$headerParams['Accept'] = 'application/json,application/xml';
92-
$headerParams['Content-Type'] = '';
95+
$_header_accept = 'application/json, application/xml';
96+
if ($_header_accept !== '') {
97+
$headerParams['Accept'] = $_header_accept;
98+
}
99+
$_header_content_type = array();
100+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
93101

94102

95103

@@ -133,8 +141,12 @@ public function createUsersWithListInput($body) {
133141
$queryParams = array();
134142
$headerParams = array();
135143
$formParams = array();
136-
$headerParams['Accept'] = 'application/json,application/xml';
137-
$headerParams['Content-Type'] = '';
144+
$_header_accept = 'application/json, application/xml';
145+
if ($_header_accept !== '') {
146+
$headerParams['Accept'] = $_header_accept;
147+
}
148+
$_header_content_type = array();
149+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
138150

139151

140152

@@ -179,8 +191,12 @@ public function loginUser($username, $password) {
179191
$queryParams = array();
180192
$headerParams = array();
181193
$formParams = array();
182-
$headerParams['Accept'] = 'application/json,application/xml';
183-
$headerParams['Content-Type'] = '';
194+
$_header_accept = 'application/json, application/xml';
195+
if ($_header_accept !== '') {
196+
$headerParams['Accept'] = $_header_accept;
197+
}
198+
$_header_content_type = array();
199+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
184200

185201
// query params
186202
if($username !== null) {
@@ -231,8 +247,12 @@ public function logoutUser() {
231247
$queryParams = array();
232248
$headerParams = array();
233249
$formParams = array();
234-
$headerParams['Accept'] = 'application/json,application/xml';
235-
$headerParams['Content-Type'] = '';
250+
$_header_accept = 'application/json, application/xml';
251+
if ($_header_accept !== '') {
252+
$headerParams['Accept'] = $_header_accept;
253+
}
254+
$_header_content_type = array();
255+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
236256

237257

238258

@@ -272,8 +292,12 @@ public function getUserByName($username) {
272292
$queryParams = array();
273293
$headerParams = array();
274294
$formParams = array();
275-
$headerParams['Accept'] = 'application/json,application/xml';
276-
$headerParams['Content-Type'] = '';
295+
$_header_accept = 'application/json, application/xml';
296+
if ($_header_accept !== '') {
297+
$headerParams['Accept'] = $_header_accept;
298+
}
299+
$_header_content_type = array();
300+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
277301

278302

279303

@@ -324,8 +348,12 @@ public function updateUser($username, $body) {
324348
$queryParams = array();
325349
$headerParams = array();
326350
$formParams = array();
327-
$headerParams['Accept'] = 'application/json,application/xml';
328-
$headerParams['Content-Type'] = '';
351+
$_header_accept = 'application/json, application/xml';
352+
if ($_header_accept !== '') {
353+
$headerParams['Accept'] = $_header_accept;
354+
}
355+
$_header_content_type = array();
356+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
329357

330358

331359

@@ -373,8 +401,12 @@ public function deleteUser($username) {
373401
$queryParams = array();
374402
$headerParams = array();
375403
$formParams = array();
376-
$headerParams['Accept'] = 'application/json,application/xml';
377-
$headerParams['Content-Type'] = '';
404+
$_header_accept = 'application/json, application/xml';
405+
if ($_header_accept !== '') {
406+
$headerParams['Accept'] = $_header_accept;
407+
}
408+
$_header_content_type = array();
409+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
378410

379411

380412

0 commit comments

Comments
 (0)