Skip to content

Commit

Permalink
build: adds a codemod func to change erroneous generated return value…
Browse files Browse the repository at this point in the history
…s back to void
  • Loading branch information
ctran88 committed Jan 7, 2025
1 parent d21f93d commit a5a5897
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
14 changes: 13 additions & 1 deletion generate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# #!/bin/bash
# set -e
set -e

if [ -z "$1" ]; then
echo "Required generator file is missing."
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions generated/lib/Api/TokensApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions generated/lib/Api/UserDevicesApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions generated/lib/Api/UsersApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit a5a5897

Please sign in to comment.