Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
for (CodegenOperation operation : operations.getOperation()) {
Set<String> phpReturnTypeOptions = new LinkedHashSet<>();
Set<String> docReturnTypeOptions = new LinkedHashSet<>();
boolean hasEmptyResponse = false;

for (CodegenResponse response : operation.responses) {
if (response.dataType != null) {
Expand All @@ -200,6 +201,8 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo

phpReturnTypeOptions.add(returnType);
docReturnTypeOptions.add(response.dataType);
} else {
hasEmptyResponse = true;
}
}

Expand All @@ -208,9 +211,16 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
operation.vendorExtensions.putIfAbsent("x-php-return-type", "void");
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", "void");
} else {
String phpReturnType = String.join("|", phpReturnTypeOptions);
String docReturnType = String.join("|", docReturnTypeOptions);
if (hasEmptyResponse) {
phpReturnType = "?" + phpReturnType;
docReturnType = docReturnType + "|null";
}

operation.vendorExtensions.putIfAbsent("x-php-return-type-is-void", false);
operation.vendorExtensions.putIfAbsent("x-php-return-type", String.join("|", phpReturnTypeOptions));
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", String.join("|", docReturnTypeOptions));
operation.vendorExtensions.putIfAbsent("x-php-return-type", phpReturnType);
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", docReturnType);
}

for (CodegenParameter param : operation.allParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,12 @@ public function fakeBigDecimalMapRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\Error
* @return \OpenAPI\Client\Model\Error|null
*/
public function fakeDeletePet(
string $pet_id,
string $contentType = self::contentTypes['fakeDeletePet'][0]
): \OpenAPI\Client\Model\Error
): ?\OpenAPI\Client\Model\Error
{
list($response) = $this->fakeDeletePetWithHttpInfo($pet_id, $contentType);
return $response;
Expand Down Expand Up @@ -3225,12 +3225,12 @@ public function fakeWith400And4xxRangeResponseEndpointRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\Pet
* @return \OpenAPI\Client\Model\Pet|null
*/
public function fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint(
\OpenAPI\Client\Model\Pet $pet,
string $contentType = self::contentTypes['fakeWith400And4xxRangeResponseNo4xxDatatypeEndpoint'][0]
): \OpenAPI\Client\Model\Pet
): ?\OpenAPI\Client\Model\Pet
{
list($response) = $this->fakeWith400And4xxRangeResponseNo4xxDatatypeEndpointWithHttpInfo($pet, $contentType);
return $response;
Expand Down Expand Up @@ -4094,12 +4094,12 @@ public function fakeWith4xxRangeResponseEndpointRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\Pet
* @return \OpenAPI\Client\Model\Pet|null
*/
public function fakeWith4xxRangeResponseNo4xxDatatypeEndpoint(
\OpenAPI\Client\Model\Pet $pet,
string $contentType = self::contentTypes['fakeWith4xxRangeResponseNo4xxDatatypeEndpoint'][0]
): \OpenAPI\Client\Model\Pet
): ?\OpenAPI\Client\Model\Pet
{
list($response) = $this->fakeWith4xxRangeResponseNo4xxDatatypeEndpointWithHttpInfo($pet, $contentType);
return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,12 +808,12 @@ public function deletePetRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\Pet[]
* @return \OpenAPI\Client\Model\Pet[]|null
*/
public function findPetsByStatus(
array $status,
string $contentType = self::contentTypes['findPetsByStatus'][0]
): array
): ?array
{
list($response) = $this->findPetsByStatusWithHttpInfo($status, $contentType);
return $response;
Expand Down Expand Up @@ -1093,13 +1093,13 @@ public function findPetsByStatusRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\Pet[]
* @return \OpenAPI\Client\Model\Pet[]|null
* @deprecated
*/
public function findPetsByTags(
array $tags,
string $contentType = self::contentTypes['findPetsByTags'][0]
): array
): ?array
{
list($response) = $this->findPetsByTagsWithHttpInfo($tags, $contentType);
return $response;
Expand Down Expand Up @@ -1383,12 +1383,12 @@ public function findPetsByTagsRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\Pet
* @return \OpenAPI\Client\Model\Pet|null
*/
public function getPetById(
int $pet_id,
string $contentType = self::contentTypes['getPetById'][0]
): \OpenAPI\Client\Model\Pet
): ?\OpenAPI\Client\Model\Pet
{
list($response) = $this->getPetByIdWithHttpInfo($pet_id, $contentType);
return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,12 +636,12 @@ public function getInventoryRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\Order
* @return \OpenAPI\Client\Model\Order|null
*/
public function getOrderById(
int $order_id,
string $contentType = self::contentTypes['getOrderById'][0]
): \OpenAPI\Client\Model\Order
): ?\OpenAPI\Client\Model\Order
{
list($response) = $this->getOrderByIdWithHttpInfo($order_id, $contentType);
return $response;
Expand Down Expand Up @@ -922,12 +922,12 @@ public function getOrderByIdRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\Order
* @return \OpenAPI\Client\Model\Order|null
*/
public function placeOrder(
\OpenAPI\Client\Model\Order $order,
string $contentType = self::contentTypes['placeOrder'][0]
): \OpenAPI\Client\Model\Order
): ?\OpenAPI\Client\Model\Order
{
list($response) = $this->placeOrderWithHttpInfo($order, $contentType);
return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1081,12 +1081,12 @@ public function deleteUserRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return \OpenAPI\Client\Model\User
* @return \OpenAPI\Client\Model\User|null
*/
public function getUserByName(
string $username,
string $contentType = self::contentTypes['getUserByName'][0]
): \OpenAPI\Client\Model\User
): ?\OpenAPI\Client\Model\User
{
list($response) = $this->getUserByNameWithHttpInfo($username, $contentType);
return $response;
Expand Down Expand Up @@ -1362,13 +1362,13 @@ public function getUserByNameRequest(
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return string
* @return string|null
*/
public function loginUser(
string $username,
string $password,
string $contentType = self::contentTypes['loginUser'][0]
): string
): ?string
{
list($response) = $this->loginUserWithHttpInfo($username, $password, $contentType);
return $response;
Expand Down
Loading