Better tests for php-nextgen (#16569)

* better tests for php nextgen

* add new files
This commit is contained in:
William Cheng
2023-09-13 10:50:29 +08:00
committed by GitHub
parent 781ccae722
commit 4260c7aaf0
70 changed files with 18854 additions and 1 deletions

View File

@@ -0,0 +1,411 @@
<?php
/**
* AuthApi
* PHP version 8.1
*
* @category Class
* @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
* OpenAPI Generator version: 7.0.1-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 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 OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;
/**
* AuthApi Class Doc Comment
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class AuthApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'testAuthHttpBasic' => [
'application/json',
],
];
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $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,
$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($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig()
{
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 \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return string
*/
public function testAuthHttpBasic(string $contentType = self::contentTypes['testAuthHttpBasic'][0])
{
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 \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testAuthHttpBasicWithHttpInfo(string $contentType = self::contentTypes['testAuthHttpBasic'][0])
{
$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 ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if ($returnType === '\SplFileObject') {
$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()
];
} 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 \GuzzleHttp\Promise\PromiseInterface
*/
public function testAuthHttpBasicAsync(string $contentType = self::contentTypes['testAuthHttpBasic'][0])
{
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 \GuzzleHttp\Promise\PromiseInterface
*/
public function testAuthHttpBasicAsyncWithHttpInfo(string $contentType = self::contentTypes['testAuthHttpBasic'][0])
{
$returnType = 'string';
$request = $this->testAuthHttpBasicRequest($contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$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])
{
$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
);
}
/**
* Create http client option
*
* @throws \RuntimeException on file opening failure
* @return array of http client options
*/
protected function createHttpClientOption()
{
$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,763 @@
<?php
/**
* FormApi
* PHP version 8.1
*
* @category Class
* @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
* OpenAPI Generator version: 7.0.1-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 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 OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;
/**
* FormApi Class Doc Comment
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class FormApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'testFormIntegerBooleanString' => [
'application/x-www-form-urlencoded',
],
'testFormOneof' => [
'application/x-www-form-urlencoded',
],
];
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $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,
$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($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* Operation testFormIntegerBooleanString
*
* Test form parameter(s)
*
* @param int $integer_form integer_form (optional)
* @param bool $boolean_form boolean_form (optional)
* @param string $string_form string_form (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormIntegerBooleanString'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return string
*/
public function testFormIntegerBooleanString($integer_form = null, $boolean_form = null, $string_form = null, string $contentType = self::contentTypes['testFormIntegerBooleanString'][0])
{
list($response) = $this->testFormIntegerBooleanStringWithHttpInfo($integer_form, $boolean_form, $string_form, $contentType);
return $response;
}
/**
* Operation testFormIntegerBooleanStringWithHttpInfo
*
* Test form parameter(s)
*
* @param int $integer_form (optional)
* @param bool $boolean_form (optional)
* @param string $string_form (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormIntegerBooleanString'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testFormIntegerBooleanStringWithHttpInfo($integer_form = null, $boolean_form = null, $string_form = null, string $contentType = self::contentTypes['testFormIntegerBooleanString'][0])
{
$request = $this->testFormIntegerBooleanStringRequest($integer_form, $boolean_form, $string_form, $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 ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if ($returnType === '\SplFileObject') {
$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()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testFormIntegerBooleanStringAsync
*
* Test form parameter(s)
*
* @param int $integer_form (optional)
* @param bool $boolean_form (optional)
* @param string $string_form (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormIntegerBooleanString'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testFormIntegerBooleanStringAsync($integer_form = null, $boolean_form = null, $string_form = null, string $contentType = self::contentTypes['testFormIntegerBooleanString'][0])
{
return $this->testFormIntegerBooleanStringAsyncWithHttpInfo($integer_form, $boolean_form, $string_form, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testFormIntegerBooleanStringAsyncWithHttpInfo
*
* Test form parameter(s)
*
* @param int $integer_form (optional)
* @param bool $boolean_form (optional)
* @param string $string_form (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormIntegerBooleanString'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testFormIntegerBooleanStringAsyncWithHttpInfo($integer_form = null, $boolean_form = null, $string_form = null, string $contentType = self::contentTypes['testFormIntegerBooleanString'][0])
{
$returnType = 'string';
$request = $this->testFormIntegerBooleanStringRequest($integer_form, $boolean_form, $string_form, $contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$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 'testFormIntegerBooleanString'
*
* @param int $integer_form (optional)
* @param bool $boolean_form (optional)
* @param string $string_form (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormIntegerBooleanString'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testFormIntegerBooleanStringRequest($integer_form = null, $boolean_form = null, $string_form = null, string $contentType = self::contentTypes['testFormIntegerBooleanString'][0])
{
$resourcePath = '/form/integer/boolean/string';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// form params
if ($integer_form !== null) {
$formParams['integer_form'] = ObjectSerializer::toFormValue($integer_form);
}
// form params
if ($boolean_form !== null) {
$formParams['boolean_form'] = ObjectSerializer::toFormValue($boolean_form);
}
// form params
if ($string_form !== null) {
$formParams['string_form'] = ObjectSerializer::toFormValue($string_form);
}
$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(
'POST',
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
$headers,
$httpBody
);
}
/**
* Operation testFormOneof
*
* Test form parameter(s) for oneOf schema
*
* @param string $form1 form1 (optional)
* @param int $form2 form2 (optional)
* @param string $form3 form3 (optional)
* @param bool $form4 form4 (optional)
* @param int $id id (optional)
* @param string $name name (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormOneof'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return string
*/
public function testFormOneof($form1 = null, $form2 = null, $form3 = null, $form4 = null, $id = null, $name = null, string $contentType = self::contentTypes['testFormOneof'][0])
{
list($response) = $this->testFormOneofWithHttpInfo($form1, $form2, $form3, $form4, $id, $name, $contentType);
return $response;
}
/**
* Operation testFormOneofWithHttpInfo
*
* Test form parameter(s) for oneOf schema
*
* @param string $form1 (optional)
* @param int $form2 (optional)
* @param string $form3 (optional)
* @param bool $form4 (optional)
* @param int $id (optional)
* @param string $name (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormOneof'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testFormOneofWithHttpInfo($form1 = null, $form2 = null, $form3 = null, $form4 = null, $id = null, $name = null, string $contentType = self::contentTypes['testFormOneof'][0])
{
$request = $this->testFormOneofRequest($form1, $form2, $form3, $form4, $id, $name, $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 ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if ($returnType === '\SplFileObject') {
$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()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testFormOneofAsync
*
* Test form parameter(s) for oneOf schema
*
* @param string $form1 (optional)
* @param int $form2 (optional)
* @param string $form3 (optional)
* @param bool $form4 (optional)
* @param int $id (optional)
* @param string $name (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormOneof'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testFormOneofAsync($form1 = null, $form2 = null, $form3 = null, $form4 = null, $id = null, $name = null, string $contentType = self::contentTypes['testFormOneof'][0])
{
return $this->testFormOneofAsyncWithHttpInfo($form1, $form2, $form3, $form4, $id, $name, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testFormOneofAsyncWithHttpInfo
*
* Test form parameter(s) for oneOf schema
*
* @param string $form1 (optional)
* @param int $form2 (optional)
* @param string $form3 (optional)
* @param bool $form4 (optional)
* @param int $id (optional)
* @param string $name (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormOneof'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testFormOneofAsyncWithHttpInfo($form1 = null, $form2 = null, $form3 = null, $form4 = null, $id = null, $name = null, string $contentType = self::contentTypes['testFormOneof'][0])
{
$returnType = 'string';
$request = $this->testFormOneofRequest($form1, $form2, $form3, $form4, $id, $name, $contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$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 'testFormOneof'
*
* @param string $form1 (optional)
* @param int $form2 (optional)
* @param string $form3 (optional)
* @param bool $form4 (optional)
* @param int $id (optional)
* @param string $name (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testFormOneof'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testFormOneofRequest($form1 = null, $form2 = null, $form3 = null, $form4 = null, $id = null, $name = null, string $contentType = self::contentTypes['testFormOneof'][0])
{
$resourcePath = '/form/oneof';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// form params
if ($form1 !== null) {
$formParams['form1'] = ObjectSerializer::toFormValue($form1);
}
// form params
if ($form2 !== null) {
$formParams['form2'] = ObjectSerializer::toFormValue($form2);
}
// form params
if ($form3 !== null) {
$formParams['form3'] = ObjectSerializer::toFormValue($form3);
}
// form params
if ($form4 !== null) {
$formParams['form4'] = ObjectSerializer::toFormValue($form4);
}
// form params
if ($id !== null) {
$formParams['id'] = ObjectSerializer::toFormValue($id);
}
// form params
if ($name !== null) {
$formParams['name'] = ObjectSerializer::toFormValue($name);
}
$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(
'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()
{
$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,437 @@
<?php
/**
* HeaderApi
* PHP version 8.1
*
* @category Class
* @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
* OpenAPI Generator version: 7.0.1-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 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 OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;
/**
* HeaderApi Class Doc Comment
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class HeaderApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'testHeaderIntegerBooleanString' => [
'application/json',
],
];
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $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,
$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($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* Operation testHeaderIntegerBooleanString
*
* Test header parameter(s)
*
* @param int $integer_header integer_header (optional)
* @param bool $boolean_header boolean_header (optional)
* @param string $string_header string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanString'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return string
*/
public function testHeaderIntegerBooleanString($integer_header = null, $boolean_header = null, $string_header = null, string $contentType = self::contentTypes['testHeaderIntegerBooleanString'][0])
{
list($response) = $this->testHeaderIntegerBooleanStringWithHttpInfo($integer_header, $boolean_header, $string_header, $contentType);
return $response;
}
/**
* Operation testHeaderIntegerBooleanStringWithHttpInfo
*
* Test header parameter(s)
*
* @param int $integer_header (optional)
* @param bool $boolean_header (optional)
* @param string $string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanString'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testHeaderIntegerBooleanStringWithHttpInfo($integer_header = null, $boolean_header = null, $string_header = null, string $contentType = self::contentTypes['testHeaderIntegerBooleanString'][0])
{
$request = $this->testHeaderIntegerBooleanStringRequest($integer_header, $boolean_header, $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 ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if ($returnType === '\SplFileObject') {
$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()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testHeaderIntegerBooleanStringAsync
*
* Test header parameter(s)
*
* @param int $integer_header (optional)
* @param bool $boolean_header (optional)
* @param string $string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanString'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testHeaderIntegerBooleanStringAsync($integer_header = null, $boolean_header = null, $string_header = null, string $contentType = self::contentTypes['testHeaderIntegerBooleanString'][0])
{
return $this->testHeaderIntegerBooleanStringAsyncWithHttpInfo($integer_header, $boolean_header, $string_header, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testHeaderIntegerBooleanStringAsyncWithHttpInfo
*
* Test header parameter(s)
*
* @param int $integer_header (optional)
* @param bool $boolean_header (optional)
* @param string $string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanString'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testHeaderIntegerBooleanStringAsyncWithHttpInfo($integer_header = null, $boolean_header = null, $string_header = null, string $contentType = self::contentTypes['testHeaderIntegerBooleanString'][0])
{
$returnType = 'string';
$request = $this->testHeaderIntegerBooleanStringRequest($integer_header, $boolean_header, $string_header, $contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$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 'testHeaderIntegerBooleanString'
*
* @param int $integer_header (optional)
* @param bool $boolean_header (optional)
* @param string $string_header (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanString'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testHeaderIntegerBooleanStringRequest($integer_header = null, $boolean_header = null, $string_header = null, string $contentType = self::contentTypes['testHeaderIntegerBooleanString'][0])
{
$resourcePath = '/header/integer/boolean/string';
$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);
}
$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()
{
$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,447 @@
<?php
/**
* PathApi
* PHP version 8.1
*
* @category Class
* @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
* OpenAPI Generator version: 7.0.1-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 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 OpenAPI\Client\ApiException;
use OpenAPI\Client\Configuration;
use OpenAPI\Client\HeaderSelector;
use OpenAPI\Client\ObjectSerializer;
/**
* PathApi Class Doc Comment
*
* @category Class
* @package OpenAPI\Client
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class PathApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'testsPathStringPathStringIntegerPathInteger' => [
'application/json',
],
];
/**
* @param ClientInterface $client
* @param Configuration $config
* @param HeaderSelector $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,
$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($hostIndex): void
{
$this->hostIndex = $hostIndex;
}
/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}
/**
* @return Configuration
*/
public function getConfig()
{
return $this->config;
}
/**
* Operation testsPathStringPathStringIntegerPathInteger
*
* Test path parameter(s)
*
* @param string $path_string path_string (required)
* @param int $path_integer path_integer (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathInteger'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return string
*/
public function testsPathStringPathStringIntegerPathInteger($path_string, $path_integer, string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathInteger'][0])
{
list($response) = $this->testsPathStringPathStringIntegerPathIntegerWithHttpInfo($path_string, $path_integer, $contentType);
return $response;
}
/**
* Operation testsPathStringPathStringIntegerPathIntegerWithHttpInfo
*
* Test path parameter(s)
*
* @param string $path_string (required)
* @param int $path_integer (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathInteger'] to see the possible values for this operation
*
* @throws \OpenAPI\Client\ApiException on non-2xx response
* @throws \InvalidArgumentException
* @return array of string, HTTP status code, HTTP response headers (array of strings)
*/
public function testsPathStringPathStringIntegerPathIntegerWithHttpInfo($path_string, $path_integer, string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathInteger'][0])
{
$request = $this->testsPathStringPathStringIntegerPathIntegerRequest($path_string, $path_integer, $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 ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = 'string';
if ($returnType === '\SplFileObject') {
$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()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* Operation testsPathStringPathStringIntegerPathIntegerAsync
*
* Test path parameter(s)
*
* @param string $path_string (required)
* @param int $path_integer (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathInteger'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testsPathStringPathStringIntegerPathIntegerAsync($path_string, $path_integer, string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathInteger'][0])
{
return $this->testsPathStringPathStringIntegerPathIntegerAsyncWithHttpInfo($path_string, $path_integer, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testsPathStringPathStringIntegerPathIntegerAsyncWithHttpInfo
*
* Test path parameter(s)
*
* @param string $path_string (required)
* @param int $path_integer (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathInteger'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function testsPathStringPathStringIntegerPathIntegerAsyncWithHttpInfo($path_string, $path_integer, string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathInteger'][0])
{
$returnType = 'string';
$request = $this->testsPathStringPathStringIntegerPathIntegerRequest($path_string, $path_integer, $contentType);
return $this->client
->sendAsync($request, $this->createHttpClientOption())
->then(
function ($response) use ($returnType) {
if ($returnType === '\SplFileObject') {
$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 'testsPathStringPathStringIntegerPathInteger'
*
* @param string $path_string (required)
* @param int $path_integer (required)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathInteger'] to see the possible values for this operation
*
* @throws \InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testsPathStringPathStringIntegerPathIntegerRequest($path_string, $path_integer, string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathInteger'][0])
{
// 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 testsPathStringPathStringIntegerPathInteger'
);
}
// 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 testsPathStringPathStringIntegerPathInteger'
);
}
$resourcePath = '/path/string/{path_string}/integer/{path_integer}';
$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
);
}
$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()
{
$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