[Java RESTEasy client] updating test to use the Java RESTEasy echo api client (#17367) (#17470)

* updating test to use the Java RESTEasy echo api client (#17367)

* regenerated samples

* set source and target to 1.8 to fix workflow failure, adapted parser
This commit is contained in:
Milad
2023-12-26 02:32:51 +01:00
committed by GitHub
parent a67e07e132
commit 8c014372aa
275 changed files with 9144 additions and 19842 deletions

View File

@@ -81,6 +81,9 @@ class BodyApi
'testBodyMultipartFormdataArrayOfBinary' => [
'multipart/form-data',
],
'testBodyMultipartFormdataSingleBinary' => [
'multipart/form-data',
],
'testEchoBodyAllOfPet' => [
'application/json',
],
@@ -1082,6 +1085,326 @@ class BodyApi
);
}
/**
* Operation testBodyMultipartFormdataSingleBinary
*
* Test single binary in multipart mime
*
* @param \SplFileObject|null $my_file my_file (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyMultipartFormdataSingleBinary'] 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 testBodyMultipartFormdataSingleBinary(
?\SplFileObject $my_file = null,
string $contentType = self::contentTypes['testBodyMultipartFormdataSingleBinary'][0]
): string
{
list($response) = $this->testBodyMultipartFormdataSingleBinaryWithHttpInfo($my_file, $contentType);
return $response;
}
/**
* Operation testBodyMultipartFormdataSingleBinaryWithHttpInfo
*
* Test single binary in multipart mime
*
* @param \SplFileObject|null $my_file (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyMultipartFormdataSingleBinary'] 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 testBodyMultipartFormdataSingleBinaryWithHttpInfo(
?\SplFileObject $my_file = null,
string $contentType = self::contentTypes['testBodyMultipartFormdataSingleBinary'][0]
): array
{
$request = $this->testBodyMultipartFormdataSingleBinaryRequest($my_file, $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') {
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 ($returnType === '\SplFileObject') {
$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 testBodyMultipartFormdataSingleBinaryAsync
*
* Test single binary in multipart mime
*
* @param \SplFileObject|null $my_file (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyMultipartFormdataSingleBinary'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testBodyMultipartFormdataSingleBinaryAsync(
?\SplFileObject $my_file = null,
string $contentType = self::contentTypes['testBodyMultipartFormdataSingleBinary'][0]
): PromiseInterface
{
return $this->testBodyMultipartFormdataSingleBinaryAsyncWithHttpInfo($my_file, $contentType)
->then(
function ($response) {
return $response[0];
}
);
}
/**
* Operation testBodyMultipartFormdataSingleBinaryAsyncWithHttpInfo
*
* Test single binary in multipart mime
*
* @param \SplFileObject|null $my_file (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyMultipartFormdataSingleBinary'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return PromiseInterface
*/
public function testBodyMultipartFormdataSingleBinaryAsyncWithHttpInfo(
$my_file = null,
string $contentType = self::contentTypes['testBodyMultipartFormdataSingleBinary'][0]
): PromiseInterface
{
$returnType = 'string';
$request = $this->testBodyMultipartFormdataSingleBinaryRequest($my_file, $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 'testBodyMultipartFormdataSingleBinary'
*
* @param \SplFileObject|null $my_file (optional)
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyMultipartFormdataSingleBinary'] to see the possible values for this operation
*
* @throws InvalidArgumentException
* @return \GuzzleHttp\Psr7\Request
*/
public function testBodyMultipartFormdataSingleBinaryRequest(
$my_file = null,
string $contentType = self::contentTypes['testBodyMultipartFormdataSingleBinary'][0]
): Request
{
$resourcePath = '/body/application/octetstream/single_binary';
$formParams = [];
$queryParams = [];
$headerParams = [];
$httpBody = '';
$multipart = false;
// form params
if ($my_file !== null) {
$multipart = true;
$formParams['my-file'] = [];
$paramFiles = is_array($my_file) ? $my_file : [$my_file];
foreach ($paramFiles as $paramFile) {
$formParams['my-file'][] = \GuzzleHttp\Psr7\Utils::tryFopen(
ObjectSerializer::toFormValue($paramFile),
'rb'
);
}
}
$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 testEchoBodyAllOfPet
*