Skip to content

Commit 74536af

Browse files
committed
Map binary to string in PHP since ByteArray is no longer in use.
1 parent 6698c53 commit 74536af

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
@@ -884,7 +884,7 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi
884884
* Fake endpoint to test byte array return by 'Find pet by ID'
885885
*
886886
* @param int $pet_id ID of pet that needs to be fetched (required)
887-
* @return ByteArray
887+
* @return string
888888
* @throws \Swagger\Client\ApiException on non-2xx response
889889
*/
890890
public function petPetIdtestingByteArraytrueGet($pet_id)
@@ -900,7 +900,7 @@ public function petPetIdtestingByteArraytrueGet($pet_id)
900900
* Fake endpoint to test byte array return by 'Find pet by ID'
901901
*
902902
* @param int $pet_id ID of pet that needs to be fetched (required)
903-
* @return Array of ByteArray, HTTP status code, HTTP response headers (array of strings)
903+
* @return Array of string, HTTP status code, HTTP response headers (array of strings)
904904
* @throws \Swagger\Client\ApiException on non-2xx response
905905
*/
906906
public function petPetIdtestingByteArraytrueGetWithHttpInfo($pet_id)
@@ -964,19 +964,19 @@ public function petPetIdtestingByteArraytrueGetWithHttpInfo($pet_id)
964964
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
965965
$resourcePath, 'GET',
966966
$queryParams, $httpBody,
967-
$headerParams, 'ByteArray'
967+
$headerParams, 'string'
968968
);
969969

970970
if (!$response) {
971971
return array(null, $statusCode, $httpHeader);
972972
}
973973

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

976976
} catch (ApiException $e) {
977977
switch ($e->getCode()) {
978978
case 200:
979-
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'ByteArray', $e->getResponseHeaders());
979+
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders());
980980
$e->setResponseObject($data);
981981
break;
982982
}
@@ -990,7 +990,7 @@ public function petPetIdtestingByteArraytrueGetWithHttpInfo($pet_id)
990990
*
991991
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
992992
*
993-
* @param ByteArray $body Pet object in the form of byte array (optional)
993+
* @param string $body Pet object in the form of byte array (optional)
994994
* @return void
995995
* @throws \Swagger\Client\ApiException on non-2xx response
996996
*/
@@ -1006,7 +1006,7 @@ public function addPetUsingByteArray($body = null)
10061006
*
10071007
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
10081008
*
1009-
* @param ByteArray $body Pet object in the form of byte array (optional)
1009+
* @param string $body Pet object in the form of byte array (optional)
10101010
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
10111011
* @throws \Swagger\Client\ApiException on non-2xx response
10121012
*/

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)