diff --git a/src/main/resources/php/Swagger.mustache b/src/main/resources/php/Swagger.mustache index 53e45e7dda9..37da9c29f83 100644 --- a/src/main/resources/php/Swagger.mustache +++ b/src/main/resources/php/Swagger.mustache @@ -137,18 +137,39 @@ class APIClient { /** * Take value and turn it into a string suitable for inclusion in - * the path or the header + * the path, by url-encoding. + * @param string $value a string which will be part of the path + * @return string the serialized object + */ + public static function toPathValue($value) { + return rawurlencode($value); + } + + /** + * Take value and turn it into a string suitable for inclusion in + * the query, by imploding comma-separated if it's an object. + * If it's a string, pass through unchanged. It will be url-encoded + * later. * @param object $object an object to be serialized to a string * @return string the serialized object */ - public static function toPathValue($object) { + public static function toQueryValue($object) { if (is_array($object)) { - return rawurlencode(implode(',', $object)); + return implode(',', $object); } else { - return rawurlencode($object); + return $object; } } + /** + * Just pass through the header value for now. Placeholder in case we + * find out we need to do something with header values. + * @param string $value a string which will be part of the header + * @return string the header string + */ + public static function toHeaderValue($value) { + return $value; + } /** * Deserialize a JSON string into an object @@ -218,3 +239,4 @@ class APIClient { ?> + diff --git a/src/main/resources/php/api.mustache b/src/main/resources/php/api.mustache index 796f1bf9fe8..fa081768fa8 100644 --- a/src/main/resources/php/api.mustache +++ b/src/main/resources/php/api.mustache @@ -48,13 +48,13 @@ class {{classname}} { {{#queryParams}} if(${{paramName}} != null) { - $queryParams['{{paramName}}'] = $this->apiClient->toPathValue(${{paramName}}); + $queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}}); } {{/queryParams}} {{#headerParams}} if(${{paramName}} != null) { - $headerParams['{{paramName}}'] = $this->apiClient->toPathValue(${{paramName}}); + $headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}}); } {{/headerParams}}