Skip to content

Commit 04810a8

Browse files
committed
Map binary to string in PHP since ByteArray is no longer in use.
1 parent 193b317 commit 04810a8

File tree

6 files changed

+10
-14
lines changed

6 files changed

+10
-14
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public PhpClientCodegen() {
101101
typeMapping.put("array", "array");
102102
typeMapping.put("list", "array");
103103
typeMapping.put("object", "object");
104-
typeMapping.put("binary", "ByteArray");
104+
typeMapping.put("binary", "string");
105105

106106
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
107107
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class ApiClient
230230
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
231231
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
232232
// return raw body if response is a file
233-
if ($responseType == '\SplFileObject' || $responseType == 'ByteArray') {
233+
if ($responseType == '\SplFileObject' || $responseType == 'string') {
234234
return array($http_body, $response_info['http_code'], $http_header);
235235
}
236236

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ class ObjectSerializer
241241
$values[] = self::deserialize($value, $subClass);
242242
}
243243
$deserialized = $values;
244-
} elseif ($class === 'ByteArray') { // byte array
245-
$deserialized = (string)$data;
246244
} elseif ($class === '\DateTime') {
247245
$deserialized = new \DateTime($data);
248246
} elseif (in_array($class, array({{&primitives}}))) {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi
879879
* Fake endpoint to test byte array return by 'Find pet by ID'
880880
*
881881
* @param int $pet_id ID of pet that needs to be fetched (required)
882-
* @return ByteArray
882+
* @return string
883883
* @throws \Swagger\Client\ApiException on non-2xx response
884884
*/
885885
public function getPetByIdWithByteArray($pet_id)
@@ -895,7 +895,7 @@ public function getPetByIdWithByteArray($pet_id)
895895
* Fake endpoint to test byte array return by 'Find pet by ID'
896896
*
897897
* @param int $pet_id ID of pet that needs to be fetched (required)
898-
* @return Array of ByteArray, HTTP status code, HTTP response headers (array of strings)
898+
* @return Array of string, HTTP status code, HTTP response headers (array of strings)
899899
* @throws \Swagger\Client\ApiException on non-2xx response
900900
*/
901901
public function getPetByIdWithByteArrayWithHttpInfo($pet_id)
@@ -954,19 +954,19 @@ public function getPetByIdWithByteArrayWithHttpInfo($pet_id)
954954
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
955955
$resourcePath, 'GET',
956956
$queryParams, $httpBody,
957-
$headerParams, 'ByteArray'
957+
$headerParams, 'string'
958958
);
959959

960960
if (!$response) {
961961
return array(null, $statusCode, $httpHeader);
962962
}
963963

964-
return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'ByteArray', $httpHeader), $statusCode, $httpHeader);
964+
return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader);
965965

966966
} catch (ApiException $e) {
967967
switch ($e->getCode()) {
968968
case 200:
969-
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'ByteArray', $e->getResponseHeaders());
969+
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders());
970970
$e->setResponseObject($data);
971971
break;
972972
}
@@ -980,7 +980,7 @@ public function getPetByIdWithByteArrayWithHttpInfo($pet_id)
980980
*
981981
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
982982
*
983-
* @param ByteArray $body Pet object in the form of byte array (optional)
983+
* @param string $body Pet object in the form of byte array (optional)
984984
* @return void
985985
* @throws \Swagger\Client\ApiException on non-2xx response
986986
*/
@@ -996,7 +996,7 @@ public function addPetUsingByteArray($body = null)
996996
*
997997
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
998998
*
999-
* @param ByteArray $body Pet object in the form of byte array (optional)
999+
* @param string $body Pet object in the form of byte array (optional)
10001000
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
10011001
* @throws \Swagger\Client\ApiException on non-2xx response
10021002
*/

samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
230230
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
231231
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
232232
// return raw body if response is a file
233-
if ($responseType == '\SplFileObject' || $responseType == 'ByteArray') {
233+
if ($responseType == '\SplFileObject' || $responseType == 'string') {
234234
return array($http_body, $response_info['http_code'], $http_header);
235235
}
236236

samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ public static function deserialize($data, $class, $httpHeaders=null)
241241
$values[] = self::deserialize($value, $subClass);
242242
}
243243
$deserialized = $values;
244-
} elseif ($class === 'ByteArray') { // byte array
245-
$deserialized = (string)$data;
246244
} elseif ($class === '\DateTime') {
247245
$deserialized = new \DateTime($data);
248246
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {

0 commit comments

Comments
 (0)