From 04810a81b812e17016f3e69294b4d472241dd4f9 Mon Sep 17 00:00:00 2001 From: Elijah Miller Date: Sat, 30 Jan 2016 10:41:46 -0500 Subject: [PATCH] Map binary to string in PHP since ByteArray is no longer in use. --- .../codegen/languages/PhpClientCodegen.java | 2 +- .../src/main/resources/php/ApiClient.mustache | 2 +- .../main/resources/php/ObjectSerializer.mustache | 2 -- .../php/SwaggerClient-php/lib/Api/PetApi.php | 14 +++++++------- .../php/SwaggerClient-php/lib/ApiClient.php | 2 +- .../php/SwaggerClient-php/lib/ObjectSerializer.php | 2 -- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index 1046add66ec9..92cf1c87f6e2 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -101,7 +101,7 @@ public PhpClientCodegen() { typeMapping.put("array", "array"); typeMapping.put("list", "array"); typeMapping.put("object", "object"); - typeMapping.put("binary", "ByteArray"); + typeMapping.put("binary", "string"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache index a0a0b8fcf594..891149d8f55d 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache @@ -230,7 +230,7 @@ class ApiClient throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { // return raw body if response is a file - if ($responseType == '\SplFileObject' || $responseType == 'ByteArray') { + if ($responseType == '\SplFileObject' || $responseType == 'string') { return array($http_body, $response_info['http_code'], $http_header); } diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index 4fac8248038f..39241038a6a8 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -241,8 +241,6 @@ class ObjectSerializer $values[] = self::deserialize($value, $subClass); } $deserialized = $values; - } elseif ($class === 'ByteArray') { // byte array - $deserialized = (string)$data; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); } elseif (in_array($class, array({{&primitives}}))) { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index 7bbcb6bd8169..78a95d7aff53 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -879,7 +879,7 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi * Fake endpoint to test byte array return by 'Find pet by ID' * * @param int $pet_id ID of pet that needs to be fetched (required) - * @return ByteArray + * @return string * @throws \Swagger\Client\ApiException on non-2xx response */ public function getPetByIdWithByteArray($pet_id) @@ -895,7 +895,7 @@ public function getPetByIdWithByteArray($pet_id) * Fake endpoint to test byte array return by 'Find pet by ID' * * @param int $pet_id ID of pet that needs to be fetched (required) - * @return Array of ByteArray, HTTP status code, HTTP response headers (array of strings) + * @return Array of string, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ public function getPetByIdWithByteArrayWithHttpInfo($pet_id) @@ -954,19 +954,19 @@ public function getPetByIdWithByteArrayWithHttpInfo($pet_id) list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'GET', $queryParams, $httpBody, - $headerParams, 'ByteArray' + $headerParams, 'string' ); if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'ByteArray', $httpHeader), $statusCode, $httpHeader); + return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'ByteArray', $e->getResponseHeaders()); + $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -980,7 +980,7 @@ public function getPetByIdWithByteArrayWithHttpInfo($pet_id) * * Fake endpoint to test byte array in body parameter for adding a new pet to the store * - * @param ByteArray $body Pet object in the form of byte array (optional) + * @param string $body Pet object in the form of byte array (optional) * @return void * @throws \Swagger\Client\ApiException on non-2xx response */ @@ -996,7 +996,7 @@ public function addPetUsingByteArray($body = null) * * Fake endpoint to test byte array in body parameter for adding a new pet to the store * - * @param ByteArray $body Pet object in the form of byte array (optional) + * @param string $body Pet object in the form of byte array (optional) * @return Array of null, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php index 8313dc520043..df38b989f88c 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php @@ -230,7 +230,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null); } elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) { // return raw body if response is a file - if ($responseType == '\SplFileObject' || $responseType == 'ByteArray') { + if ($responseType == '\SplFileObject' || $responseType == 'string') { return array($http_body, $response_info['http_code'], $http_header); } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 753893014aa9..502016eb58f6 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -241,8 +241,6 @@ public static function deserialize($data, $class, $httpHeaders=null) $values[] = self::deserialize($value, $subClass); } $deserialized = $values; - } elseif ($class === 'ByteArray') { // byte array - $deserialized = (string)$data; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {