diff --git a/codegen/Cms/AuditLogs/Api/AuditLogsApi.php b/codegen/Cms/AuditLogs/Api/AuditLogsApi.php index 4ed98e543..69f1e7682 100644 --- a/codegen/Cms/AuditLogs/Api/AuditLogsApi.php +++ b/codegen/Cms/AuditLogs/Api/AuditLogsApi.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -83,13 +83,13 @@ class AuditLogsApi * @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,14 +127,14 @@ public function getConfig() * * Query audit logs * - * @param string[] $user_id Comma separated list of user ids to filter by. (optional) - * @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) - * @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) - * @param string[] $object_id Comma separated list of object ids to filter by. (optional) - * @param string $after Timestamp after which audit logs will be returned (optional) - * @param string $before Timestamp before which audit logs will be returned (optional) - * @param int $limit The number of logs to return. (optional) - * @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) + * @param string[]|null $user_id Comma separated list of user ids to filter by. (optional) + * @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) + * @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) + * @param string[]|null $object_id Comma separated list of object ids to filter by. (optional) + * @param string|null $after Timestamp after which audit logs will be returned (optional) + * @param string|null $before Timestamp before which audit logs will be returned (optional) + * @param int|null $limit The number of logs to return. (optional) + * @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\AuditLogs\ApiException on non-2xx response or if the response body is not in the expected format @@ -152,14 +152,14 @@ public function getPage($user_id = null, $event_type = null, $object_type = null * * Query audit logs * - * @param string[] $user_id Comma separated list of user ids to filter by. (optional) - * @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) - * @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) - * @param string[] $object_id Comma separated list of object ids to filter by. (optional) - * @param string $after Timestamp after which audit logs will be returned (optional) - * @param string $before Timestamp before which audit logs will be returned (optional) - * @param int $limit The number of logs to return. (optional) - * @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) + * @param string[]|null $user_id Comma separated list of user ids to filter by. (optional) + * @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) + * @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) + * @param string[]|null $object_id Comma separated list of object ids to filter by. (optional) + * @param string|null $after Timestamp after which audit logs will be returned (optional) + * @param string|null $before Timestamp before which audit logs will be returned (optional) + * @param int|null $limit The number of logs to return. (optional) + * @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\AuditLogs\ApiException on non-2xx response or if the response body is not in the expected format @@ -192,18 +192,6 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object $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: @@ -262,6 +250,19 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object ]; } + 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\Cms\AuditLogs\Model\CollectionResponsePublicAuditLog'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -318,14 +319,14 @@ public function getPageWithHttpInfo($user_id = null, $event_type = null, $object * * Query audit logs * - * @param string[] $user_id Comma separated list of user ids to filter by. (optional) - * @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) - * @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) - * @param string[] $object_id Comma separated list of object ids to filter by. (optional) - * @param string $after Timestamp after which audit logs will be returned (optional) - * @param string $before Timestamp before which audit logs will be returned (optional) - * @param int $limit The number of logs to return. (optional) - * @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) + * @param string[]|null $user_id Comma separated list of user ids to filter by. (optional) + * @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) + * @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) + * @param string[]|null $object_id Comma separated list of object ids to filter by. (optional) + * @param string|null $after Timestamp after which audit logs will be returned (optional) + * @param string|null $before Timestamp before which audit logs will be returned (optional) + * @param int|null $limit The number of logs to return. (optional) + * @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -346,14 +347,14 @@ function ($response) { * * Query audit logs * - * @param string[] $user_id Comma separated list of user ids to filter by. (optional) - * @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) - * @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) - * @param string[] $object_id Comma separated list of object ids to filter by. (optional) - * @param string $after Timestamp after which audit logs will be returned (optional) - * @param string $before Timestamp before which audit logs will be returned (optional) - * @param int $limit The number of logs to return. (optional) - * @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) + * @param string[]|null $user_id Comma separated list of user ids to filter by. (optional) + * @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) + * @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) + * @param string[]|null $object_id Comma separated list of object ids to filter by. (optional) + * @param string|null $after Timestamp after which audit logs will be returned (optional) + * @param string|null $before Timestamp before which audit logs will be returned (optional) + * @param int|null $limit The number of logs to return. (optional) + * @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -403,14 +404,14 @@ function ($exception) { /** * Create request for operation 'getPage' * - * @param string[] $user_id Comma separated list of user ids to filter by. (optional) - * @param string[] $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) - * @param string[] $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) - * @param string[] $object_id Comma separated list of object ids to filter by. (optional) - * @param string $after Timestamp after which audit logs will be returned (optional) - * @param string $before Timestamp before which audit logs will be returned (optional) - * @param int $limit The number of logs to return. (optional) - * @param string[] $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) + * @param string[]|null $user_id Comma separated list of user ids to filter by. (optional) + * @param string[]|null $event_type Comma separated list of event types to filter by (CREATED, UPDATED, PUBLISHED, DELETED, UNPUBLISHED). (optional) + * @param string[]|null $object_type Comma separated list of object types to filter by (BLOG, LANDING_PAGE, DOMAIN, HUBDB_TABLE etc.) (optional) + * @param string[]|null $object_id Comma separated list of object ids to filter by. (optional) + * @param string|null $after Timestamp after which audit logs will be returned (optional) + * @param string|null $before Timestamp before which audit logs will be returned (optional) + * @param int|null $limit The number of logs to return. (optional) + * @param string[]|null $sort The sort direction for the audit logs. (Can only sort by timestamp). (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/codegen/Cms/AuditLogs/ApiException.php b/codegen/Cms/AuditLogs/ApiException.php index 0a167a692..771d4638e 100644 --- a/codegen/Cms/AuditLogs/ApiException.php +++ b/codegen/Cms/AuditLogs/ApiException.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * 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/Cms/AuditLogs/Configuration.php b/codegen/Cms/AuditLogs/Configuration.php index a7b86fbf0..7d0293e68 100644 --- a/codegen/Cms/AuditLogs/Configuration.php +++ b/codegen/Cms/AuditLogs/Configuration.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * 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/Cms/AuditLogs/HeaderSelector.php b/codegen/Cms/AuditLogs/HeaderSelector.php index a4dacb4eb..9ca182727 100644 --- a/codegen/Cms/AuditLogs/HeaderSelector.php +++ b/codegen/Cms/AuditLogs/HeaderSelector.php @@ -16,7 +16,7 @@ * * The version of the OpenAPI document: v3 * 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/Cms/AuditLogs/Model/CollectionResponsePublicAuditLog.php b/codegen/Cms/AuditLogs/Model/CollectionResponsePublicAuditLog.php index 26394c14d..af39e09f7 100644 --- a/codegen/Cms/AuditLogs/Model/CollectionResponsePublicAuditLog.php +++ b/codegen/Cms/AuditLogs/Model/CollectionResponsePublicAuditLog.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -246,10 +246,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('paging', $data ?? [], null); $this->setIfExists('results', $data ?? [], null); diff --git a/codegen/Cms/AuditLogs/Model/Error.php b/codegen/Cms/AuditLogs/Model/Error.php index b2a6eab26..692d525f3 100644 --- a/codegen/Cms/AuditLogs/Model/Error.php +++ b/codegen/Cms/AuditLogs/Model/Error.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * 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/Cms/AuditLogs/Model/ErrorDetail.php b/codegen/Cms/AuditLogs/Model/ErrorDetail.php index 3279d5276..bf29abe92 100644 --- a/codegen/Cms/AuditLogs/Model/ErrorDetail.php +++ b/codegen/Cms/AuditLogs/Model/ErrorDetail.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * 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/Cms/AuditLogs/Model/ModelInterface.php b/codegen/Cms/AuditLogs/Model/ModelInterface.php index 6dd972f76..b8763cda4 100644 --- a/codegen/Cms/AuditLogs/Model/ModelInterface.php +++ b/codegen/Cms/AuditLogs/Model/ModelInterface.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** diff --git a/codegen/Cms/AuditLogs/Model/NextPage.php b/codegen/Cms/AuditLogs/Model/NextPage.php index 57acee4ea..a3cd3d2b8 100644 --- a/codegen/Cms/AuditLogs/Model/NextPage.php +++ b/codegen/Cms/AuditLogs/Model/NextPage.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -245,10 +245,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('link', $data ?? [], null); $this->setIfExists('after', $data ?? [], null); diff --git a/codegen/Cms/AuditLogs/Model/Paging.php b/codegen/Cms/AuditLogs/Model/Paging.php index d39b36c99..94d80d88f 100644 --- a/codegen/Cms/AuditLogs/Model/Paging.php +++ b/codegen/Cms/AuditLogs/Model/Paging.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -245,10 +245,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('next', $data ?? [], null); $this->setIfExists('prev', $data ?? [], null); diff --git a/codegen/Cms/AuditLogs/Model/PreviousPage.php b/codegen/Cms/AuditLogs/Model/PreviousPage.php index 5929e5958..b48b021db 100644 --- a/codegen/Cms/AuditLogs/Model/PreviousPage.php +++ b/codegen/Cms/AuditLogs/Model/PreviousPage.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -245,10 +245,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('before', $data ?? [], null); $this->setIfExists('link', $data ?? [], null); diff --git a/codegen/Cms/AuditLogs/Model/PublicAuditLog.php b/codegen/Cms/AuditLogs/Model/PublicAuditLog.php index 1eb62a3c8..168b0450a 100644 --- a/codegen/Cms/AuditLogs/Model/PublicAuditLog.php +++ b/codegen/Cms/AuditLogs/Model/PublicAuditLog.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -355,10 +355,10 @@ public function getObjectTypeAllowableValues() /** * 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('meta', $data ?? [], null); $this->setIfExists('object_name', $data ?? [], null); diff --git a/codegen/Cms/AuditLogs/ObjectSerializer.php b/codegen/Cms/AuditLogs/ObjectSerializer.php index b7987d3df..ee4e0bbd3 100644 --- a/codegen/Cms/AuditLogs/ObjectSerializer.php +++ b/codegen/Cms/AuditLogs/ObjectSerializer.php @@ -17,7 +17,7 @@ * * The version of the OpenAPI document: v3 * 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) : ''; } } diff --git a/codegen/Cms/Domains/Api/DomainsApi.php b/codegen/Cms/Domains/Api/DomainsApi.php index 108a66bd5..bd69e1e1d 100644 --- a/codegen/Cms/Domains/Api/DomainsApi.php +++ b/codegen/Cms/Domains/Api/DomainsApi.php @@ -10,13 +10,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -86,13 +86,13 @@ class DomainsApi * @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; } @@ -181,18 +181,6 @@ public function getByIdWithHttpInfo($domain_id, string $contentType = self::cont $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: @@ -251,6 +239,19 @@ public function getByIdWithHttpInfo($domain_id, string $contentType = self::cont ]; } + 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\Cms\Domains\Model\Domain'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -476,16 +477,16 @@ public function getByIdRequest($domain_id, string $contentType = self::contentTy * * Get current domains * - * @param \DateTime $created_at Only return domains created at this date. (optional) - * @param \DateTime $created_after Only return domains created after this date. (optional) - * @param \DateTime $created_before Only return domains created before this date. (optional) - * @param \DateTime $updated_at Only return domains updated at this date. (optional) - * @param \DateTime $updated_after Only return domains updated after this date. (optional) - * @param \DateTime $updated_before Only return domains updated before this date. (optional) - * @param string[] $sort sort (optional) - * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit Maximum number of results per page. (optional) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param \DateTime|null $created_at Only return domains created at this date. (optional) + * @param \DateTime|null $created_after Only return domains created after this date. (optional) + * @param \DateTime|null $created_before Only return domains created before this date. (optional) + * @param \DateTime|null $updated_at Only return domains updated at this date. (optional) + * @param \DateTime|null $updated_after Only return domains updated after this date. (optional) + * @param \DateTime|null $updated_before Only return domains updated before this date. (optional) + * @param string[]|null $sort sort (optional) + * @param string|null $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int|null $limit Maximum number of results per page. (optional) + * @param bool|null $archived Whether to return only results that have been archived. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Domains\ApiException on non-2xx response or if the response body is not in the expected format @@ -503,16 +504,16 @@ public function getPage($created_at = null, $created_after = null, $created_befo * * Get current domains * - * @param \DateTime $created_at Only return domains created at this date. (optional) - * @param \DateTime $created_after Only return domains created after this date. (optional) - * @param \DateTime $created_before Only return domains created before this date. (optional) - * @param \DateTime $updated_at Only return domains updated at this date. (optional) - * @param \DateTime $updated_after Only return domains updated after this date. (optional) - * @param \DateTime $updated_before Only return domains updated before this date. (optional) - * @param string[] $sort (optional) - * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit Maximum number of results per page. (optional) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param \DateTime|null $created_at Only return domains created at this date. (optional) + * @param \DateTime|null $created_after Only return domains created after this date. (optional) + * @param \DateTime|null $created_before Only return domains created before this date. (optional) + * @param \DateTime|null $updated_at Only return domains updated at this date. (optional) + * @param \DateTime|null $updated_after Only return domains updated after this date. (optional) + * @param \DateTime|null $updated_before Only return domains updated before this date. (optional) + * @param string[]|null $sort (optional) + * @param string|null $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int|null $limit Maximum number of results per page. (optional) + * @param bool|null $archived Whether to return only results that have been archived. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \HubSpot\Client\Cms\Domains\ApiException on non-2xx response or if the response body is not in the expected format @@ -545,18 +546,6 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ $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: @@ -615,6 +604,19 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ ]; } + 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\Cms\Domains\Model\CollectionResponseWithTotalDomainForwardPaging'; if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer @@ -671,16 +673,16 @@ public function getPageWithHttpInfo($created_at = null, $created_after = null, $ * * Get current domains * - * @param \DateTime $created_at Only return domains created at this date. (optional) - * @param \DateTime $created_after Only return domains created after this date. (optional) - * @param \DateTime $created_before Only return domains created before this date. (optional) - * @param \DateTime $updated_at Only return domains updated at this date. (optional) - * @param \DateTime $updated_after Only return domains updated after this date. (optional) - * @param \DateTime $updated_before Only return domains updated before this date. (optional) - * @param string[] $sort (optional) - * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit Maximum number of results per page. (optional) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param \DateTime|null $created_at Only return domains created at this date. (optional) + * @param \DateTime|null $created_after Only return domains created after this date. (optional) + * @param \DateTime|null $created_before Only return domains created before this date. (optional) + * @param \DateTime|null $updated_at Only return domains updated at this date. (optional) + * @param \DateTime|null $updated_after Only return domains updated after this date. (optional) + * @param \DateTime|null $updated_before Only return domains updated before this date. (optional) + * @param string[]|null $sort (optional) + * @param string|null $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int|null $limit Maximum number of results per page. (optional) + * @param bool|null $archived Whether to return only results that have been archived. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -701,16 +703,16 @@ function ($response) { * * Get current domains * - * @param \DateTime $created_at Only return domains created at this date. (optional) - * @param \DateTime $created_after Only return domains created after this date. (optional) - * @param \DateTime $created_before Only return domains created before this date. (optional) - * @param \DateTime $updated_at Only return domains updated at this date. (optional) - * @param \DateTime $updated_after Only return domains updated after this date. (optional) - * @param \DateTime $updated_before Only return domains updated before this date. (optional) - * @param string[] $sort (optional) - * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit Maximum number of results per page. (optional) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param \DateTime|null $created_at Only return domains created at this date. (optional) + * @param \DateTime|null $created_after Only return domains created after this date. (optional) + * @param \DateTime|null $created_before Only return domains created before this date. (optional) + * @param \DateTime|null $updated_at Only return domains updated at this date. (optional) + * @param \DateTime|null $updated_after Only return domains updated after this date. (optional) + * @param \DateTime|null $updated_before Only return domains updated before this date. (optional) + * @param string[]|null $sort (optional) + * @param string|null $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int|null $limit Maximum number of results per page. (optional) + * @param bool|null $archived Whether to return only results that have been archived. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException @@ -760,16 +762,16 @@ function ($exception) { /** * Create request for operation 'getPage' * - * @param \DateTime $created_at Only return domains created at this date. (optional) - * @param \DateTime $created_after Only return domains created after this date. (optional) - * @param \DateTime $created_before Only return domains created before this date. (optional) - * @param \DateTime $updated_at Only return domains updated at this date. (optional) - * @param \DateTime $updated_after Only return domains updated after this date. (optional) - * @param \DateTime $updated_before Only return domains updated before this date. (optional) - * @param string[] $sort (optional) - * @param string $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) - * @param int $limit Maximum number of results per page. (optional) - * @param bool $archived Whether to return only results that have been archived. (optional) + * @param \DateTime|null $created_at Only return domains created at this date. (optional) + * @param \DateTime|null $created_after Only return domains created after this date. (optional) + * @param \DateTime|null $created_before Only return domains created before this date. (optional) + * @param \DateTime|null $updated_at Only return domains updated at this date. (optional) + * @param \DateTime|null $updated_after Only return domains updated after this date. (optional) + * @param \DateTime|null $updated_before Only return domains updated before this date. (optional) + * @param string[]|null $sort (optional) + * @param string|null $after The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. (optional) + * @param int|null $limit Maximum number of results per page. (optional) + * @param bool|null $archived Whether to return only results that have been archived. (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getPage'] to see the possible values for this operation * * @throws \InvalidArgumentException diff --git a/codegen/Cms/Domains/ApiException.php b/codegen/Cms/Domains/ApiException.php index 0bbe3acb5..904608952 100644 --- a/codegen/Cms/Domains/ApiException.php +++ b/codegen/Cms/Domains/ApiException.php @@ -10,13 +10,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * 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/Cms/Domains/Configuration.php b/codegen/Cms/Domains/Configuration.php index 226db12aa..0cddd48ad 100644 --- a/codegen/Cms/Domains/Configuration.php +++ b/codegen/Cms/Domains/Configuration.php @@ -10,13 +10,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * 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/Cms/Domains/HeaderSelector.php b/codegen/Cms/Domains/HeaderSelector.php index 017d84e87..e97e12cc9 100644 --- a/codegen/Cms/Domains/HeaderSelector.php +++ b/codegen/Cms/Domains/HeaderSelector.php @@ -10,13 +10,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * 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/Cms/Domains/Model/CollectionResponseWithTotalDomainForwardPaging.php b/codegen/Cms/Domains/Model/CollectionResponseWithTotalDomainForwardPaging.php index 1344a9a56..116b2f0fb 100644 --- a/codegen/Cms/Domains/Model/CollectionResponseWithTotalDomainForwardPaging.php +++ b/codegen/Cms/Domains/Model/CollectionResponseWithTotalDomainForwardPaging.php @@ -11,13 +11,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -251,10 +251,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('total', $data ?? [], null); $this->setIfExists('paging', $data ?? [], null); diff --git a/codegen/Cms/Domains/Model/Domain.php b/codegen/Cms/Domains/Model/Domain.php index 10d180408..186ca361f 100644 --- a/codegen/Cms/Domains/Model/Domain.php +++ b/codegen/Cms/Domains/Model/Domain.php @@ -11,13 +11,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -353,10 +353,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('is_used_for_landing_page', $data ?? [], null); $this->setIfExists('primary_blog_post', $data ?? [], null); diff --git a/codegen/Cms/Domains/Model/Error.php b/codegen/Cms/Domains/Model/Error.php index ce5e3126c..ed0221442 100644 --- a/codegen/Cms/Domains/Model/Error.php +++ b/codegen/Cms/Domains/Model/Error.php @@ -11,13 +11,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * 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/Cms/Domains/Model/ErrorDetail.php b/codegen/Cms/Domains/Model/ErrorDetail.php index 7da1ede8e..8d8fd85e6 100644 --- a/codegen/Cms/Domains/Model/ErrorDetail.php +++ b/codegen/Cms/Domains/Model/ErrorDetail.php @@ -11,13 +11,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * 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/Cms/Domains/Model/ForwardPaging.php b/codegen/Cms/Domains/Model/ForwardPaging.php index deb0a23e8..28ff6cd4d 100644 --- a/codegen/Cms/Domains/Model/ForwardPaging.php +++ b/codegen/Cms/Domains/Model/ForwardPaging.php @@ -11,13 +11,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -239,10 +239,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('next', $data ?? [], null); } diff --git a/codegen/Cms/Domains/Model/ModelInterface.php b/codegen/Cms/Domains/Model/ModelInterface.php index 64a817e8a..5401d7f33 100644 --- a/codegen/Cms/Domains/Model/ModelInterface.php +++ b/codegen/Cms/Domains/Model/ModelInterface.php @@ -11,13 +11,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** diff --git a/codegen/Cms/Domains/Model/NextPage.php b/codegen/Cms/Domains/Model/NextPage.php index cc1871a6c..dfd9bd60c 100644 --- a/codegen/Cms/Domains/Model/NextPage.php +++ b/codegen/Cms/Domains/Model/NextPage.php @@ -11,13 +11,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * Generated by: https://openapi-generator.tech - * OpenAPI Generator version: 7.3.0 + * Generator version: 7.12.0 */ /** @@ -245,10 +245,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('link', $data ?? [], null); $this->setIfExists('after', $data ?? [], null); diff --git a/codegen/Cms/Domains/ObjectSerializer.php b/codegen/Cms/Domains/ObjectSerializer.php index 9faff293d..e7b05dfe6 100644 --- a/codegen/Cms/Domains/ObjectSerializer.php +++ b/codegen/Cms/Domains/ObjectSerializer.php @@ -11,13 +11,13 @@ */ /** - * CMS Domains + * Domains * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v3 * 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) : ''; } }