From a5a5897a41291831d863e3a0098616ba277b0f8a Mon Sep 17 00:00:00 2001 From: Chris Tran Date: Mon, 6 Jan 2025 17:10:58 -0600 Subject: [PATCH] build: adds a codemod func to change erroneous generated return values back to void --- generate.sh | 14 +++++++++++++- generated/lib/Api/TokensApi.php | 4 ++-- generated/lib/Api/UserDevicesApi.php | 4 ++-- generated/lib/Api/UsersApi.php | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/generate.sh b/generate.sh index a766f98..9054074 100755 --- a/generate.sh +++ b/generate.sh @@ -1,5 +1,5 @@ # #!/bin/bash -# set -e +set -e if [ -z "$1" ]; then echo "Required generator file is missing." @@ -45,4 +45,16 @@ add_passage_version_header() { generated/lib/HeaderSelector.php } +# php-nextgen is generating error model return values from the API instead of void for some operations +# so this changes the return value back to void +return_void() { + local bad_user_return_type=' \\OpenAPI\\Client\\Model\\Model401Error|\\OpenAPI\\Client\\Model\\Model404Error|\\OpenAPI\\Client\\Model\\Model500Error' + sed -i 's/'"$bad_user_return_type"'/ void/' generated/lib/Api/UsersApi.php + sed -i 's/'"$bad_user_return_type"'/ void/' generated/lib/Api/UserDevicesApi.php + + local bad_token_return_type=' \\OpenAPI\\Client\\Model\\Model401Error|\\OpenAPI\\Client\\Model\\Model403Error|\\OpenAPI\\Client\\Model\\Model404Error|\\OpenAPI\\Client\\Model\\Model500Error' + sed -i 's/'"$bad_token_return_type"'/ void/' generated/lib/Api/TokensApi.php +} + add_passage_version_header +return_void diff --git a/generated/lib/Api/TokensApi.php b/generated/lib/Api/TokensApi.php index 6772472..0392e2c 100644 --- a/generated/lib/Api/TokensApi.php +++ b/generated/lib/Api/TokensApi.php @@ -134,13 +134,13 @@ public function getConfig(): Configuration * * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return \OpenAPI\Client\Model\Model401Error|\OpenAPI\Client\Model\Model403Error|\OpenAPI\Client\Model\Model404Error|\OpenAPI\Client\Model\Model500Error + * @return void */ public function revokeUserRefreshTokens( string $app_id, string $user_id, string $contentType = self::contentTypes['revokeUserRefreshTokens'][0] - ): \OpenAPI\Client\Model\Model401Error|\OpenAPI\Client\Model\Model403Error|\OpenAPI\Client\Model\Model404Error|\OpenAPI\Client\Model\Model500Error + ): void { $this->revokeUserRefreshTokensWithHttpInfo($app_id, $user_id, $contentType); } diff --git a/generated/lib/Api/UserDevicesApi.php b/generated/lib/Api/UserDevicesApi.php index 309d4ae..0c53581 100644 --- a/generated/lib/Api/UserDevicesApi.php +++ b/generated/lib/Api/UserDevicesApi.php @@ -138,14 +138,14 @@ public function getConfig(): Configuration * * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return \OpenAPI\Client\Model\Model401Error|\OpenAPI\Client\Model\Model404Error|\OpenAPI\Client\Model\Model500Error + * @return void */ public function deleteUserDevices( string $app_id, string $user_id, string $device_id, string $contentType = self::contentTypes['deleteUserDevices'][0] - ): \OpenAPI\Client\Model\Model401Error|\OpenAPI\Client\Model\Model404Error|\OpenAPI\Client\Model\Model500Error + ): void { $this->deleteUserDevicesWithHttpInfo($app_id, $user_id, $device_id, $contentType); } diff --git a/generated/lib/Api/UsersApi.php b/generated/lib/Api/UsersApi.php index cfd07c3..b6a8bad 100644 --- a/generated/lib/Api/UsersApi.php +++ b/generated/lib/Api/UsersApi.php @@ -1557,13 +1557,13 @@ public function deactivateUserRequest( * * @throws ApiException on non-2xx response or if the response body is not in the expected format * @throws InvalidArgumentException - * @return \OpenAPI\Client\Model\Model401Error|\OpenAPI\Client\Model\Model404Error|\OpenAPI\Client\Model\Model500Error + * @return void */ public function deleteUser( string $app_id, string $user_id, string $contentType = self::contentTypes['deleteUser'][0] - ): \OpenAPI\Client\Model\Model401Error|\OpenAPI\Client\Model\Model404Error|\OpenAPI\Client\Model\Model500Error + ): void { $this->deleteUserWithHttpInfo($app_id, $user_id, $contentType); }