diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 74c32a891f3..bf059063ffd 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -44,8 +44,12 @@ class {{classname}} { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}'; - $headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}'; + $_header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}}); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; {{#queryParams}}// query params if(${{paramName}} !== null) { diff --git a/samples/client/petstore/php/PetApi.php b/samples/client/petstore/php/PetApi.php index 87850e3128d..a972a5c995b 100644 --- a/samples/client/petstore/php/PetApi.php +++ b/samples/client/petstore/php/PetApi.php @@ -43,8 +43,12 @@ class PetApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = 'application/json,application/xml'; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array('application/json','application/xml'); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -88,8 +92,12 @@ class PetApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = 'application/json,application/xml'; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array('application/json','application/xml'); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -133,8 +141,12 @@ class PetApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; // query params if($status !== null) { @@ -183,8 +195,12 @@ class PetApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; // query params if($tags !== null) { @@ -233,8 +249,12 @@ class PetApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -286,8 +306,12 @@ class PetApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array('application/x-www-form-urlencoded'); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -338,8 +362,12 @@ class PetApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; // header params @@ -388,8 +416,12 @@ class PetApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = 'multipart/form-data'; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array('multipart/form-data'); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; diff --git a/samples/client/petstore/php/StoreApi.php b/samples/client/petstore/php/StoreApi.php index 6ff2f83d1be..169766a8e76 100644 --- a/samples/client/petstore/php/StoreApi.php +++ b/samples/client/petstore/php/StoreApi.php @@ -42,8 +42,12 @@ class StoreApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -89,8 +93,12 @@ class StoreApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -140,8 +148,12 @@ class StoreApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -191,8 +203,12 @@ class StoreApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; diff --git a/samples/client/petstore/php/UserApi.php b/samples/client/petstore/php/UserApi.php index a811d8c9f97..4d5c3de954f 100644 --- a/samples/client/petstore/php/UserApi.php +++ b/samples/client/petstore/php/UserApi.php @@ -43,8 +43,12 @@ class UserApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -88,8 +92,12 @@ class UserApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -133,8 +141,12 @@ class UserApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -179,8 +191,12 @@ class UserApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; // query params if($username !== null) { @@ -231,8 +247,12 @@ class UserApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -272,8 +292,12 @@ class UserApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -324,8 +348,12 @@ class UserApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json'; @@ -373,8 +401,12 @@ class UserApi { $queryParams = array(); $headerParams = array(); $formParams = array(); - $headerParams['Accept'] = 'application/json,application/xml'; - $headerParams['Content-Type'] = ''; + $_header_accept = 'application/json, application/xml'; + if ($_header_accept !== '') { + $headerParams['Accept'] = $_header_accept; + } + $_header_content_type = array(); + $headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';