feat(php-nextgen-client): add support for streaming (#19192)

Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
This commit is contained in:
Emilien Escalle
2024-07-31 11:32:10 +02:00
committed by GitHub
parent 4874a0bce7
commit 7f551bb9a0
91 changed files with 21287 additions and 171 deletions

View File

@@ -0,0 +1,749 @@
<?php
/**
* AuthApi
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Api;
use InvalidArgumentException;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\Promise\PromiseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;
/**
* AuthApi Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class AuthApi
{
/**
* @var ClientInterface
*/
protected ClientInterface $client;
/**
* @var Configuration
*/
protected Configuration $config;
/**
* @var HeaderSelector
*/
protected HeaderSelector $headerSelector;
/**
* @var int Host index
*/
protected int $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'testAuthHttpBasic' => [
'application/json',
],
'testAuthHttpBearer' => [
'application/json',
],
];
/**
* @param ClientInterface|null $client
* @param Configuration|null $config
* @param HeaderSelector|null $selector
* @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,
int $hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $hostIndex;
}
/**
* Set the host index
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex(int $hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex(): int
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig(): Configuration
{
return $this->config;
}
/**
* Operation testAuthHttpBasic
*
* To test HTTP basic authentication
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBasic'] to see the possible values for this operation
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return string
*/
public function testAuthHttpBasic(
string $contentType = self::contentTypes['testAuthHttpBasic'][0]
): string
{
list($response) = $this->testAuthHttpBasicWithHttpInfo($contentType);
return $response;
}
/**
* Operation testAuthHttpBasicWithHttpInfo
*
* To test HTTP basic authentication
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBasic'] to see the possible values for this operation
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testAuthHttpBasicWithHttpInfo(
string $contentType = self::contentTypes['testAuthHttpBasic'][0]
): array
{
$request = $this->testAuthHttpBasicRequest($contentType);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
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:
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testAuthHttpBasicAsync
*
* To test HTTP basic authentication
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBasic'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testAuthHttpBasicAsync(
string $contentType = self::contentTypes['testAuthHttpBasic'][0]
): PromiseInterface
{
return $this->testAuthHttpBasicAsyncWithHttpInfo($contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testAuthHttpBasicAsyncWithHttpInfo
*
* To test HTTP basic authentication
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBasic'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testAuthHttpBasicAsyncWithHttpInfo(
string $contentType = self::contentTypes['testAuthHttpBasic'][0]
): PromiseInterface
{
$returnType = 'string';
$request = $this->testAuthHttpBasicRequest($contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'testAuthHttpBasic'
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBasic'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testAuthHttpBasicRequest(
string $contentType = self::contentTypes['testAuthHttpBasic'][0]
): Request
{
$resourcePath = '/auth/http/basic';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
$headers = $this->headerSelector->selectHeaders(
['text/plain', ],
$contentType,
$multipart
);
// for model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
}
}
// this endpoint requires HTTP basic authentication
if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) {
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation testAuthHttpBearer
*
* To test HTTP bearer authentication
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBearer'] to see the possible values for this operation
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return string
*/
public function testAuthHttpBearer(
string $contentType = self::contentTypes['testAuthHttpBearer'][0]
): string
{
list($response) = $this->testAuthHttpBearerWithHttpInfo($contentType);
return $response;
}
/**
* Operation testAuthHttpBearerWithHttpInfo
*
* To test HTTP bearer authentication
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBearer'] to see the possible values for this operation
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testAuthHttpBearerWithHttpInfo(
string $contentType = self::contentTypes['testAuthHttpBearer'][0]
): array
{
$request = $this->testAuthHttpBearerRequest($contentType);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
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:
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testAuthHttpBearerAsync
*
* To test HTTP bearer authentication
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBearer'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testAuthHttpBearerAsync(
string $contentType = self::contentTypes['testAuthHttpBearer'][0]
): PromiseInterface
{
return $this->testAuthHttpBearerAsyncWithHttpInfo($contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testAuthHttpBearerAsyncWithHttpInfo
*
* To test HTTP bearer authentication
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBearer'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testAuthHttpBearerAsyncWithHttpInfo(
string $contentType = self::contentTypes['testAuthHttpBearer'][0]
): PromiseInterface
{
$returnType = 'string';
$request = $this->testAuthHttpBearerRequest($contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'testAuthHttpBearer'
*
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testAuthHttpBearer'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testAuthHttpBearerRequest(
string $contentType = self::contentTypes['testAuthHttpBearer'][0]
): Request
{
$resourcePath = '/auth/http/bearer';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
$headers = $this->headerSelector->selectHeaders(
['text/plain', ],
$contentType,
$multipart
);
// for model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
}
}
// this endpoint requires Bearer authentication (access token)
if (!empty($this->config->getAccessToken())) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'POST',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Create http client option
*
* @throws \RuntimeException on file opening failure
* @return array of http client options
*/
protected function createHttpClientOption(): array
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
if (!$options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
}
}
return $options;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,516 @@
<?php
/**
* HeaderApi
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Api;
use InvalidArgumentException;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\Promise\PromiseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;
/**
* HeaderApi Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class HeaderApi
{
/**
* @var ClientInterface
*/
protected ClientInterface $client;
/**
* @var Configuration
*/
protected Configuration $config;
/**
* @var HeaderSelector
*/
protected HeaderSelector $headerSelector;
/**
* @var int Host index
*/
protected int $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'testHeaderIntegerBooleanStringEnums' => [
'application/json',
],
];
/**
* @param ClientInterface|null $client
* @param Configuration|null $config
* @param HeaderSelector|null $selector
* @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,
int $hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $hostIndex;
}
/**
* Set the host index
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex(int $hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex(): int
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig(): Configuration
{
return $this->config;
}
/**
* Operation testHeaderIntegerBooleanStringEnums
*
* Test header parameter(s)
*
* @param int|null $integer_header integer_header (optional)
* @param bool|null $boolean_header boolean_header (optional)
* @param string|null $string_header string_header (optional)
* @param string|null $enum_nonref_string_header enum_nonref_string_header (optional)
* @param StringEnumRef|null $enum_ref_string_header enum_ref_string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return string
*/
public function testHeaderIntegerBooleanStringEnums(
?int $integer_header = null,
?bool $boolean_header = null,
?string $string_header = null,
?string $enum_nonref_string_header = null,
?StringEnumRef $enum_ref_string_header = null,
string $contentType = self::contentTypes['testHeaderIntegerBooleanStringEnums'][0]
): string
{
list($response) = $this->testHeaderIntegerBooleanStringEnumsWithHttpInfo($integer_header, $boolean_header, $string_header, $enum_nonref_string_header, $enum_ref_string_header, $contentType);
return $response;
}
/**
* Operation testHeaderIntegerBooleanStringEnumsWithHttpInfo
*
* Test header parameter(s)
*
* @param int|null $integer_header (optional)
* @param bool|null $boolean_header (optional)
* @param string|null $string_header (optional)
* @param string|null $enum_nonref_string_header (optional)
* @param StringEnumRef|null $enum_ref_string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testHeaderIntegerBooleanStringEnumsWithHttpInfo(
?int $integer_header = null,
?bool $boolean_header = null,
?string $string_header = null,
?string $enum_nonref_string_header = null,
?StringEnumRef $enum_ref_string_header = null,
string $contentType = self::contentTypes['testHeaderIntegerBooleanStringEnums'][0]
): array
{
$request = $this->testHeaderIntegerBooleanStringEnumsRequest($integer_header, $boolean_header, $string_header, $enum_nonref_string_header, $enum_ref_string_header, $contentType);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
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:
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testHeaderIntegerBooleanStringEnumsAsync
*
* Test header parameter(s)
*
* @param int|null $integer_header (optional)
* @param bool|null $boolean_header (optional)
* @param string|null $string_header (optional)
* @param string|null $enum_nonref_string_header (optional)
* @param StringEnumRef|null $enum_ref_string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testHeaderIntegerBooleanStringEnumsAsync(
?int $integer_header = null,
?bool $boolean_header = null,
?string $string_header = null,
?string $enum_nonref_string_header = null,
?StringEnumRef $enum_ref_string_header = null,
string $contentType = self::contentTypes['testHeaderIntegerBooleanStringEnums'][0]
): PromiseInterface
{
return $this->testHeaderIntegerBooleanStringEnumsAsyncWithHttpInfo($integer_header, $boolean_header, $string_header, $enum_nonref_string_header, $enum_ref_string_header, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testHeaderIntegerBooleanStringEnumsAsyncWithHttpInfo
*
* Test header parameter(s)
*
* @param int|null $integer_header (optional)
* @param bool|null $boolean_header (optional)
* @param string|null $string_header (optional)
* @param string|null $enum_nonref_string_header (optional)
* @param StringEnumRef|null $enum_ref_string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testHeaderIntegerBooleanStringEnumsAsyncWithHttpInfo(
$integer_header = null,
$boolean_header = null,
$string_header = null,
$enum_nonref_string_header = null,
$enum_ref_string_header = null,
string $contentType = self::contentTypes['testHeaderIntegerBooleanStringEnums'][0]
): PromiseInterface
{
$returnType = 'string';
$request = $this->testHeaderIntegerBooleanStringEnumsRequest($integer_header, $boolean_header, $string_header, $enum_nonref_string_header, $enum_ref_string_header, $contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'testHeaderIntegerBooleanStringEnums'
*
* @param int|null $integer_header (optional)
* @param bool|null $boolean_header (optional)
* @param string|null $string_header (optional)
* @param string|null $enum_nonref_string_header (optional)
* @param StringEnumRef|null $enum_ref_string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testHeaderIntegerBooleanStringEnumsRequest(
$integer_header = null,
$boolean_header = null,
$string_header = null,
$enum_nonref_string_header = null,
$enum_ref_string_header = null,
string $contentType = self::contentTypes['testHeaderIntegerBooleanStringEnums'][0]
): Request
{
$resourcePath = '/header/integer/boolean/string/enums';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// header params
if ($integer_header !== null) {
$headerParams['integer_header'] = ObjectSerializer::toHeaderValue($integer_header);
}
// header params
if ($boolean_header !== null) {
$headerParams['boolean_header'] = ObjectSerializer::toHeaderValue($boolean_header);
}
// header params
if ($string_header !== null) {
$headerParams['string_header'] = ObjectSerializer::toHeaderValue($string_header);
}
// header params
if ($enum_nonref_string_header !== null) {
$headerParams['enum_nonref_string_header'] = ObjectSerializer::toHeaderValue($enum_nonref_string_header);
}
// header params
if ($enum_ref_string_header !== null) {
$headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header);
}
$headers = $this->headerSelector->selectHeaders(
['text/plain', ],
$contentType,
$multipart
);
// for model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Create http client option
*
* @throws \RuntimeException on file opening failure
* @return array of http client options
*/
protected function createHttpClientOption(): array
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
if (!$options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
}
}
return $options;
}
}

View File

@@ -0,0 +1,541 @@
<?php
/**
* PathApi
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Api;
use InvalidArgumentException;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\Promise\PromiseInterface;
use OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;
/**
* PathApi Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class PathApi
{
/**
* @var ClientInterface
*/
protected ClientInterface $client;
/**
* @var Configuration
*/
protected Configuration $config;
/**
* @var HeaderSelector
*/
protected HeaderSelector $headerSelector;
/**
* @var int Host index
*/
protected int $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath' => [
'application/json',
],
];
/**
* @param ClientInterface|null $client
* @param Configuration|null $config
* @param HeaderSelector|null $selector
* @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,
int $hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
$this->headerSelector = $selector ?: new HeaderSelector();
$this->hostIndex = $hostIndex;
}
/**
* Set the host index
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex(int $hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex(): int
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig(): Configuration
{
return $this->config;
}
/**
* Operation testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath
*
* Test path parameter(s)
*
* @param string $path_string path_string (required)
* @param int $path_integer path_integer (required)
* @param string $enum_nonref_string_path enum_nonref_string_path (required)
* @param StringEnumRef $enum_ref_string_path enum_ref_string_path (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return string
*/
public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath(
string $path_string,
int $path_integer,
string $enum_nonref_string_path,
StringEnumRef $enum_ref_string_path,
string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'][0]
): string
{
list($response) = $this->testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo($path_string, $path_integer, $enum_nonref_string_path, $enum_ref_string_path, $contentType);
return $response;
}
/**
* Operation testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo
*
* Test path parameter(s)
*
* @param string $path_string (required)
* @param int $path_integer (required)
* @param string $enum_nonref_string_path (required)
* @param StringEnumRef $enum_ref_string_path (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
*
* @throws ApiException on non-2xx response or if the response body is not in the expected format
* @throws InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathWithHttpInfo(
string $path_string,
int $path_integer,
string $enum_nonref_string_path,
StringEnumRef $enum_ref_string_path,
string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'][0]
): array
{
$request = $this->testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequest($path_string, $path_integer, $enum_nonref_string_path, $enum_ref_string_path, $contentType);
try {
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
);
} catch (ConnectException $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
null,
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:
if (in_array('string', ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
try {
$content = json_decode($content, false, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $exception) {
throw new ApiException(
sprintf(
'Error JSON decoding server response (%s)',
$request->getUri()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathAsync
*
* Test path parameter(s)
*
* @param string $path_string (required)
* @param int $path_integer (required)
* @param string $enum_nonref_string_path (required)
* @param StringEnumRef $enum_ref_string_path (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathAsync(
string $path_string,
int $path_integer,
string $enum_nonref_string_path,
StringEnumRef $enum_ref_string_path,
string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'][0]
): PromiseInterface
{
return $this->testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathAsyncWithHttpInfo($path_string, $path_integer, $enum_nonref_string_path, $enum_ref_string_path, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathAsyncWithHttpInfo
*
* Test path parameter(s)
*
* @param string $path_string (required)
* @param int $path_integer (required)
* @param string $enum_nonref_string_path (required)
* @param StringEnumRef $enum_ref_string_path (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathAsyncWithHttpInfo(
$path_string,
$path_integer,
$enum_nonref_string_path,
$enum_ref_string_path,
string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'][0]
): PromiseInterface
{
$returnType = 'string';
$request = $this->testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequest($path_string, $path_integer, $enum_nonref_string_path, $enum_ref_string_path, $contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if (in_array($returnType, ['\SplFileObject', '\Psr\Http\Message\StreamInterface'])) {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
(string) $response->getBody()
);
}
);
}
/**
* Create request for operation 'testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'
*
* @param string $path_string (required)
* @param int $path_integer (required)
* @param string $enum_nonref_string_path (required)
* @param StringEnumRef $enum_ref_string_path (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPathRequest(
$path_string,
$path_integer,
$enum_nonref_string_path,
$enum_ref_string_path,
string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'][0]
): Request
{
// verify the required parameter 'path_string' is set
if ($path_string === null || (is_array($path_string) && count($path_string) === 0)) {
throw new InvalidArgumentException(
'Missing the required parameter $path_string when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'
);
}
// verify the required parameter 'path_integer' is set
if ($path_integer === null || (is_array($path_integer) && count($path_integer) === 0)) {
throw new InvalidArgumentException(
'Missing the required parameter $path_integer when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'
);
}
// verify the required parameter 'enum_nonref_string_path' is set
if ($enum_nonref_string_path === null || (is_array($enum_nonref_string_path) && count($enum_nonref_string_path) === 0)) {
throw new InvalidArgumentException(
'Missing the required parameter $enum_nonref_string_path when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'
);
}
// verify the required parameter 'enum_ref_string_path' is set
if ($enum_ref_string_path === null || (is_array($enum_ref_string_path) && count($enum_ref_string_path) === 0)) {
throw new InvalidArgumentException(
'Missing the required parameter $enum_ref_string_path when calling testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'
);
}
$resourcePath = '/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// path params
if ($path_string !== null) {
$resourcePath = str_replace(
'{' . 'path_string' . '}',
ObjectSerializer::toPathValue($path_string),
$resourcePath
);
}
// path params
if ($path_integer !== null) {
$resourcePath = str_replace(
'{' . 'path_integer' . '}',
ObjectSerializer::toPathValue($path_integer),
$resourcePath
);
}
// path params
if ($enum_nonref_string_path !== null) {
$resourcePath = str_replace(
'{' . 'enum_nonref_string_path' . '}',
ObjectSerializer::toPathValue($enum_nonref_string_path),
$resourcePath
);
}
// path params
if ($enum_ref_string_path !== null) {
$resourcePath = str_replace(
'{' . 'enum_ref_string_path' . '}',
ObjectSerializer::toPathValue($enum_ref_string_path),
$resourcePath
);
}
$headers = $this->headerSelector->selectHeaders(
['text/plain', ],
$contentType,
$multipart
);
// for model (json/xml)
if (count($formParams) > 0) {
if ($multipart) {
$multipartContents = [];
foreach ($formParams as $formParamName => $formParamValue) {
$formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue];
foreach ($formParamValueItems as $formParamValueItem) {
$multipartContents[] = [
'name' => $formParamName,
'contents' => $formParamValueItem
];
}
}
// for HTTP post (form)
$httpBody = new MultipartStream($multipartContents);
} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
}
}
$defaultHeaders = [];
if ($this->config->getUserAgent()) {
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
}
$headers = array_merge(
$defaultHeaders,
$headerParams,
$headers
);
$operationHost = $this->config->getHost();
$query = ObjectSerializer::buildQuery($queryParams);
return new Request(
'GET',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Create http client option
*
* @throws \RuntimeException on file opening failure
* @return array of http client options
*/
protected function createHttpClientOption(): array
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
if (!$options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
}
}
return $options;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,119 @@
<?php
/**
* ApiException
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client;
use Exception;
use stdClass;
/**
* ApiException Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class ApiException extends Exception
{
/**
* The HTTP body of the server response either as Json or string.
*
* @var stdClass|string|null
*/
protected stdClass|string|null $responseBody;
/**
* The HTTP header of the server response.
*
* @var string[][]|null
*/
protected ?array $responseHeaders;
/**
* The deserialized response object
*
* @var mixed
*/
protected mixed $responseObject = null;
/**
* Constructor
*
* @param string $message Error message
* @param int $code HTTP status code
* @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(string $message = "", int $code = 0, ?array $responseHeaders = [], stdClass|string|null $responseBody = null)
{
parent::__construct($message, $code);
$this->responseHeaders = $responseHeaders;
$this->responseBody = $responseBody;
}
/**
* Gets the HTTP response header
*
* @return string[][]|null HTTP response header
*/
public function getResponseHeaders(): ?array
{
return $this->responseHeaders;
}
/**
* Gets the HTTP body of the server response either as Json or string
*
* @return stdClass|string|null HTTP body of the server response either as \stdClass or string
*/
public function getResponseBody(): stdClass|string|null
{
return $this->responseBody;
}
/**
* Sets the deserialized response object (during deserialization)
*
* @param mixed $obj Deserialized response object
*
* @return void
*/
public function setResponseObject(mixed $obj): void
{
$this->responseObject = $obj;
}
/**
* Gets the deserialized response object (during deserialization)
*
* @return mixed the deserialized response object
*/
public function getResponseObject(): mixed
{
return $this->responseObject;
}
}

View File

@@ -0,0 +1,527 @@
<?php
/**
* Configuration
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client;
use InvalidArgumentException;
/**
* Configuration Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class Configuration
{
public const BOOLEAN_FORMAT_INT = 'int';
public const BOOLEAN_FORMAT_STRING = 'string';
/**
* @var Configuration|null
*/
private static ?Configuration $defaultConfiguration = null;
/**
* Associate array to store API key(s)
*
* @var string[]
*/
protected array $apiKeys = [];
/**
* Associate array to store API prefix (e.g. Bearer)
*
* @var string[]
*/
protected array $apiKeyPrefixes = [];
/**
* Access token for OAuth/Bearer authentication
*
* @var string
*/
protected string $accessToken = '';
/**
* Boolean format for query string
*
* @var string
*/
protected string $booleanFormatForQueryString = self::BOOLEAN_FORMAT_INT;
/**
* Username for HTTP basic authentication
*
* @var string
*/
protected string $username = '';
/**
* Password for HTTP basic authentication
*
* @var string
*/
protected string $password = '';
/**
* The host
*
* @var string
*/
protected string $host = 'http://localhost:3000';
/**
* User agent of the HTTP request, set to "OpenAPI-Generator/{version}/PHP" by default
*
* @var string
*/
protected string $userAgent = 'OpenAPI-Generator/1.0.0/PHP';
/**
* Debug switch (default set to false)
*
* @var bool
*/
protected bool $debug = false;
/**
* Debug file location (log to STDOUT by default)
*
* @var string
*/
protected string $debugFile = 'php://output';
/**
* Debug file location (log to STDOUT by default)
*
* @var string
*/
protected string $tempFolderPath;
/**
* Constructor
*/
public function __construct()
{
$this->tempFolderPath = sys_get_temp_dir();
}
/**
* Sets API key
*
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
* @param string $key API key or token
*
* @return $this
*/
public function setApiKey(string $apiKeyIdentifier, string $key): static
{
$this->apiKeys[$apiKeyIdentifier] = $key;
return $this;
}
/**
* Gets API key
*
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
*
* @return null|string API key or token
*/
public function getApiKey(string $apiKeyIdentifier): ?string
{
return $this->apiKeys[$apiKeyIdentifier] ?? null;
}
/**
* Sets the prefix for API key (e.g. Bearer)
*
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
* @param string $prefix API key prefix, e.g. Bearer
*
* @return $this
*/
public function setApiKeyPrefix(string $apiKeyIdentifier, string $prefix): static
{
$this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix;
return $this;
}
/**
* Gets API key prefix
*
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
*
* @return null|string
*/
public function getApiKeyPrefix(string $apiKeyIdentifier): ?string
{
return $this->apiKeyPrefixes[$apiKeyIdentifier] ?? null;
}
/**
* Sets the access token for OAuth
*
* @param string $accessToken Token for OAuth
*
* @return $this
*/
public function setAccessToken(string $accessToken): static
{
$this->accessToken = $accessToken;
return $this;
}
/**
* Gets the access token for OAuth
*
* @return string Access token for OAuth
*/
public function getAccessToken(): string
{
return $this->accessToken;
}
/**
* Sets boolean format for query string.
*
* @param string $booleanFormat Boolean format for query string
*
* @return $this
*/
public function setBooleanFormatForQueryString(string $booleanFormat): static
{
$this->booleanFormatForQueryString = $booleanFormat;
return $this;
}
/**
* Gets boolean format for query string.
*
* @return string Boolean format for query string
*/
public function getBooleanFormatForQueryString(): string
{
return $this->booleanFormatForQueryString;
}
/**
* Sets the username for HTTP basic authentication
*
* @param string $username Username for HTTP basic authentication
*
* @return $this
*/
public function setUsername(string $username): static
{
$this->username = $username;
return $this;
}
/**
* Gets the username for HTTP basic authentication
*
* @return string Username for HTTP basic authentication
*/
public function getUsername(): string
{
return $this->username;
}
/**
* Sets the password for HTTP basic authentication
*
* @param string $password Password for HTTP basic authentication
*
* @return $this
*/
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
/**
* Gets the password for HTTP basic authentication
*
* @return string Password for HTTP basic authentication
*/
public function getPassword(): string
{
return $this->password;
}
/**
* Sets the host
*
* @param string $host Host
*
* @return $this
*/
public function setHost(string $host): static
{
$this->host = $host;
return $this;
}
/**
* Gets the host
*
* @return string Host
*/
public function getHost(): string
{
return $this->host;
}
/**
* Sets the user agent of the api client
*
* @param string $userAgent the user agent of the api client
*
* @throws InvalidArgumentException
* @return $this
*/
public function setUserAgent(string $userAgent): static
{
$this->userAgent = $userAgent;
return $this;
}
/**
* Gets the user agent of the api client
*
* @return string user agent
*/
public function getUserAgent(): string
{
return $this->userAgent;
}
/**
* Sets debug flag
*
* @param bool $debug Debug flag
*
* @return $this
*/
public function setDebug(bool $debug): static
{
$this->debug = $debug;
return $this;
}
/**
* Gets the debug flag
*
* @return bool
*/
public function getDebug(): bool
{
return $this->debug;
}
/**
* Sets the debug file
*
* @param string $debugFile Debug file
*
* @return $this
*/
public function setDebugFile(string $debugFile): static
{
$this->debugFile = $debugFile;
return $this;
}
/**
* Gets the debug file
*
* @return string
*/
public function getDebugFile(): string
{
return $this->debugFile;
}
/**
* Sets the temp folder path
*
* @param string $tempFolderPath Temp folder path
*
* @return $this
*/
public function setTempFolderPath(string $tempFolderPath): static
{
$this->tempFolderPath = $tempFolderPath;
return $this;
}
/**
* Gets the temp folder path
*
* @return string Temp folder path
*/
public function getTempFolderPath(): string
{
return $this->tempFolderPath;
}
/**
* Gets the default configuration instance
*
* @return Configuration
*/
public static function getDefaultConfiguration(): Configuration
{
if (self::$defaultConfiguration === null) {
self::$defaultConfiguration = new Configuration();
}
return self::$defaultConfiguration;
}
/**
* Sets the default configuration instance
*
* @param Configuration $config An instance of the Configuration Object
*
* @return void
*/
public static function setDefaultConfiguration(Configuration $config): void
{
self::$defaultConfiguration = $config;
}
/**
* Gets the essential information for debugging
*
* @return string The report for debugging
*/
public static function toDebugReport(): string
{
$report = 'PHP SDK (OpenAPI\Client) Debug Report:' . PHP_EOL;
$report .= ' OS: ' . php_uname() . PHP_EOL;
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
$report .= ' The version of the OpenAPI document: 0.1.0' . PHP_EOL;
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
return $report;
}
/**
* Get API key (with prefix if set)
*
* @param string $apiKeyIdentifier name of apikey
*
* @return null|string API key with the prefix
*/
public function getApiKeyWithPrefix(string $apiKeyIdentifier): ?string
{
$prefix = $this->getApiKeyPrefix($apiKeyIdentifier);
$apiKey = $this->getApiKey($apiKeyIdentifier);
if ($apiKey === null) {
return null;
}
if ($prefix === null) {
$keyWithPrefix = $apiKey;
} else {
$keyWithPrefix = $prefix . ' ' . $apiKey;
}
return $keyWithPrefix;
}
/**
* Returns an array of host settings
*
* @return array an array of host settings
*/
public function getHostSettings(): array
{
return [
[
"url" => "http://localhost:3000",
"description" => "No description provided",
]
];
}
/**
* Returns URL based on host settings, index and variables
*
* @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients
* @param int $hostIndex index of the host settings
* @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, int $hostIndex, array $variables = null): string
{
if (null === $variables) {
$variables = [];
}
// check array index out of bound
if ($hostIndex < 0 || $hostIndex >= count($hostSettings)) {
throw new InvalidArgumentException("Invalid index $hostIndex when selecting the host. Must be less than ".count($hostSettings));
}
$host = $hostSettings[$hostIndex];
$url = $host["url"];
// go through variable and assign a value
foreach ($host["variables"] ?? [] as $name => $variable) {
if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user
if (!isset($variable['enum_values']) || in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum
$url = str_replace("{".$name."}", $variables[$name], $url);
} else {
throw new InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"]).".");
}
} else {
// use default value
$url = str_replace("{".$name."}", $variable["default_value"], $url);
}
}
return $url;
}
/**
* Returns URL based on the index and variables
*
* @param int $index index of the host settings
* @param array|null $variables hash of variable and the corresponding value (optional)
* @return string URL based on host settings
*/
public function getHostFromSettings(int $index, ?array $variables = null): string
{
return self::getHostString($this->getHostSettings(), $index, $variables);
}
}

View File

@@ -0,0 +1,244 @@
<?php
/**
* HeaderSelector
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client;
/**
* HeaderSelector Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class HeaderSelector
{
/**
* @param string[] $accept
* @param string $contentType
* @param bool $isMultipart
* @return string[]
*/
public function selectHeaders(array $accept, string $contentType, bool $isMultipart): array
{
$headers = [];
$accept = $this->selectAcceptHeader($accept);
if ($accept !== null) {
$headers['Accept'] = $accept;
}
if (!$isMultipart) {
if($contentType === '') {
$contentType = 'application/json';
}
$headers['Content-Type'] = $contentType;
}
return $headers;
}
/**
* Return the header 'Accept' based on an array of Accept provided.
*
* @param string[] $accept Array of header
*
* @return null|string Accept (e.g. application/json)
*/
private function selectAcceptHeader(array $accept): ?string
{
# filter out empty entries
$accept = array_filter($accept);
if (count($accept) === 0) {
return null;
}
# If there's only one Accept header, just use it
if (count($accept) === 1) {
return reset($accept);
}
# 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);
if (count($headersWithJson) === 0) {
return implode(',', $accept);
}
# If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1,
# to give the highest priority to json-like headers - recalculating the existing ones, if needed
return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson);
}
/**
* Create an Accept header string from the given "Accept" headers array, recalculating all weights
*
* @param string[] $accept Array of Accept Headers
* @param string[] $headersWithJson Array of Accept Headers of type "json"
*
* @return string "Accept" Header (e.g. "application/json, text/html; q=0.9")
*/
private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string
{
$processedHeaders = [
'withApplicationJson' => [],
'withJson' => [],
'withoutJson' => [],
];
foreach ($accept as $header) {
$headerData = $this->getHeaderAndWeight($header);
if (stripos($headerData['header'], 'application/json') === 0) {
$processedHeaders['withApplicationJson'][] = $headerData;
} elseif (in_array($header, $headersWithJson, true)) {
$processedHeaders['withJson'][] = $headerData;
} else {
$processedHeaders['withoutJson'][] = $headerData;
}
}
$acceptHeaders = [];
$currentWeight = 1000;
$hasMoreThan28Headers = count($accept) > 28;
foreach($processedHeaders as $headers) {
if (count($headers) > 0) {
$acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers);
}
}
$acceptHeaders = array_merge(...$acceptHeaders);
return implode(',', $acceptHeaders);
}
/**
* Given an Accept header, returns an associative array splitting the header and its weight
*
* @param string $header "Accept" Header
*
* @return array with the header and its weight
*/
private function getHeaderAndWeight(string $header): array
{
# matches headers with weight, splitting the header and the weight in $outputArray
if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) {
$headerData = [
'header' => $outputArray[1],
'weight' => (int)($outputArray[2] * 1000),
];
} else {
$headerData = [
'header' => trim($header),
'weight' => 1000,
];
}
return $headerData;
}
/**
* @param array[] $headers
* @param float $currentWeight
* @param bool $hasMoreThan28Headers
* @return string[] array of adjusted "Accept" headers
*/
private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array
{
usort($headers, function (array $a, array $b) {
return $b['weight'] - $a['weight'];
});
$acceptHeaders = [];
foreach ($headers as $index => $header) {
if($index > 0 && $headers[$index - 1]['weight'] > $header['weight'])
{
$currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers);
}
$weight = $currentWeight;
$acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight);
}
$currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers);
return $acceptHeaders;
}
/**
* @param string $header
* @param int $weight
* @return string
*/
private function buildAcceptHeader(string $header, int $weight): string
{
if($weight === 1000) {
return $header;
}
return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0');
}
/**
* Calculate the next weight, based on the current one.
*
* If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the
* following formula:
*
* next weight = current weight - 10 ^ (floor(log(current weight - 1)))
*
* ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) )
*
* Starting from 1000, this generates the following series:
*
* 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
*
* The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works
* if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1
* decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc.
*
* @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value)
* @param bool $hasMoreThan28Headers
* @return int
*/
public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int
{
if ($currentWeight <= 1) {
return 1;
}
if ($hasMoreThan28Headers) {
return $currentWeight - 1;
}
return $currentWeight - 10 ** floor( log10($currentWeight - 1) );
}
}

View File

@@ -0,0 +1,442 @@
<?php
/**
* Bird
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* Bird Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class Bird implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'Bird';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'size' => 'string',
'color' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'size' => null,
'color' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'size' => false,
'color' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'size' => 'size',
'color' => 'color'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'size' => 'setSize',
'color' => 'setColor'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'size' => 'getSize',
'color' => 'getColor'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('size', $data ?? [], null);
$this->setIfExists('color', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets size
*
* @return string|null
*/
public function getSize(): ?string
{
return $this->container['size'];
}
/**
* Sets size
*
* @param string|null $size size
*
* @return $this
*/
public function setSize(?string $size): static
{
if (is_null($size)) {
throw new InvalidArgumentException('non-nullable size cannot be null');
}
$this->container['size'] = $size;
return $this;
}
/**
* Gets color
*
* @return string|null
*/
public function getColor(): ?string
{
return $this->container['color'];
}
/**
* Sets color
*
* @param string|null $color color
*
* @return $this
*/
public function setColor(?string $color): static
{
if (is_null($color)) {
throw new InvalidArgumentException('non-nullable color cannot be null');
}
$this->container['color'] = $color;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,442 @@
<?php
/**
* Category
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* Category Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class Category implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'Category';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'id' => 'int',
'name' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'id' => 'int64',
'name' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'id' => false,
'name' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'id' => 'id',
'name' => 'name'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'id' => 'setId',
'name' => 'setName'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'id' => 'getId',
'name' => 'getName'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('id', $data ?? [], null);
$this->setIfExists('name', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets id
*
* @return int|null
*/
public function getId(): ?int
{
return $this->container['id'];
}
/**
* Sets id
*
* @param int|null $id id
*
* @return $this
*/
public function setId(?int $id): static
{
if (is_null($id)) {
throw new InvalidArgumentException('non-nullable id cannot be null');
}
$this->container['id'] = $id;
return $this;
}
/**
* Gets name
*
* @return string|null
*/
public function getName(): ?string
{
return $this->container['name'];
}
/**
* Sets name
*
* @param string|null $name name
*
* @return $this
*/
public function setName(?string $name): static
{
if (is_null($name)) {
throw new InvalidArgumentException('non-nullable name cannot be null');
}
$this->container['name'] = $name;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,466 @@
<?php
/**
* DataQuery
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
/**
* DataQuery Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class DataQuery extends Query
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'DataQuery';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'suffix' => 'string',
'text' => 'string',
'date' => '\DateTime'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'suffix' => null,
'text' => null,
'date' => 'date-time'
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'suffix' => false,
'text' => false,
'date' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes + parent::openAPITypes();
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats + parent::openAPIFormats();
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables + parent::openAPINullables();
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'suffix' => 'suffix',
'text' => 'text',
'date' => 'date'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'suffix' => 'setSuffix',
'text' => 'setText',
'date' => 'setDate'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'suffix' => 'getSuffix',
'text' => 'getText',
'date' => 'getDate'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return parent::attributeMap() + self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return parent::setters() + self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return parent::getters() + self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
parent::__construct($data);
$this->setIfExists('suffix', $data ?? [], null);
$this->setIfExists('text', $data ?? [], null);
$this->setIfExists('date', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = parent::listInvalidProperties();
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets suffix
*
* @return string|null
*/
public function getSuffix(): ?string
{
return $this->container['suffix'];
}
/**
* Sets suffix
*
* @param string|null $suffix test suffix
*
* @return $this
*/
public function setSuffix(?string $suffix): static
{
if (is_null($suffix)) {
throw new InvalidArgumentException('non-nullable suffix cannot be null');
}
$this->container['suffix'] = $suffix;
return $this;
}
/**
* Gets text
*
* @return string|null
*/
public function getText(): ?string
{
return $this->container['text'];
}
/**
* Sets text
*
* @param string|null $text Some text containing white spaces
*
* @return $this
*/
public function setText(?string $text): static
{
if (is_null($text)) {
throw new InvalidArgumentException('non-nullable text cannot be null');
}
$this->container['text'] = $text;
return $this;
}
/**
* Gets date
*
* @return \DateTime|null
*/
public function getDate(): ?\DateTime
{
return $this->container['date'];
}
/**
* Sets date
*
* @param \DateTime|null $date A date
*
* @return $this
*/
public function setDate(?\DateTime $date): static
{
if (is_null($date)) {
throw new InvalidArgumentException('non-nullable date cannot be null');
}
$this->container['date'] = $date;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,694 @@
<?php
/**
* DefaultValue
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* DefaultValue Class Doc Comment
*
* @description to test the default value of properties
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class DefaultValue implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'DefaultValue';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'array_string_enum_ref_default' => '\OpenAPI\Client\Model\StringEnumRef[]',
'array_string_enum_default' => 'string[]',
'array_string_default' => 'string[]',
'array_integer_default' => 'int[]',
'array_string' => 'string[]',
'array_string_nullable' => 'string[]',
'array_string_extension_nullable' => 'string[]',
'string_nullable' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'array_string_enum_ref_default' => null,
'array_string_enum_default' => null,
'array_string_default' => null,
'array_integer_default' => null,
'array_string' => null,
'array_string_nullable' => null,
'array_string_extension_nullable' => null,
'string_nullable' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'array_string_enum_ref_default' => false,
'array_string_enum_default' => false,
'array_string_default' => false,
'array_integer_default' => false,
'array_string' => false,
'array_string_nullable' => true,
'array_string_extension_nullable' => true,
'string_nullable' => true
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'array_string_enum_ref_default' => 'array_string_enum_ref_default',
'array_string_enum_default' => 'array_string_enum_default',
'array_string_default' => 'array_string_default',
'array_integer_default' => 'array_integer_default',
'array_string' => 'array_string',
'array_string_nullable' => 'array_string_nullable',
'array_string_extension_nullable' => 'array_string_extension_nullable',
'string_nullable' => 'string_nullable'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'array_string_enum_ref_default' => 'setArrayStringEnumRefDefault',
'array_string_enum_default' => 'setArrayStringEnumDefault',
'array_string_default' => 'setArrayStringDefault',
'array_integer_default' => 'setArrayIntegerDefault',
'array_string' => 'setArrayString',
'array_string_nullable' => 'setArrayStringNullable',
'array_string_extension_nullable' => 'setArrayStringExtensionNullable',
'string_nullable' => 'setStringNullable'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'array_string_enum_ref_default' => 'getArrayStringEnumRefDefault',
'array_string_enum_default' => 'getArrayStringEnumDefault',
'array_string_default' => 'getArrayStringDefault',
'array_integer_default' => 'getArrayIntegerDefault',
'array_string' => 'getArrayString',
'array_string_nullable' => 'getArrayStringNullable',
'array_string_extension_nullable' => 'getArrayStringExtensionNullable',
'string_nullable' => 'getStringNullable'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
public const ARRAY_STRING_ENUM_DEFAULT_SUCCESS = 'success';
public const ARRAY_STRING_ENUM_DEFAULT_FAILURE = 'failure';
public const ARRAY_STRING_ENUM_DEFAULT_UNCLASSIFIED = 'unclassified';
/**
* Gets allowable values of the enum
*
* @return string[]
*/
public function getArrayStringEnumDefaultAllowableValues()
{
return [
self::ARRAY_STRING_ENUM_DEFAULT_SUCCESS,
self::ARRAY_STRING_ENUM_DEFAULT_FAILURE,
self::ARRAY_STRING_ENUM_DEFAULT_UNCLASSIFIED,
];
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('array_string_enum_ref_default', $data ?? [], [["success","failure"]]);
$this->setIfExists('array_string_enum_default', $data ?? [], [["success","failure"]]);
$this->setIfExists('array_string_default', $data ?? [], [["failure","skipped"]]);
$this->setIfExists('array_integer_default', $data ?? [], [[1,3]]);
$this->setIfExists('array_string', $data ?? [], null);
$this->setIfExists('array_string_nullable', $data ?? [], null);
$this->setIfExists('array_string_extension_nullable', $data ?? [], null);
$this->setIfExists('string_nullable', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets array_string_enum_ref_default
*
* @return \OpenAPI\Client\Model\StringEnumRef[]|null
*/
public function getArrayStringEnumRefDefault(): ?array
{
return $this->container['array_string_enum_ref_default'];
}
/**
* Sets array_string_enum_ref_default
*
* @param \OpenAPI\Client\Model\StringEnumRef[]|null $array_string_enum_ref_default array_string_enum_ref_default
*
* @return $this
*/
public function setArrayStringEnumRefDefault(?array $array_string_enum_ref_default): static
{
if (is_null($array_string_enum_ref_default)) {
throw new InvalidArgumentException('non-nullable array_string_enum_ref_default cannot be null');
}
$this->container['array_string_enum_ref_default'] = $array_string_enum_ref_default;
return $this;
}
/**
* Gets array_string_enum_default
*
* @return string[]|null
*/
public function getArrayStringEnumDefault(): ?array
{
return $this->container['array_string_enum_default'];
}
/**
* Sets array_string_enum_default
*
* @param string[]|null $array_string_enum_default array_string_enum_default
*
* @return $this
*/
public function setArrayStringEnumDefault(?array $array_string_enum_default): static
{
if (is_null($array_string_enum_default)) {
throw new InvalidArgumentException('non-nullable array_string_enum_default cannot be null');
}
$allowedValues = $this->getArrayStringEnumDefaultAllowableValues();
if (array_diff($array_string_enum_default, $allowedValues)) {
throw new InvalidArgumentException(
sprintf(
"Invalid value for 'array_string_enum_default', must be one of '%s'",
implode("', '", $allowedValues)
)
);
}
$this->container['array_string_enum_default'] = $array_string_enum_default;
return $this;
}
/**
* Gets array_string_default
*
* @return string[]|null
*/
public function getArrayStringDefault(): ?array
{
return $this->container['array_string_default'];
}
/**
* Sets array_string_default
*
* @param string[]|null $array_string_default array_string_default
*
* @return $this
*/
public function setArrayStringDefault(?array $array_string_default): static
{
if (is_null($array_string_default)) {
throw new InvalidArgumentException('non-nullable array_string_default cannot be null');
}
$this->container['array_string_default'] = $array_string_default;
return $this;
}
/**
* Gets array_integer_default
*
* @return int[]|null
*/
public function getArrayIntegerDefault(): ?array
{
return $this->container['array_integer_default'];
}
/**
* Sets array_integer_default
*
* @param int[]|null $array_integer_default array_integer_default
*
* @return $this
*/
public function setArrayIntegerDefault(?array $array_integer_default): static
{
if (is_null($array_integer_default)) {
throw new InvalidArgumentException('non-nullable array_integer_default cannot be null');
}
$this->container['array_integer_default'] = $array_integer_default;
return $this;
}
/**
* Gets array_string
*
* @return string[]|null
*/
public function getArrayString(): ?array
{
return $this->container['array_string'];
}
/**
* Sets array_string
*
* @param string[]|null $array_string array_string
*
* @return $this
*/
public function setArrayString(?array $array_string): static
{
if (is_null($array_string)) {
throw new InvalidArgumentException('non-nullable array_string cannot be null');
}
$this->container['array_string'] = $array_string;
return $this;
}
/**
* Gets array_string_nullable
*
* @return string[]|null
*/
public function getArrayStringNullable(): ?array
{
return $this->container['array_string_nullable'];
}
/**
* Sets array_string_nullable
*
* @param string[]|null $array_string_nullable array_string_nullable
*
* @return $this
*/
public function setArrayStringNullable(?array $array_string_nullable): static
{
if (is_null($array_string_nullable)) {
array_push($this->openAPINullablesSetToNull, 'array_string_nullable');
} else {
$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
$index = array_search('array_string_nullable', $nullablesSetToNull);
if ($index !== FALSE) {
unset($nullablesSetToNull[$index]);
$this->setOpenAPINullablesSetToNull($nullablesSetToNull);
}
}
$this->container['array_string_nullable'] = $array_string_nullable;
return $this;
}
/**
* Gets array_string_extension_nullable
*
* @return string[]|null
*/
public function getArrayStringExtensionNullable(): ?array
{
return $this->container['array_string_extension_nullable'];
}
/**
* Sets array_string_extension_nullable
*
* @param string[]|null $array_string_extension_nullable array_string_extension_nullable
*
* @return $this
*/
public function setArrayStringExtensionNullable(?array $array_string_extension_nullable): static
{
if (is_null($array_string_extension_nullable)) {
array_push($this->openAPINullablesSetToNull, 'array_string_extension_nullable');
} else {
$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
$index = array_search('array_string_extension_nullable', $nullablesSetToNull);
if ($index !== FALSE) {
unset($nullablesSetToNull[$index]);
$this->setOpenAPINullablesSetToNull($nullablesSetToNull);
}
}
$this->container['array_string_extension_nullable'] = $array_string_extension_nullable;
return $this;
}
/**
* Gets string_nullable
*
* @return string|null
*/
public function getStringNullable(): ?string
{
return $this->container['string_nullable'];
}
/**
* Sets string_nullable
*
* @param string|null $string_nullable string_nullable
*
* @return $this
*/
public function setStringNullable(?string $string_nullable): static
{
if (is_null($string_nullable)) {
array_push($this->openAPINullablesSetToNull, 'string_nullable');
} else {
$nullablesSetToNull = $this->getOpenAPINullablesSetToNull();
$index = array_search('string_nullable', $nullablesSetToNull);
if ($index !== FALSE) {
unset($nullablesSetToNull[$index]);
$this->setOpenAPINullablesSetToNull($nullablesSetToNull);
}
}
$this->container['string_nullable'] = $string_nullable;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,111 @@
<?php
/**
* ModelInterface
*
* PHP version 8.1
*
* @package OpenAPI\Client\Model
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
/**
* Interface abstracting model access.
*
* @package OpenAPI\Client\Model
* @author OpenAPI Generator team
*/
interface ModelInterface
{
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string;
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array
*/
public static function openAPITypes(): array;
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array
*/
public static function openAPIFormats(): array;
/**
* Array of attributes where the key is the local name, and the value is the original name
*
* @return array
*/
public static function attributeMap(): array;
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array
*/
public static function setters(): array;
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array
*/
public static function getters(): array;
/**
* Show all the invalid properties with reasons.
*
* @return array
*/
public function listInvalidProperties(): array;
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool
*/
public function valid(): bool;
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool;
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool;
}

View File

@@ -0,0 +1,492 @@
<?php
/**
* NumberPropertiesOnly
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* NumberPropertiesOnly Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class NumberPropertiesOnly implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'NumberPropertiesOnly';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'number' => 'float',
'float' => 'float',
'double' => 'float'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'number' => null,
'float' => 'float',
'double' => 'double'
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'number' => false,
'float' => false,
'double' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'number' => 'number',
'float' => 'float',
'double' => 'double'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'number' => 'setNumber',
'float' => 'setFloat',
'double' => 'setDouble'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'number' => 'getNumber',
'float' => 'getFloat',
'double' => 'getDouble'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('number', $data ?? [], null);
$this->setIfExists('float', $data ?? [], null);
$this->setIfExists('double', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
if (!is_null($this->container['double']) && ($this->container['double'] > 50.2)) {
$invalidProperties[] = "invalid value for 'double', must be smaller than or equal to 50.2.";
}
if (!is_null($this->container['double']) && ($this->container['double'] < 0.8)) {
$invalidProperties[] = "invalid value for 'double', must be bigger than or equal to 0.8.";
}
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets number
*
* @return float|null
*/
public function getNumber(): ?float
{
return $this->container['number'];
}
/**
* Sets number
*
* @param float|null $number number
*
* @return $this
*/
public function setNumber(?float $number): static
{
if (is_null($number)) {
throw new InvalidArgumentException('non-nullable number cannot be null');
}
$this->container['number'] = $number;
return $this;
}
/**
* Gets float
*
* @return float|null
*/
public function getFloat(): ?float
{
return $this->container['float'];
}
/**
* Sets float
*
* @param float|null $float float
*
* @return $this
*/
public function setFloat(?float $float): static
{
if (is_null($float)) {
throw new InvalidArgumentException('non-nullable float cannot be null');
}
$this->container['float'] = $float;
return $this;
}
/**
* Gets double
*
* @return float|null
*/
public function getDouble(): ?float
{
return $this->container['double'];
}
/**
* Sets double
*
* @param float|null $double double
*
* @return $this
*/
public function setDouble(?float $double): static
{
if (is_null($double)) {
throw new InvalidArgumentException('non-nullable double cannot be null');
}
if (($double > 50.2)) {
throw new InvalidArgumentException('invalid value for $double when calling NumberPropertiesOnly., must be smaller than or equal to 50.2.');
}
if (($double < 0.8)) {
throw new InvalidArgumentException('invalid value for $double when calling NumberPropertiesOnly., must be bigger than or equal to 0.8.');
}
$this->container['double'] = $double;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,620 @@
<?php
/**
* Pet
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* Pet Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class Pet implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'Pet';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'id' => 'int',
'name' => 'string',
'category' => '\OpenAPI\Client\Model\Category',
'photo_urls' => 'string[]',
'tags' => '\OpenAPI\Client\Model\Tag[]',
'status' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'id' => 'int64',
'name' => null,
'category' => null,
'photo_urls' => null,
'tags' => null,
'status' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'id' => false,
'name' => false,
'category' => false,
'photo_urls' => false,
'tags' => false,
'status' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'id' => 'id',
'name' => 'name',
'category' => 'category',
'photo_urls' => 'photoUrls',
'tags' => 'tags',
'status' => 'status'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'id' => 'setId',
'name' => 'setName',
'category' => 'setCategory',
'photo_urls' => 'setPhotoUrls',
'tags' => 'setTags',
'status' => 'setStatus'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'id' => 'getId',
'name' => 'getName',
'category' => 'getCategory',
'photo_urls' => 'getPhotoUrls',
'tags' => 'getTags',
'status' => 'getStatus'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
public const STATUS_AVAILABLE = 'available';
public const STATUS_PENDING = 'pending';
public const STATUS_SOLD = 'sold';
/**
* Gets allowable values of the enum
*
* @return string[]
*/
public function getStatusAllowableValues()
{
return [
self::STATUS_AVAILABLE,
self::STATUS_PENDING,
self::STATUS_SOLD,
];
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('id', $data ?? [], null);
$this->setIfExists('name', $data ?? [], null);
$this->setIfExists('category', $data ?? [], null);
$this->setIfExists('photo_urls', $data ?? [], null);
$this->setIfExists('tags', $data ?? [], null);
$this->setIfExists('status', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
if ($this->container['name'] === null) {
$invalidProperties[] = "'name' can't be null";
}
if ($this->container['photo_urls'] === null) {
$invalidProperties[] = "'photo_urls' can't be null";
}
$allowedValues = $this->getStatusAllowableValues();
if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) {
$invalidProperties[] = sprintf(
"invalid value '%s' for 'status', must be one of '%s'",
$this->container['status'],
implode("', '", $allowedValues)
);
}
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets id
*
* @return int|null
*/
public function getId(): ?int
{
return $this->container['id'];
}
/**
* Sets id
*
* @param int|null $id id
*
* @return $this
*/
public function setId(?int $id): static
{
if (is_null($id)) {
throw new InvalidArgumentException('non-nullable id cannot be null');
}
$this->container['id'] = $id;
return $this;
}
/**
* Gets name
*
* @return string
*/
public function getName(): string
{
return $this->container['name'];
}
/**
* Sets name
*
* @param string $name name
*
* @return $this
*/
public function setName(string $name): static
{
if (is_null($name)) {
throw new InvalidArgumentException('non-nullable name cannot be null');
}
$this->container['name'] = $name;
return $this;
}
/**
* Gets category
*
* @return \OpenAPI\Client\Model\Category|null
*/
public function getCategory(): ?\OpenAPI\Client\Model\Category
{
return $this->container['category'];
}
/**
* Sets category
*
* @param \OpenAPI\Client\Model\Category|null $category category
*
* @return $this
*/
public function setCategory(?\OpenAPI\Client\Model\Category $category): static
{
if (is_null($category)) {
throw new InvalidArgumentException('non-nullable category cannot be null');
}
$this->container['category'] = $category;
return $this;
}
/**
* Gets photo_urls
*
* @return string[]
*/
public function getPhotoUrls(): array
{
return $this->container['photo_urls'];
}
/**
* Sets photo_urls
*
* @param string[] $photo_urls photo_urls
*
* @return $this
*/
public function setPhotoUrls(array $photo_urls): static
{
if (is_null($photo_urls)) {
throw new InvalidArgumentException('non-nullable photo_urls cannot be null');
}
$this->container['photo_urls'] = $photo_urls;
return $this;
}
/**
* Gets tags
*
* @return \OpenAPI\Client\Model\Tag[]|null
*/
public function getTags(): ?array
{
return $this->container['tags'];
}
/**
* Sets tags
*
* @param \OpenAPI\Client\Model\Tag[]|null $tags tags
*
* @return $this
*/
public function setTags(?array $tags): static
{
if (is_null($tags)) {
throw new InvalidArgumentException('non-nullable tags cannot be null');
}
$this->container['tags'] = $tags;
return $this;
}
/**
* Gets status
*
* @return string|null
*/
public function getStatus(): ?string
{
return $this->container['status'];
}
/**
* Sets status
*
* @param string|null $status pet status in the store
*
* @return $this
*/
public function setStatus(?string $status): static
{
if (is_null($status)) {
throw new InvalidArgumentException('non-nullable status cannot be null');
}
$allowedValues = $this->getStatusAllowableValues();
if (!in_array($status, $allowedValues, true)) {
throw new InvalidArgumentException(
sprintf(
"Invalid value '%s' for 'status', must be one of '%s'",
$status,
implode("', '", $allowedValues)
)
);
}
$this->container['status'] = $status;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,468 @@
<?php
/**
* Query
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* Query Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class Query implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'Query';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'id' => 'int',
'outcomes' => 'string[]'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'id' => 'int64',
'outcomes' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'id' => false,
'outcomes' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'id' => 'id',
'outcomes' => 'outcomes'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'id' => 'setId',
'outcomes' => 'setOutcomes'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'id' => 'getId',
'outcomes' => 'getOutcomes'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
public const OUTCOMES_SUCCESS = 'SUCCESS';
public const OUTCOMES_FAILURE = 'FAILURE';
public const OUTCOMES_SKIPPED = 'SKIPPED';
/**
* Gets allowable values of the enum
*
* @return string[]
*/
public function getOutcomesAllowableValues()
{
return [
self::OUTCOMES_SUCCESS,
self::OUTCOMES_FAILURE,
self::OUTCOMES_SKIPPED,
];
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('id', $data ?? [], null);
$this->setIfExists('outcomes', $data ?? [], [["SUCCESS","FAILURE"]]);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets id
*
* @return int|null
*/
public function getId(): ?int
{
return $this->container['id'];
}
/**
* Sets id
*
* @param int|null $id Query
*
* @return $this
*/
public function setId(?int $id): static
{
if (is_null($id)) {
throw new InvalidArgumentException('non-nullable id cannot be null');
}
$this->container['id'] = $id;
return $this;
}
/**
* Gets outcomes
*
* @return string[]|null
*/
public function getOutcomes(): ?array
{
return $this->container['outcomes'];
}
/**
* Sets outcomes
*
* @param string[]|null $outcomes outcomes
*
* @return $this
*/
public function setOutcomes(?array $outcomes): static
{
if (is_null($outcomes)) {
throw new InvalidArgumentException('non-nullable outcomes cannot be null');
}
$allowedValues = $this->getOutcomesAllowableValues();
if (array_diff($outcomes, $allowedValues)) {
throw new InvalidArgumentException(
sprintf(
"Invalid value for 'outcomes', must be one of '%s'",
implode("', '", $allowedValues)
)
);
}
$this->container['outcomes'] = $outcomes;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* StringEnumRef
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
/**
* StringEnumRef Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
enum StringEnumRef: string
{
case SUCCESS = 'success';
case FAILURE = 'failure';
case UNCLASSIFIED = 'unclassified';
}

View File

@@ -0,0 +1,442 @@
<?php
/**
* Tag
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* Tag Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class Tag implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'Tag';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'id' => 'int',
'name' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'id' => 'int64',
'name' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'id' => false,
'name' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'id' => 'id',
'name' => 'name'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'id' => 'setId',
'name' => 'setName'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'id' => 'getId',
'name' => 'getName'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('id', $data ?? [], null);
$this->setIfExists('name', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets id
*
* @return int|null
*/
public function getId(): ?int
{
return $this->container['id'];
}
/**
* Sets id
*
* @param int|null $id id
*
* @return $this
*/
public function setId(?int $id): static
{
if (is_null($id)) {
throw new InvalidArgumentException('non-nullable id cannot be null');
}
$this->container['id'] = $id;
return $this;
}
/**
* Gets name
*
* @return string|null
*/
public function getName(): ?string
{
return $this->container['name'];
}
/**
* Sets name
*
* @param string|null $name name
*
* @return $this
*/
public function setName(?string $name): static
{
if (is_null($name)) {
throw new InvalidArgumentException('non-nullable name cannot be null');
}
$this->container['name'] = $name;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,408 @@
<?php
/**
* TestFormObjectMultipartRequestMarker
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* TestFormObjectMultipartRequestMarker Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class TestFormObjectMultipartRequestMarker implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'test_form_object_multipart_request_marker';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'name' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'name' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'name' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'name' => 'name'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'name' => 'setName'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'name' => 'getName'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('name', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets name
*
* @return string|null
*/
public function getName(): ?string
{
return $this->container['name'];
}
/**
* Sets name
*
* @param string|null $name name
*
* @return $this
*/
public function setName(?string $name): static
{
if (is_null($name)) {
throw new InvalidArgumentException('non-nullable name cannot be null');
}
$this->container['name'] = $name;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,510 @@
<?php
/**
* TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'test_query_style_deepObject_explode_true_object_allOf_query_object_parameter';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'size' => 'string',
'color' => 'string',
'id' => 'int',
'name' => 'string'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'size' => null,
'color' => null,
'id' => 'int64',
'name' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'size' => false,
'color' => false,
'id' => false,
'name' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'size' => 'size',
'color' => 'color',
'id' => 'id',
'name' => 'name'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'size' => 'setSize',
'color' => 'setColor',
'id' => 'setId',
'name' => 'setName'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'size' => 'getSize',
'color' => 'getColor',
'id' => 'getId',
'name' => 'getName'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('size', $data ?? [], null);
$this->setIfExists('color', $data ?? [], null);
$this->setIfExists('id', $data ?? [], null);
$this->setIfExists('name', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets size
*
* @return string|null
*/
public function getSize(): ?string
{
return $this->container['size'];
}
/**
* Sets size
*
* @param string|null $size size
*
* @return $this
*/
public function setSize(?string $size): static
{
if (is_null($size)) {
throw new InvalidArgumentException('non-nullable size cannot be null');
}
$this->container['size'] = $size;
return $this;
}
/**
* Gets color
*
* @return string|null
*/
public function getColor(): ?string
{
return $this->container['color'];
}
/**
* Sets color
*
* @param string|null $color color
*
* @return $this
*/
public function setColor(?string $color): static
{
if (is_null($color)) {
throw new InvalidArgumentException('non-nullable color cannot be null');
}
$this->container['color'] = $color;
return $this;
}
/**
* Gets id
*
* @return int|null
*/
public function getId(): ?int
{
return $this->container['id'];
}
/**
* Sets id
*
* @param int|null $id id
*
* @return $this
*/
public function setId(?int $id): static
{
if (is_null($id)) {
throw new InvalidArgumentException('non-nullable id cannot be null');
}
$this->container['id'] = $id;
return $this;
}
/**
* Gets name
*
* @return string|null
*/
public function getName(): ?string
{
return $this->container['name'];
}
/**
* Sets name
*
* @param string|null $name name
*
* @return $this
*/
public function setName(?string $name): static
{
if (is_null($name)) {
throw new InvalidArgumentException('non-nullable name cannot be null');
}
$this->container['name'] = $name;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,408 @@
<?php
/**
* TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client\Model;
use ArrayAccess;
use JsonSerializable;
use InvalidArgumentException;
use ReturnTypeWillChange;
use OpenAPI\Client\ObjectSerializer;
/**
* TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
* @implements ArrayAccess<string, mixed>
*/
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter implements ModelInterface, ArrayAccess, JsonSerializable
{
public const DISCRIMINATOR = null;
/**
* The original name of the model.
*
* @var string
*/
protected static string $openAPIModelName = 'test_query_style_form_explode_true_array_string_query_object_parameter';
/**
* Array of property to type mappings. Used for (de)serialization
*
* @var array<string, string>
*/
protected static array $openAPITypes = [
'values' => 'string[]'
];
/**
* Array of property to format mappings. Used for (de)serialization
*
* @var array<string, string|null>
*/
protected static array $openAPIFormats = [
'values' => null
];
/**
* Array of nullable properties. Used for (de)serialization
*
* @var array<string, bool>
*/
protected static array $openAPINullables = [
'values' => false
];
/**
* If a nullable field gets set to null, insert it here
*
* @var array<string, bool>
*/
protected array $openAPINullablesSetToNull = [];
/**
* Array of property to type mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPITypes(): array
{
return self::$openAPITypes;
}
/**
* Array of property to format mappings. Used for (de)serialization
*
* @return array<string, string>
*/
public static function openAPIFormats(): array
{
return self::$openAPIFormats;
}
/**
* Array of nullable properties
*
* @return array<string, bool>
*/
protected static function openAPINullables(): array
{
return self::$openAPINullables;
}
/**
* Array of nullable field names deliberately set to null
*
* @return array<string, bool>
*/
private function getOpenAPINullablesSetToNull(): array
{
return $this->openAPINullablesSetToNull;
}
/**
* Setter - Array of nullable field names deliberately set to null
*
* @param array<string, bool> $openAPINullablesSetToNull
*/
private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void
{
$this->openAPINullablesSetToNull = $openAPINullablesSetToNull;
}
/**
* Checks if a property is nullable
*
* @param string $property
* @return bool
*/
public static function isNullable(string $property): bool
{
return self::openAPINullables()[$property] ?? false;
}
/**
* Checks if a nullable property is set to null.
*
* @param string $property
* @return bool
*/
public function isNullableSetToNull(string $property): bool
{
return in_array($property, $this->getOpenAPINullablesSetToNull(), true);
}
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @var array<string, string>
*/
protected static array $attributeMap = [
'values' => 'values'
];
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @var array<string, string>
*/
protected static array $setters = [
'values' => 'setValues'
];
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @var array<string, string>
*/
protected static array $getters = [
'values' => 'getValues'
];
/**
* Array of attributes where the key is the local name,
* and the value is the original name
*
* @return array<string, string>
*/
public static function attributeMap(): array
{
return self::$attributeMap;
}
/**
* Array of attributes to setter functions (for deserialization of responses)
*
* @return array<string, string>
*/
public static function setters(): array
{
return self::$setters;
}
/**
* Array of attributes to getter functions (for serialization of requests)
*
* @return array<string, string>
*/
public static function getters(): array
{
return self::$getters;
}
/**
* The original name of the model.
*
* @return string
*/
public function getModelName(): string
{
return self::$openAPIModelName;
}
/**
* Associative array for storing property values
*
* @var array
*/
protected array $container = [];
/**
* Constructor
*
* @param array $data Associated array of property values initializing the model
*/
public function __construct(array $data = null)
{
$this->setIfExists('values', $data ?? [], null);
}
/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, mixed $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
$this->openAPINullablesSetToNull[] = $variableName;
}
$this->container[$variableName] = $fields[$variableName] ?? $defaultValue;
}
/**
* Show all the invalid properties with reasons.
*
* @return string[] invalid properties with reasons
*/
public function listInvalidProperties(): array
{
$invalidProperties = [];
return $invalidProperties;
}
/**
* Validate all the properties in the model
* return true if all passed
*
* @return bool True if all properties are valid
*/
public function valid(): bool
{
return count($this->listInvalidProperties()) === 0;
}
/**
* Gets values
*
* @return string[]|null
*/
public function getValues(): ?array
{
return $this->container['values'];
}
/**
* Sets values
*
* @param string[]|null $values values
*
* @return $this
*/
public function setValues(?array $values): static
{
if (is_null($values)) {
throw new InvalidArgumentException('non-nullable values cannot be null');
}
$this->container['values'] = $values;
return $this;
}
/**
* Returns true if offset exists. False otherwise.
*
* @param integer $offset Offset
*
* @return boolean
*/
public function offsetExists(mixed $offset): bool
{
return isset($this->container[$offset]);
}
/**
* Gets offset.
*
* @param integer $offset Offset
*
* @return mixed|null
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset): mixed
{
return $this->container[$offset] ?? null;
}
/**
* Sets value based on offset.
*
* @param int|null $offset Offset
* @param mixed $value Value to be set
*
* @return void
*/
public function offsetSet(mixed $offset, mixed $value): void
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
/**
* Unsets offset.
*
* @param integer $offset Offset
*
* @return void
*/
public function offsetUnset(mixed $offset): void
{
unset($this->container[$offset]);
}
/**
* Serializes the object to a value that can be serialized natively by json_encode().
* @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php
*
* @return mixed Returns data which can be serialized by json_encode(), which is a value
* of any type other than a resource.
*/
#[ReturnTypeWillChange]
public function jsonSerialize(): mixed
{
return ObjectSerializer::sanitizeForSerialization($this);
}
/**
* Gets the string presentation of the object
*
* @return string
*/
public function __toString(): string
{
return json_encode(
ObjectSerializer::sanitizeForSerialization($this),
JSON_PRETTY_PRINT
);
}
/**
* Gets a header-safe presentation of the object
*
* @return string
*/
public function toHeaderValue(): string
{
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
}
}

View File

@@ -0,0 +1,603 @@
<?php
/**
* ObjectSerializer
*
* PHP version 8.1
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Echo Server API
*
* Echo Server API
*
* The version of the OpenAPI document: 0.1.0
* Contact: team@openapitools.org
* @generated Generated by: https://openapi-generator.tech
* Generator version: 7.8.0-SNAPSHOT
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace OpenAPI\Client;
use DateTimeInterface;
use DateTime;
use GuzzleHttp\Psr7\Utils;
use OpenAPI\Client\Model\ModelInterface;
/**
* ObjectSerializer Class Doc Comment
*
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class ObjectSerializer
{
/** @var string */
private static string $dateTimeFormat = DateTimeInterface::ATOM;
/**
* Change the date format
*
* @param string $format the new date format to use
*
* @return void
*/
public static function setDateTimeFormat(string $format): void
{
self::$dateTimeFormat = $format;
}
/**
* Serialize data
*
* @param mixed $data the data to serialize
* @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
*/
public static function sanitizeForSerialization(mixed $data, string $type = null, string $format = null): mixed
{
if (is_scalar($data) || null === $data) {
return $data;
}
if ($data instanceof DateTime) {
return ($format === 'date') ? $data->format('Y-m-d') : $data->format(self::$dateTimeFormat);
}
if ($data instanceof \BackedEnum) {
return $data->value;
}
if (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = self::sanitizeForSerialization($value);
}
return $data;
}
if (is_object($data)) {
$values = [];
if ($data instanceof ModelInterface) {
$formats = $data::openAPIFormats();
foreach ($data::openAPITypes() as $property => $openAPIType) {
$getter = $data::getters()[$property];
$value = $data->$getter();
if ($value !== null && !in_array($openAPIType, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
if (is_subclass_of($openAPIType, '\BackedEnum')) {
if (is_scalar($value)) {
$value = $openAPIType::tryFrom($value);
if ($value === null) {
$imploded = implode("', '", array_map(fn($case) => $case->value, $openAPIType::cases()));
throw new \InvalidArgumentException(
sprintf(
"Invalid value for enum '%s', must be one of: '%s'",
$openAPIType::class,
$imploded
)
);
}
}
}
}
if (($data::isNullable($property) && $data->isNullableSetToNull($property)) || $value !== null) {
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);
}
}
} else {
foreach($data as $property => $value) {
$values[$property] = self::sanitizeForSerialization($value);
}
}
return (object)$values;
} else {
return (string)$data;
}
}
/**
* Sanitize filename by removing path.
* e.g. ../../sun.gif becomes sun.gif
*
* @param string $filename filename to be sanitized
*
* @return string the sanitized filename
*/
public static function sanitizeFilename(string $filename): string
{
if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) {
return $match[1];
} else {
return $filename;
}
}
/**
* Shorter timestamp microseconds to 6 digits length.
*
* @param string $timestamp Original timestamp
*
* @return string the shorten timestamp
*/
public static function sanitizeTimestamp(string $timestamp): string
{
return preg_replace('/(:\d{2}.\d{6})\d*/', '$1', $timestamp);
}
/**
* Take value and turn it into a string suitable for inclusion in
* the path, by url-encoding.
*
* @param string $value a string which will be part of the path
*
* @return string the serialized object
*/
public static function toPathValue(string $value): string
{
return rawurlencode(self::toString($value));
}
/**
* Checks if a value is empty, based on its OpenAPI type.
*
* @param mixed $value
* @param string $openApiType
*
* @return bool true if $value is empty
*/
private static function isEmptyValue(mixed $value, string $openApiType): bool
{
# If empty() returns false, it is not empty regardless of its type.
if (!empty($value)) {
return false;
}
# Null is always empty, as we cannot send a real "null" value in a query parameter.
if ($value === null) {
return true;
}
return match ($openApiType) {
# For numeric values, false and '' are considered empty.
# This comparison is safe for floating point values, since the previous call to empty() will
# filter out values that don't match 0.
'int','integer' => $value !== 0,
'number'|'float' => $value !== 0 && $value !== 0.0,
# For boolean values, '' is considered empty
'bool','boolean' => !in_array($value, [false, 0], true),
# For all the other types, any value at this point can be considered empty.
default => true
};
}
/**
* Take query parameter properties and turn it into an array suitable for
* native http_build_query or GuzzleHttp\Psr7\Query::build.
*
* @param mixed $value Parameter value
* @param string $paramName Parameter name
* @param string $openApiType OpenAPIType e.g. array or object
* @param string $style Parameter serialization style
* @param bool $explode Parameter explode option
* @param bool $required Whether query param is required or not
*
* @return array
*/
public static function toQueryValue(
mixed $value,
string $paramName,
string $openApiType = 'string',
string $style = 'form',
bool $explode = true,
bool $required = true
): array {
# Check if we should omit this parameter from the query. This should only happen when:
# - Parameter is NOT required; AND
# - its value is set to a value that is equivalent to "empty", depending on its OpenAPI type. For
# example, 0 as "int" or "boolean" is NOT an empty value.
if (self::isEmptyValue($value, $openApiType)) {
if ($required) {
return ["{$paramName}" => ''];
} else {
return [];
}
}
# Handle DateTime objects in query
if($openApiType === "\DateTime" && $value instanceof DateTime) {
return ["{$paramName}" => $value->format(self::$dateTimeFormat)];
}
$query = [];
$value = (in_array($openApiType, ['object', 'array'], true)) ? (array)$value : $value;
// since \GuzzleHttp\Psr7\Query::build fails with nested arrays
// need to flatten array first
$flattenArray = function ($arr, $name, &$result = []) use (&$flattenArray, $style, $explode) {
if (!is_array($arr)) return $arr;
foreach ($arr as $k => $v) {
$prop = ($style === 'deepObject') ? "{$name}[{$k}]" : $k;
if (is_array($v)) {
$flattenArray($v, $prop, $result);
} else {
if ($style !== 'deepObject' && !$explode) {
// push key itself
$result[] = $prop;
}
$result[$prop] = $v;
}
}
return $result;
};
$value = $flattenArray($value, $paramName);
if ($openApiType === 'object' && ($style === 'deepObject' || $explode)) {
return $value;
}
if ('boolean' === $openApiType && is_bool($value)) {
$value = self::convertBoolToQueryStringFormat($value);
}
// handle style in serializeCollection
$query[$paramName] = ($explode) ? $value : self::serializeCollection((array)$value, $style);
return $query;
}
/**
* Convert boolean value to format for query string.
*
* @param bool $value Boolean value
*
* @return int|string Boolean value in format
*/
public static function convertBoolToQueryStringFormat(bool $value): int|string
{
if (Configuration::BOOLEAN_FORMAT_STRING == Configuration::getDefaultConfiguration()->getBooleanFormatForQueryString()) {
return $value ? 'true' : 'false';
}
return (int) $value;
}
/**
* Take value and turn it into a string suitable for inclusion in
* the header. If it's a string, pass through unchanged
* If it's a datetime object, format it in ISO8601
*
* @param string $value a string which will be part of the header
*
* @return string the header string
*/
public static function toHeaderValue(string $value): string
{
$callable = [$value, 'toHeaderValue'];
if (is_callable($callable)) {
return $callable();
}
return self::toString($value);
}
/**
* Take value and turn it into a string suitable for inclusion in
* the http body (form parameter). If it's a string, pass through unchanged
* If it's a datetime object, format it in ISO8601
*
* @param string|\SplFileObject $value the value of the form parameter
*
* @return string the form string
*/
public static function toFormValue(string|\SplFileObject $value): string
{
if ($value instanceof \SplFileObject) {
return $value->getRealPath();
} else {
return self::toString($value);
}
}
/**
* Take value and turn it into a string suitable for inclusion in
* the parameter. If it's a string, pass through unchanged
* 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
*
* @return string the header string
*/
public static function toString(string|bool|DateTime $value): string
{
if ($value instanceof DateTime) { // datetime in ISO8601 format
return $value->format(self::$dateTimeFormat);
} elseif (is_bool($value)) {
return $value ? 'true' : 'false';
} else {
return (string) $value;
}
}
/**
* Serialize an array to a string.
*
* @param array $collection collection to serialize to a string
* @param string $style the format use for serialization (csv,
* ssv, tsv, pipes, multi)
* @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array
*
* @return string
*/
public static function serializeCollection(array $collection, string $style, bool $allowCollectionFormatMulti = false): string
{
if ($allowCollectionFormatMulti && ('multi' === $style)) {
// http_build_query() almost does the job for us. We just
// need to fix the result of multidimensional arrays.
return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&'));
}
return match ($style) {
'pipeDelimited', 'pipes' => implode('|', $collection),
'tsv' => implode("\t", $collection),
'spaceDelimited', 'ssv' => implode(' ', $collection),
default => implode(',', $collection),
};
}
/**
* Deserialize a JSON string into an object
*
* @param mixed $data object or primitive to be deserialized
* @param string $class class name is passed as a string
* @param string[]|null $httpHeaders HTTP headers
*
* @return mixed a single or an array of $class instances
*/
public static function deserialize(mixed $data, string $class, array $httpHeaders = null): mixed
{
if (null === $data) {
return null;
}
if (strcasecmp(substr($class, -2), '[]') === 0) {
$data = is_string($data) ? json_decode($data) : $data;
if (!is_array($data)) {
throw new \InvalidArgumentException("Invalid array '$class'");
}
$subClass = substr($class, 0, -2);
$values = [];
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass, null);
}
return $values;
}
if (preg_match('/^(array<|map\[)/', $class)) { // for associative array e.g. array<string,int>
$data = is_string($data) ? json_decode($data) : $data;
settype($data, 'array');
$inner = substr($class, 4, -1);
$deserialized = [];
if (strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass, null);
}
}
return $deserialized;
}
if ($class === 'mixed') {
settype($data, gettype($data));
return $data;
}
if ($class === '\DateTime') {
// Some APIs return an invalid, empty string as a
// date-time property. DateTime::__construct() will return
// the current time for empty input which is probably not
// what is meant. The invalid empty string is probably to
// be interpreted as a missing field/value. Let's handle
// this graceful.
if (!empty($data)) {
try {
return new DateTime($data);
} catch (\Exception $exception) {
// Some APIs return a date-time with too high nanosecond
// precision for php's DateTime to handle.
// With provided regexp 6 digits of microseconds saved
return new DateTime(self::sanitizeTimestamp($data));
}
} else {
return null;
}
}
if ($class === '\Psr\Http\Message\StreamInterface') {
return Utils::streamFor($data);
}
if ($class === '\SplFileObject') {
$data = Utils::streamFor($data);
/** @var \Psr\Http\Message\StreamInterface $data */
// determine file name
if (
is_array($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]);
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
$file = fopen($filename, 'w');
while ($chunk = $data->read(200)) {
fwrite($file, $chunk);
}
fclose($file);
return new \SplFileObject($filename, 'r');
}
/** @psalm-suppress ParadoxicalCondition */
// handle primitive types
if (in_array($class, ['\DateTime', '\SplFileObject'], true)) {
return $data;
} elseif (in_array($class, ['array', 'bool', 'boolean', 'float', 'double', 'int', 'integer', 'object', 'string', 'null'], true)) {
// type ref: https://www.php.net/manual/en/function.settype.php
// byte, mixed, void in the old php client were removed
settype($data, $class);
return $data;
}
if (is_subclass_of($class, '\BackedEnum')) {
$data = $class::tryFrom($data);
if ($data === null) {
$imploded = implode("', '", array_map(fn($case) => $case->value, $class::cases()));
throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'");
}
return $data;
} else {
$data = is_string($data) ? json_decode($data) : $data;
if (is_array($data)) {
$data = (object)$data;
}
// If a discriminator is defined and points to a valid subclass, use it.
$discriminator = $class::DISCRIMINATOR;
if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
$subclass = '\OpenAPI\Client\Model\\' . $data->{$discriminator};
if (is_subclass_of($subclass, $class)) {
$class = $subclass;
}
}
/** @var ModelInterface $instance */
$instance = new $class();
foreach ($instance::openAPITypes() as $property => $type) {
$propertySetter = $instance::setters()[$property];
if (!isset($propertySetter)) {
continue;
}
if (!isset($data->{$instance::attributeMap()[$property]})) {
if ($instance::isNullable($property)) {
$instance->$propertySetter(null);
}
continue;
}
if (isset($data->{$instance::attributeMap()[$property]})) {
$propertyValue = $data->{$instance::attributeMap()[$property]};
$instance->$propertySetter(self::deserialize($propertyValue, $type, null));
}
}
return $instance;
}
}
/**
* 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).
*
* @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) : '';
}
}