From d135a72f5c87fa549470249f699dd59da1a8a21e Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 17 Apr 2025 11:28:31 +0300 Subject: [PATCH 1/2] Codegen: OAuth --- codegen/Oauth/Api/AccessTokensApi.php | 18 +++++++++---- codegen/Oauth/Api/RefreshTokensApi.php | 36 +++++++++++++++++++------- codegen/Oauth/Api/TokensApi.php | 8 ++++++ 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/codegen/Oauth/Api/AccessTokensApi.php b/codegen/Oauth/Api/AccessTokensApi.php index 04a0e561b..9289628d3 100644 --- a/codegen/Oauth/Api/AccessTokensApi.php +++ b/codegen/Oauth/Api/AccessTokensApi.php @@ -125,7 +125,9 @@ public function getConfig() /** * Operation get * - * @param string $token token (required) + * Retrieve OAuth token metadata + * + * @param string $token The access token that you want to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format @@ -141,7 +143,9 @@ public function get($token, string $contentType = self::contentTypes['get'][0]) /** * Operation getWithHttpInfo * - * @param string $token (required) + * Retrieve OAuth token metadata + * + * @param string $token The access token that you want to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format @@ -298,7 +302,9 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes /** * Operation getAsync * - * @param string $token (required) + * Retrieve OAuth token metadata + * + * @param string $token The access token that you want to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -317,7 +323,9 @@ function ($response) { /** * Operation getAsyncWithHttpInfo * - * @param string $token (required) + * Retrieve OAuth token metadata + * + * @param string $token The access token that you want to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -367,7 +375,7 @@ function ($exception) { /** * Create request for operation 'get' * - * @param string $token (required) + * @param string $token The access token that you want to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/codegen/Oauth/Api/RefreshTokensApi.php b/codegen/Oauth/Api/RefreshTokensApi.php index 83b88008d..3b8ef9400 100644 --- a/codegen/Oauth/Api/RefreshTokensApi.php +++ b/codegen/Oauth/Api/RefreshTokensApi.php @@ -128,7 +128,9 @@ public function getConfig() /** * Operation archive * - * @param string $token token (required) + * Delete a refresh token + * + * @param string $token The refresh token to delete. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format @@ -143,7 +145,9 @@ public function archive($token, string $contentType = self::contentTypes['archiv /** * Operation archiveWithHttpInfo * - * @param string $token (required) + * Delete a refresh token + * + * @param string $token The refresh token to delete. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format @@ -209,7 +213,9 @@ public function archiveWithHttpInfo($token, string $contentType = self::contentT /** * Operation archiveAsync * - * @param string $token (required) + * Delete a refresh token + * + * @param string $token The refresh token to delete. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -228,7 +234,9 @@ function ($response) { /** * Operation archiveAsyncWithHttpInfo * - * @param string $token (required) + * Delete a refresh token + * + * @param string $token The refresh token to delete. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -265,7 +273,7 @@ function ($exception) { /** * Create request for operation 'archive' * - * @param string $token (required) + * @param string $token The refresh token to delete. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['archive'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -357,7 +365,9 @@ public function archiveRequest($token, string $contentType = self::contentTypes[ /** * Operation get * - * @param string $token token (required) + * Retrieve refresh token metadata + * + * @param string $token The refresh token to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format @@ -373,7 +383,9 @@ public function get($token, string $contentType = self::contentTypes['get'][0]) /** * Operation getWithHttpInfo * - * @param string $token (required) + * Retrieve refresh token metadata + * + * @param string $token The refresh token to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format @@ -530,7 +542,9 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes /** * Operation getAsync * - * @param string $token (required) + * Retrieve refresh token metadata + * + * @param string $token The refresh token to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -549,7 +563,9 @@ function ($response) { /** * Operation getAsyncWithHttpInfo * - * @param string $token (required) + * Retrieve refresh token metadata + * + * @param string $token The refresh token to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -599,7 +615,7 @@ function ($exception) { /** * Create request for operation 'get' * - * @param string $token (required) + * @param string $token The refresh token to retrieve information about. (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['get'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/codegen/Oauth/Api/TokensApi.php b/codegen/Oauth/Api/TokensApi.php index a05c7b2f9..26a1527df 100644 --- a/codegen/Oauth/Api/TokensApi.php +++ b/codegen/Oauth/Api/TokensApi.php @@ -125,6 +125,8 @@ public function getConfig() /** * Operation create * + * Refresh an access token + * * @param string $grant_type grant_type (optional) * @param string $code code (optional) * @param string $redirect_uri redirect_uri (optional) @@ -146,6 +148,8 @@ public function create($grant_type = null, $code = null, $redirect_uri = null, $ /** * Operation createWithHttpInfo * + * Refresh an access token + * * @param string $grant_type (optional) * @param string $code (optional) * @param string $redirect_uri (optional) @@ -308,6 +312,8 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u /** * Operation createAsync * + * Refresh an access token + * * @param string $grant_type (optional) * @param string $code (optional) * @param string $redirect_uri (optional) @@ -332,6 +338,8 @@ function ($response) { /** * Operation createAsyncWithHttpInfo * + * Refresh an access token + * * @param string $grant_type (optional) * @param string $code (optional) * @param string $redirect_uri (optional) From 3601afa9156292a034ee9c5ec7f8cbfbe219c333 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 17 Apr 2025 11:48:05 +0300 Subject: [PATCH 2/2] Codegen: Oauth --- codegen/Oauth/Api/AccessTokensApi.php | 37 +++---- codegen/Oauth/Api/RefreshTokensApi.php | 49 ++++------ codegen/Oauth/Api/TokensApi.php | 97 +++++++++--------- codegen/Oauth/ApiException.php | 8 +- codegen/Oauth/Configuration.php | 4 +- codegen/Oauth/HeaderSelector.php | 32 +++++- .../Oauth/Model/AccessTokenInfoResponse.php | 6 +- codegen/Oauth/Model/Error.php | 6 +- codegen/Oauth/Model/ErrorDetail.php | 6 +- codegen/Oauth/Model/ModelInterface.php | 2 +- .../Oauth/Model/RefreshTokenInfoResponse.php | 6 +- codegen/Oauth/Model/TokenResponseIF.php | 6 +- codegen/Oauth/ObjectSerializer.php | 98 ++++++++++++++----- 13 files changed, 213 insertions(+), 144 deletions(-) diff --git a/codegen/Oauth/Api/AccessTokensApi.php b/codegen/Oauth/Api/AccessTokensApi.php index 9289628d3..ba9c0e4ef 100644 --- a/codegen/Oauth/Api/AccessTokensApi.php +++ b/codegen/Oauth/Api/AccessTokensApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -83,13 +83,13 @@ class AccessTokensApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } @@ -178,18 +178,6 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes $statusCode = $response->getStatusCode(); - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } switch($statusCode) { case 200: @@ -248,6 +236,19 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes ]; } + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + $returnType = '\HubSpot\Client\Oauth\Model\AccessTokenInfoResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Oauth/Api/RefreshTokensApi.php b/codegen/Oauth/Api/RefreshTokensApi.php index 3b8ef9400..d1af3d1a9 100644 --- a/codegen/Oauth/Api/RefreshTokensApi.php +++ b/codegen/Oauth/Api/RefreshTokensApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -86,13 +86,13 @@ class RefreshTokensApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } @@ -180,18 +180,6 @@ public function archiveWithHttpInfo($token, string $contentType = self::contentT $statusCode = $response->getStatusCode(); - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } return [null, $statusCode, $response->getHeaders()]; @@ -418,18 +406,6 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes $statusCode = $response->getStatusCode(); - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } switch($statusCode) { case 200: @@ -488,6 +464,19 @@ public function getWithHttpInfo($token, string $contentType = self::contentTypes ]; } + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + $returnType = '\HubSpot\Client\Oauth\Model\RefreshTokenInfoResponse'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer diff --git a/codegen/Oauth/Api/TokensApi.php b/codegen/Oauth/Api/TokensApi.php index 26a1527df..25907b3cd 100644 --- a/codegen/Oauth/Api/TokensApi.php +++ b/codegen/Oauth/Api/TokensApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -83,13 +83,13 @@ class TokensApi * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( - ClientInterface $client = null, - Configuration $config = null, - HeaderSelector $selector = null, - $hostIndex = 0 + ?ClientInterface $client = null, + ?Configuration $config = null, + ?HeaderSelector $selector = null, + int $hostIndex = 0 ) { $this->client = $client ?: new Client(); - $this->config = $config ?: new Configuration(); + $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } @@ -127,12 +127,12 @@ public function getConfig() * * Refresh an access token * - * @param string $grant_type grant_type (optional) - * @param string $code code (optional) - * @param string $redirect_uri redirect_uri (optional) - * @param string $client_id client_id (optional) - * @param string $client_secret client_secret (optional) - * @param string $refresh_token refresh_token (optional) + * @param string|null $grant_type grant_type (optional) + * @param string|null $code code (optional) + * @param string|null $redirect_uri redirect_uri (optional) + * @param string|null $client_id client_id (optional) + * @param string|null $client_secret client_secret (optional) + * @param string|null $refresh_token refresh_token (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format @@ -150,12 +150,12 @@ public function create($grant_type = null, $code = null, $redirect_uri = null, $ * * Refresh an access token * - * @param string $grant_type (optional) - * @param string $code (optional) - * @param string $redirect_uri (optional) - * @param string $client_id (optional) - * @param string $client_secret (optional) - * @param string $refresh_token (optional) + * @param string|null $grant_type (optional) + * @param string|null $code (optional) + * @param string|null $redirect_uri (optional) + * @param string|null $client_id (optional) + * @param string|null $client_secret (optional) + * @param string|null $refresh_token (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format @@ -188,18 +188,6 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u $statusCode = $response->getStatusCode(); - if ($statusCode < 200 || $statusCode > 299) { - throw new ApiException( - sprintf( - '[%d] Error connecting to the API (%s)', - $statusCode, - (string) $request->getUri() - ), - $statusCode, - $response->getHeaders(), - (string) $response->getBody() - ); - } switch($statusCode) { case 200: @@ -258,6 +246,19 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u ]; } + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + $returnType = '\HubSpot\Client\Oauth\Model\TokenResponseIF'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -314,12 +315,12 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u * * Refresh an access token * - * @param string $grant_type (optional) - * @param string $code (optional) - * @param string $redirect_uri (optional) - * @param string $client_id (optional) - * @param string $client_secret (optional) - * @param string $refresh_token (optional) + * @param string|null $grant_type (optional) + * @param string|null $code (optional) + * @param string|null $redirect_uri (optional) + * @param string|null $client_id (optional) + * @param string|null $client_secret (optional) + * @param string|null $refresh_token (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -340,12 +341,12 @@ function ($response) { * * Refresh an access token * - * @param string $grant_type (optional) - * @param string $code (optional) - * @param string $redirect_uri (optional) - * @param string $client_id (optional) - * @param string $client_secret (optional) - * @param string $refresh_token (optional) + * @param string|null $grant_type (optional) + * @param string|null $code (optional) + * @param string|null $redirect_uri (optional) + * @param string|null $client_id (optional) + * @param string|null $client_secret (optional) + * @param string|null $refresh_token (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -395,12 +396,12 @@ function ($exception) { /** * Create request for operation 'create' * - * @param string $grant_type (optional) - * @param string $code (optional) - * @param string $redirect_uri (optional) - * @param string $client_id (optional) - * @param string $client_secret (optional) - * @param string $refresh_token (optional) + * @param string|null $grant_type (optional) + * @param string|null $code (optional) + * @param string|null $redirect_uri (optional) + * @param string|null $client_id (optional) + * @param string|null $client_secret (optional) + * @param string|null $refresh_token (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/codegen/Oauth/ApiException.php b/codegen/Oauth/ApiException.php index 6bf7de3f7..64105239d 100644 --- a/codegen/Oauth/ApiException.php +++ b/codegen/Oauth/ApiException.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -49,7 +49,7 @@ class ApiException extends Exception /** * The HTTP header of the server response. * - * @var string[]|null + * @var string[][]|null */ protected $responseHeaders; @@ -65,7 +65,7 @@ class ApiException extends Exception * * @param string $message Error message * @param int $code HTTP status code - * @param string[]|null $responseHeaders HTTP response header + * @param string[][]|null $responseHeaders HTTP response header * @param \stdClass|string|null $responseBody HTTP decoded body of the server response either as \stdClass or string */ public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) @@ -78,7 +78,7 @@ public function __construct($message = "", $code = 0, $responseHeaders = [], $re /** * Gets the HTTP response header * - * @return string[]|null HTTP response header + * @return string[][]|null HTTP response header */ public function getResponseHeaders() { diff --git a/codegen/Oauth/Configuration.php b/codegen/Oauth/Configuration.php index 4baacf1d0..a998f41a8 100644 --- a/codegen/Oauth/Configuration.php +++ b/codegen/Oauth/Configuration.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -486,7 +486,7 @@ public function getHostSettings() * @param array|null $variables hash of variable and the corresponding value (optional) * @return string URL based on host settings */ - public static function getHostString(array $hostSettings, $hostIndex, array $variables = null) + public static function getHostString(array $hostSettings, $hostIndex, ?array $variables = null) { if (null === $variables) { $variables = []; diff --git a/codegen/Oauth/HeaderSelector.php b/codegen/Oauth/HeaderSelector.php index c7d69015c..0e4258711 100644 --- a/codegen/Oauth/HeaderSelector.php +++ b/codegen/Oauth/HeaderSelector.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -85,7 +85,7 @@ private function selectAcceptHeader(array $accept): ?string } # If none of the available Accept headers is of type "json", then just use all them - $headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept); + $headersWithJson = $this->selectJsonMimeList($accept); if (count($headersWithJson) === 0) { return implode(',', $accept); } @@ -95,6 +95,34 @@ private function selectAcceptHeader(array $accept): ?string return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson); } + /** + * Detects whether a string contains a valid JSON mime type + * + * @param string $searchString + * @return bool + */ + public function isJsonMime(string $searchString): bool + { + return preg_match('~^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)~', $searchString) === 1; + } + + /** + * Select all items from a list containing a JSON mime type + * + * @param array $mimeList + * @return array + */ + private function selectJsonMimeList(array $mimeList): array { + $jsonMimeList = []; + foreach ($mimeList as $mime) { + if($this->isJsonMime($mime)) { + $jsonMimeList[] = $mime; + } + } + return $jsonMimeList; + } + + /** * Create an Accept header string from the given "Accept" headers array, recalculating all weights * diff --git a/codegen/Oauth/Model/AccessTokenInfoResponse.php b/codegen/Oauth/Model/AccessTokenInfoResponse.php index f8ddeb24e..50b422790 100644 --- a/codegen/Oauth/Model/AccessTokenInfoResponse.php +++ b/codegen/Oauth/Model/AccessTokenInfoResponse.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -287,10 +287,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('hub_id', $data ?? [], null); $this->setIfExists('user_id', $data ?? [], null); diff --git a/codegen/Oauth/Model/Error.php b/codegen/Oauth/Model/Error.php index be0669aff..49fa2bab2 100644 --- a/codegen/Oauth/Model/Error.php +++ b/codegen/Oauth/Model/Error.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -275,10 +275,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('context', $data ?? [], null); diff --git a/codegen/Oauth/Model/ErrorDetail.php b/codegen/Oauth/Model/ErrorDetail.php index 379d05012..831caff24 100644 --- a/codegen/Oauth/Model/ErrorDetail.php +++ b/codegen/Oauth/Model/ErrorDetail.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -263,10 +263,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('sub_category', $data ?? [], null); $this->setIfExists('code', $data ?? [], null); diff --git a/codegen/Oauth/Model/ModelInterface.php b/codegen/Oauth/Model/ModelInterface.php index 2a2d53d22..2d082ed48 100644 --- a/codegen/Oauth/Model/ModelInterface.php +++ b/codegen/Oauth/Model/ModelInterface.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** diff --git a/codegen/Oauth/Model/RefreshTokenInfoResponse.php b/codegen/Oauth/Model/RefreshTokenInfoResponse.php index 8b455ac38..3a13f07ff 100644 --- a/codegen/Oauth/Model/RefreshTokenInfoResponse.php +++ b/codegen/Oauth/Model/RefreshTokenInfoResponse.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -281,10 +281,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('hub_id', $data ?? [], null); $this->setIfExists('user_id', $data ?? [], null); diff --git a/codegen/Oauth/Model/TokenResponseIF.php b/codegen/Oauth/Model/TokenResponseIF.php index 9dab01067..9b701f0cd 100644 --- a/codegen/Oauth/Model/TokenResponseIF.php +++ b/codegen/Oauth/Model/TokenResponseIF.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -263,10 +263,10 @@ public function getModelName() /** * Constructor * - * @param mixed[] $data Associated array of property values + * @param mixed[]|null $data Associated array of property values * initializing the model */ - public function __construct(array $data = null) + public function __construct(?array $data = null) { $this->setIfExists('access_token', $data ?? [], null); $this->setIfExists('refresh_token', $data ?? [], null); diff --git a/codegen/Oauth/ObjectSerializer.php b/codegen/Oauth/ObjectSerializer.php index 90ae635dd..76ad33eb3 100644 --- a/codegen/Oauth/ObjectSerializer.php +++ b/codegen/Oauth/ObjectSerializer.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v1 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -58,8 +58,8 @@ public static function setDateTimeFormat($format) * Serialize data * * @param mixed $data the data to serialize - * @param string $type the OpenAPIToolsType of the data - * @param string $format the format of the OpenAPITools type of the data + * @param string|null $type the OpenAPIToolsType of the data + * @param string|null $format the format of the OpenAPITools type of the data * * @return scalar|object|array|null serialized form of $data */ @@ -194,6 +194,10 @@ private static function isEmptyValue($value, string $openApiType): bool case 'boolean': return !in_array($value, [false, 0], true); + # For string values, '' is considered empty. + case 'string': + return $value === ''; + # For all the other types, any value at this point can be considered empty. default: return true; @@ -265,6 +269,11 @@ public static function toQueryValue( $value = $flattenArray($value, $paramName); + // https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values + if ($openApiType === 'array' && $style === 'deepObject' && $explode) { + return $value; + } + if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) { return $value; } @@ -338,7 +347,7 @@ public static function toFormValue($value) * If it's a datetime object, format it in ISO8601 * If it's a boolean, convert it to "true" or "false". * - * @param string|bool|\DateTime $value the value of the parameter + * @param float|int|bool|\DateTime $value the value of the parameter * * @return string the header string */ @@ -395,8 +404,7 @@ public static function serializeCollection(array $collection, $style, $allowColl * * @param mixed $data object or primitive to be deserialized * @param string $class class name is passed as a string - * @param string[] $httpHeaders HTTP headers - * @param string $discriminator discriminator if polymorphism is used + * @param string[]|null $httpHeaders HTTP headers * * @return object|array|null a single or an array of $class instances */ @@ -473,7 +481,7 @@ public static function deserialize($data, $class, $httpHeaders = null) // determine file name if ( is_array($httpHeaders) - && array_key_exists('Content-Disposition', $httpHeaders) + && array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match) ) { $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); @@ -546,22 +554,64 @@ public static function deserialize($data, $class, $httpHeaders = null) } /** - * Native `http_build_query` wrapper. - * @see https://www.php.net/manual/en/function.http-build-query - * - * @param array|object $data May be an array or object containing properties. - * @param string $numeric_prefix If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only. - * @param string|null $arg_separator arg_separator.output is used to separate arguments but may be overridden by specifying this parameter. - * @param int $encoding_type Encoding type. By default, PHP_QUERY_RFC1738. - * - * @return string - */ - public static function buildQuery( - $data, - string $numeric_prefix = '', - ?string $arg_separator = null, - int $encoding_type = \PHP_QUERY_RFC3986 - ): string { - return \GuzzleHttp\Psr7\Query::build($data, $encoding_type); + * Build a query string from an array of key value pairs. + * + * This function can use the return value of `parse()` to build a query + * string. This function does not modify the provided keys when an array is + * encountered (like `http_build_query()` would). + * + * The function is copied from https://github.com/guzzle/psr7/blob/a243f80a1ca7fe8ceed4deee17f12c1930efe662/src/Query.php#L59-L112 + * with a modification which is described in https://github.com/guzzle/psr7/pull/603 + * + * @param array $params Query string parameters. + * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 + * to encode using RFC3986, or PHP_QUERY_RFC1738 + * to encode using RFC1738. + */ + public static function buildQuery(array $params, $encoding = PHP_QUERY_RFC3986): string + { + if (!$params) { + return ''; + } + + if ($encoding === false) { + $encoder = function (string $str): string { + return $str; + }; + } elseif ($encoding === PHP_QUERY_RFC3986) { + $encoder = 'rawurlencode'; + } elseif ($encoding === PHP_QUERY_RFC1738) { + $encoder = 'urlencode'; + } else { + throw new \InvalidArgumentException('Invalid type'); + } + + $castBool = Configuration::BOOLEAN_FORMAT_INT == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString() + ? function ($v) { return (int) $v; } + : function ($v) { return $v ? 'true' : 'false'; }; + + $qs = ''; + foreach ($params as $k => $v) { + $k = $encoder((string) $k); + if (!is_array($v)) { + $qs .= $k; + $v = is_bool($v) ? $castBool($v) : $v; + if ($v !== null) { + $qs .= '='.$encoder((string) $v); + } + $qs .= '&'; + } else { + foreach ($v as $vv) { + $qs .= $k; + $vv = is_bool($vv) ? $castBool($vv) : $vv; + if ($vv !== null) { + $qs .= '='.$encoder((string) $vv); + } + $qs .= '&'; + } + } + } + + return $qs ? (string) substr($qs, 0, -1) : ''; } }