forked from loafle/openapi-generator-original
fix(php-nextgen): always return if not void (#21119)
This commit is contained in:
parent
a66dd20783
commit
d4d14204e8
@ -204,9 +204,11 @@ public class PhpNextgenClientCodegen extends AbstractPhpCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (phpReturnTypeOptions.isEmpty()) {
|
if (phpReturnTypeOptions.isEmpty()) {
|
||||||
|
operation.vendorExtensions.putIfAbsent("x-php-return-type-is-void", true);
|
||||||
operation.vendorExtensions.putIfAbsent("x-php-return-type", "void");
|
operation.vendorExtensions.putIfAbsent("x-php-return-type", "void");
|
||||||
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", "void");
|
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", "void");
|
||||||
} else {
|
} else {
|
||||||
|
operation.vendorExtensions.putIfAbsent("x-php-return-type-is-void", false);
|
||||||
operation.vendorExtensions.putIfAbsent("x-php-return-type", String.join("|", phpReturnTypeOptions));
|
operation.vendorExtensions.putIfAbsent("x-php-return-type", String.join("|", phpReturnTypeOptions));
|
||||||
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", String.join("|", docReturnTypeOptions));
|
operation.vendorExtensions.putIfAbsent("x-php-doc-return-type", String.join("|", docReturnTypeOptions));
|
||||||
}
|
}
|
||||||
|
@ -190,8 +190,8 @@ use {{invokerPackage}}\ObjectSerializer;
|
|||||||
{{/vendorExtensions.x-group-parameters}}
|
{{/vendorExtensions.x-group-parameters}}
|
||||||
): {{{vendorExtensions.x-php-return-type}}}
|
): {{{vendorExtensions.x-php-return-type}}}
|
||||||
{
|
{
|
||||||
{{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
|
{{^vendorExtensions.x-php-return-type-is-void}}list($response) = {{/vendorExtensions.x-php-return-type-is-void}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{^vendorExtensions.x-php-return-type-is-void}}
|
||||||
return $response;{{/returnType}}
|
return $response;{{/vendorExtensions.x-php-return-type-is-void}}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1444,6 +1444,51 @@ paths:
|
|||||||
description: Range of HTTP code 400-499
|
description: Range of HTTP code 400-499
|
||||||
requestBody:
|
requestBody:
|
||||||
$ref: '#/components/requestBodies/Pet'
|
$ref: '#/components/requestBodies/Pet'
|
||||||
|
"/error":
|
||||||
|
get:
|
||||||
|
summary: Will always generate an error
|
||||||
|
operationId: error
|
||||||
|
responses: &commonErrors
|
||||||
|
"400":
|
||||||
|
description: The supplied request was not valid
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
"404":
|
||||||
|
description: Requested item was not found
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
"422":
|
||||||
|
description: The input to the operation was not valid
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
"500":
|
||||||
|
description: Internal server error
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Error"
|
||||||
|
"/fake/pet/{pet_id}":
|
||||||
|
delete:
|
||||||
|
operationId: fakeDeletePet
|
||||||
|
tags:
|
||||||
|
- fake
|
||||||
|
parameters:
|
||||||
|
- name: pet_id
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
|
description: The id of the pet to retrieve
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"204":
|
||||||
|
description: "Returns 204 No Content on success."
|
||||||
|
<<: *commonErrors
|
||||||
servers:
|
servers:
|
||||||
- url: 'http://{server}.swagger.io:{port}/v2'
|
- url: 'http://{server}.swagger.io:{port}/v2'
|
||||||
description: petstore server
|
description: petstore server
|
||||||
@ -2230,3 +2275,18 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
error:
|
error:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
Error:
|
||||||
|
title: Error
|
||||||
|
description: "Returned when the server encounters an error, either in client input or internally"
|
||||||
|
properties:
|
||||||
|
error:
|
||||||
|
type: string
|
||||||
|
description: "A human readable error message"
|
||||||
|
errors:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
description: "Optional array of multiple errors encountered during processing"
|
||||||
|
required:
|
||||||
|
- error
|
||||||
|
@ -30,6 +30,7 @@ docs/Model/EnumArrays.md
|
|||||||
docs/Model/EnumClass.md
|
docs/Model/EnumClass.md
|
||||||
docs/Model/EnumTest.md
|
docs/Model/EnumTest.md
|
||||||
docs/Model/EnumWithNameAndDescription.md
|
docs/Model/EnumWithNameAndDescription.md
|
||||||
|
docs/Model/Error.md
|
||||||
docs/Model/ErrorResponse.md
|
docs/Model/ErrorResponse.md
|
||||||
docs/Model/FakeBigDecimalMap200Response.md
|
docs/Model/FakeBigDecimalMap200Response.md
|
||||||
docs/Model/File.md
|
docs/Model/File.md
|
||||||
@ -95,6 +96,7 @@ src/Model/EnumArrays.php
|
|||||||
src/Model/EnumClass.php
|
src/Model/EnumClass.php
|
||||||
src/Model/EnumTest.php
|
src/Model/EnumTest.php
|
||||||
src/Model/EnumWithNameAndDescription.php
|
src/Model/EnumWithNameAndDescription.php
|
||||||
|
src/Model/Error.php
|
||||||
src/Model/ErrorResponse.php
|
src/Model/ErrorResponse.php
|
||||||
src/Model/FakeBigDecimalMap200Response.php
|
src/Model/FakeBigDecimalMap200Response.php
|
||||||
src/Model/File.php
|
src/Model/File.php
|
||||||
|
@ -72,8 +72,10 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
|
|||||||
Class | Method | HTTP request | Description
|
Class | Method | HTTP request | Description
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
*AnotherFakeApi* | [**call123TestSpecialTags**](docs/Api/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
*AnotherFakeApi* | [**call123TestSpecialTags**](docs/Api/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
||||||
|
*DefaultApi* | [**error**](docs/Api/DefaultApi.md#error) | **GET** /error | Will always generate an error
|
||||||
*DefaultApi* | [**fooGet**](docs/Api/DefaultApi.md#fooget) | **GET** /foo |
|
*DefaultApi* | [**fooGet**](docs/Api/DefaultApi.md#fooget) | **GET** /foo |
|
||||||
*FakeApi* | [**fakeBigDecimalMap**](docs/Api/FakeApi.md#fakebigdecimalmap) | **GET** /fake/BigDecimalMap |
|
*FakeApi* | [**fakeBigDecimalMap**](docs/Api/FakeApi.md#fakebigdecimalmap) | **GET** /fake/BigDecimalMap |
|
||||||
|
*FakeApi* | [**fakeDeletePet**](docs/Api/FakeApi.md#fakedeletepet) | **DELETE** /fake/pet/{pet_id} |
|
||||||
*FakeApi* | [**fakeEnumEndpoint**](docs/Api/FakeApi.md#fakeenumendpoint) | **GET** /fake/enum/endpoint | test endpoint with enum parameter
|
*FakeApi* | [**fakeEnumEndpoint**](docs/Api/FakeApi.md#fakeenumendpoint) | **GET** /fake/enum/endpoint | test endpoint with enum parameter
|
||||||
*FakeApi* | [**fakeHealthGet**](docs/Api/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
|
*FakeApi* | [**fakeHealthGet**](docs/Api/FakeApi.md#fakehealthget) | **GET** /fake/health | Health check endpoint
|
||||||
*FakeApi* | [**fakeHttpSignatureTest**](docs/Api/FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication
|
*FakeApi* | [**fakeHttpSignatureTest**](docs/Api/FakeApi.md#fakehttpsignaturetest) | **GET** /fake/http-signature-test | test http signature authentication
|
||||||
@ -145,6 +147,7 @@ Class | Method | HTTP request | Description
|
|||||||
- [EnumClass](docs/Model/EnumClass.md)
|
- [EnumClass](docs/Model/EnumClass.md)
|
||||||
- [EnumTest](docs/Model/EnumTest.md)
|
- [EnumTest](docs/Model/EnumTest.md)
|
||||||
- [EnumWithNameAndDescription](docs/Model/EnumWithNameAndDescription.md)
|
- [EnumWithNameAndDescription](docs/Model/EnumWithNameAndDescription.md)
|
||||||
|
- [Error](docs/Model/Error.md)
|
||||||
- [ErrorResponse](docs/Model/ErrorResponse.md)
|
- [ErrorResponse](docs/Model/ErrorResponse.md)
|
||||||
- [FakeBigDecimalMap200Response](docs/Model/FakeBigDecimalMap200Response.md)
|
- [FakeBigDecimalMap200Response](docs/Model/FakeBigDecimalMap200Response.md)
|
||||||
- [File](docs/Model/File.md)
|
- [File](docs/Model/File.md)
|
||||||
|
@ -4,9 +4,60 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati
|
|||||||
|
|
||||||
| Method | HTTP request | Description |
|
| Method | HTTP request | Description |
|
||||||
| ------------- | ------------- | ------------- |
|
| ------------- | ------------- | ------------- |
|
||||||
|
| [**error()**](DefaultApi.md#error) | **GET** /error | Will always generate an error |
|
||||||
| [**fooGet()**](DefaultApi.md#fooGet) | **GET** /foo | |
|
| [**fooGet()**](DefaultApi.md#fooGet) | **GET** /foo | |
|
||||||
|
|
||||||
|
|
||||||
|
## `error()`
|
||||||
|
|
||||||
|
```php
|
||||||
|
error()
|
||||||
|
```
|
||||||
|
|
||||||
|
Will always generate an error
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require_once(__DIR__ . '/vendor/autoload.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$apiInstance = new OpenAPI\Client\Api\DefaultApi(
|
||||||
|
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||||
|
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||||
|
new GuzzleHttp\Client()
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$apiInstance->error();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo 'Exception when calling DefaultApi->error: ', $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: `application/json`
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||||
|
[[Back to Model list]](../../README.md#models)
|
||||||
|
[[Back to README]](../../README.md)
|
||||||
|
|
||||||
## `fooGet()`
|
## `fooGet()`
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
@ -5,6 +5,7 @@ All URIs are relative to http://petstore.swagger.io:80/v2, except if the operati
|
|||||||
| Method | HTTP request | Description |
|
| Method | HTTP request | Description |
|
||||||
| ------------- | ------------- | ------------- |
|
| ------------- | ------------- | ------------- |
|
||||||
| [**fakeBigDecimalMap()**](FakeApi.md#fakeBigDecimalMap) | **GET** /fake/BigDecimalMap | |
|
| [**fakeBigDecimalMap()**](FakeApi.md#fakeBigDecimalMap) | **GET** /fake/BigDecimalMap | |
|
||||||
|
| [**fakeDeletePet()**](FakeApi.md#fakeDeletePet) | **DELETE** /fake/pet/{pet_id} | |
|
||||||
| [**fakeEnumEndpoint()**](FakeApi.md#fakeEnumEndpoint) | **GET** /fake/enum/endpoint | test endpoint with enum parameter |
|
| [**fakeEnumEndpoint()**](FakeApi.md#fakeEnumEndpoint) | **GET** /fake/enum/endpoint | test endpoint with enum parameter |
|
||||||
| [**fakeHealthGet()**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint |
|
| [**fakeHealthGet()**](FakeApi.md#fakeHealthGet) | **GET** /fake/health | Health check endpoint |
|
||||||
| [**fakeHttpSignatureTest()**](FakeApi.md#fakeHttpSignatureTest) | **GET** /fake/http-signature-test | test http signature authentication |
|
| [**fakeHttpSignatureTest()**](FakeApi.md#fakeHttpSignatureTest) | **GET** /fake/http-signature-test | test http signature authentication |
|
||||||
@ -87,6 +88,59 @@ No authorization required
|
|||||||
[[Back to Model list]](../../README.md#models)
|
[[Back to Model list]](../../README.md#models)
|
||||||
[[Back to README]](../../README.md)
|
[[Back to README]](../../README.md)
|
||||||
|
|
||||||
|
## `fakeDeletePet()`
|
||||||
|
|
||||||
|
```php
|
||||||
|
fakeDeletePet($pet_id)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
require_once(__DIR__ . '/vendor/autoload.php');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$apiInstance = new OpenAPI\Client\Api\FakeApi(
|
||||||
|
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||||
|
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||||
|
new GuzzleHttp\Client()
|
||||||
|
);
|
||||||
|
$pet_id = 'pet_id_example'; // string | The id of the pet to retrieve
|
||||||
|
|
||||||
|
try {
|
||||||
|
$apiInstance->fakeDeletePet($pet_id);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo 'Exception when calling FakeApi->fakeDeletePet: ', $e->getMessage(), PHP_EOL;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Name | Type | Description | Notes |
|
||||||
|
| ------------- | ------------- | ------------- | ------------- |
|
||||||
|
| **pet_id** | **string**| The id of the pet to retrieve | |
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: `application/json`
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||||
|
[[Back to Model list]](../../README.md#models)
|
||||||
|
[[Back to README]](../../README.md)
|
||||||
|
|
||||||
## `fakeEnumEndpoint()`
|
## `fakeEnumEndpoint()`
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
# # Error
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**error** | **string** | A human readable error message |
|
||||||
|
**errors** | **string[]** | Optional array of multiple errors encountered during processing | [optional]
|
||||||
|
|
||||||
|
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -74,6 +74,9 @@ class DefaultApi
|
|||||||
|
|
||||||
/** @var string[] $contentTypes **/
|
/** @var string[] $contentTypes **/
|
||||||
public const contentTypes = [
|
public const contentTypes = [
|
||||||
|
'error' => [
|
||||||
|
'application/json',
|
||||||
|
],
|
||||||
'fooGet' => [
|
'fooGet' => [
|
||||||
'application/json',
|
'application/json',
|
||||||
],
|
],
|
||||||
@ -125,6 +128,246 @@ class DefaultApi
|
|||||||
return $this->config;
|
return $this->config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation error
|
||||||
|
*
|
||||||
|
* Will always generate an error
|
||||||
|
*
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['error'] 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 \OpenAPI\Client\Model\Error
|
||||||
|
*/
|
||||||
|
public function error(
|
||||||
|
string $contentType = self::contentTypes['error'][0]
|
||||||
|
): \OpenAPI\Client\Model\Error
|
||||||
|
{
|
||||||
|
list($response) = $this->errorWithHttpInfo($contentType);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation errorWithHttpInfo
|
||||||
|
*
|
||||||
|
* Will always generate an error
|
||||||
|
*
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['error'] 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 null, HTTP status code, HTTP response headers (array of strings)
|
||||||
|
*/
|
||||||
|
public function errorWithHttpInfo(
|
||||||
|
string $contentType = self::contentTypes['error'][0]
|
||||||
|
): array
|
||||||
|
{
|
||||||
|
$request = $this->errorRequest($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();
|
||||||
|
|
||||||
|
|
||||||
|
return [null, $statusCode, $response->getHeaders()];
|
||||||
|
} catch (ApiException $e) {
|
||||||
|
switch ($e->getCode()) {
|
||||||
|
case 400:
|
||||||
|
$data = ObjectSerializer::deserialize(
|
||||||
|
$e->getResponseBody(),
|
||||||
|
'\OpenAPI\Client\Model\Error',
|
||||||
|
$e->getResponseHeaders()
|
||||||
|
);
|
||||||
|
$e->setResponseObject($data);
|
||||||
|
throw $e;
|
||||||
|
case 404:
|
||||||
|
$data = ObjectSerializer::deserialize(
|
||||||
|
$e->getResponseBody(),
|
||||||
|
'\OpenAPI\Client\Model\Error',
|
||||||
|
$e->getResponseHeaders()
|
||||||
|
);
|
||||||
|
$e->setResponseObject($data);
|
||||||
|
throw $e;
|
||||||
|
case 422:
|
||||||
|
$data = ObjectSerializer::deserialize(
|
||||||
|
$e->getResponseBody(),
|
||||||
|
'\OpenAPI\Client\Model\Error',
|
||||||
|
$e->getResponseHeaders()
|
||||||
|
);
|
||||||
|
$e->setResponseObject($data);
|
||||||
|
throw $e;
|
||||||
|
case 500:
|
||||||
|
$data = ObjectSerializer::deserialize(
|
||||||
|
$e->getResponseBody(),
|
||||||
|
'\OpenAPI\Client\Model\Error',
|
||||||
|
$e->getResponseHeaders()
|
||||||
|
);
|
||||||
|
$e->setResponseObject($data);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation errorAsync
|
||||||
|
*
|
||||||
|
* Will always generate an error
|
||||||
|
*
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['error'] to see the possible values for this operation
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @return PromiseInterface
|
||||||
|
*/
|
||||||
|
public function errorAsync(
|
||||||
|
string $contentType = self::contentTypes['error'][0]
|
||||||
|
): PromiseInterface
|
||||||
|
{
|
||||||
|
return $this->errorAsyncWithHttpInfo($contentType)
|
||||||
|
->then(
|
||||||
|
function ($response) {
|
||||||
|
return $response[0];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation errorAsyncWithHttpInfo
|
||||||
|
*
|
||||||
|
* Will always generate an error
|
||||||
|
*
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['error'] to see the possible values for this operation
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @return PromiseInterface
|
||||||
|
*/
|
||||||
|
public function errorAsyncWithHttpInfo(
|
||||||
|
string $contentType = self::contentTypes['error'][0]
|
||||||
|
): PromiseInterface
|
||||||
|
{
|
||||||
|
$returnType = '';
|
||||||
|
$request = $this->errorRequest($contentType);
|
||||||
|
|
||||||
|
return $this->client
|
||||||
|
->sendAsync($request, $this->createHttpClientOption())
|
||||||
|
->then(
|
||||||
|
function ($response) use ($returnType) {
|
||||||
|
return [null, $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 'error'
|
||||||
|
*
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['error'] to see the possible values for this operation
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @return \GuzzleHttp\Psr7\Request
|
||||||
|
*/
|
||||||
|
public function errorRequest(
|
||||||
|
string $contentType = self::contentTypes['error'][0]
|
||||||
|
): Request
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$resourcePath = '/error';
|
||||||
|
$formParams = [];
|
||||||
|
$queryParams = [];
|
||||||
|
$headerParams = [];
|
||||||
|
$httpBody = '';
|
||||||
|
$multipart = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$headers = $this->headerSelector->selectHeaders(
|
||||||
|
['application/json', ],
|
||||||
|
$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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation fooGet
|
* Operation fooGet
|
||||||
*
|
*
|
||||||
|
@ -77,6 +77,9 @@ class FakeApi
|
|||||||
'fakeBigDecimalMap' => [
|
'fakeBigDecimalMap' => [
|
||||||
'application/json',
|
'application/json',
|
||||||
],
|
],
|
||||||
|
'fakeDeletePet' => [
|
||||||
|
'application/json',
|
||||||
|
],
|
||||||
'fakeEnumEndpoint' => [
|
'fakeEnumEndpoint' => [
|
||||||
'application/json',
|
'application/json',
|
||||||
],
|
],
|
||||||
@ -459,6 +462,263 @@ class FakeApi
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation fakeDeletePet
|
||||||
|
*
|
||||||
|
* @param string $pet_id The id of the pet to retrieve (required)
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeDeletePet'] 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 \OpenAPI\Client\Model\Error
|
||||||
|
*/
|
||||||
|
public function fakeDeletePet(
|
||||||
|
string $pet_id,
|
||||||
|
string $contentType = self::contentTypes['fakeDeletePet'][0]
|
||||||
|
): \OpenAPI\Client\Model\Error
|
||||||
|
{
|
||||||
|
list($response) = $this->fakeDeletePetWithHttpInfo($pet_id, $contentType);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation fakeDeletePetWithHttpInfo
|
||||||
|
*
|
||||||
|
* @param string $pet_id The id of the pet to retrieve (required)
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeDeletePet'] 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 null, HTTP status code, HTTP response headers (array of strings)
|
||||||
|
*/
|
||||||
|
public function fakeDeletePetWithHttpInfo(
|
||||||
|
string $pet_id,
|
||||||
|
string $contentType = self::contentTypes['fakeDeletePet'][0]
|
||||||
|
): array
|
||||||
|
{
|
||||||
|
$request = $this->fakeDeletePetRequest($pet_id, $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();
|
||||||
|
|
||||||
|
|
||||||
|
return [null, $statusCode, $response->getHeaders()];
|
||||||
|
} catch (ApiException $e) {
|
||||||
|
switch ($e->getCode()) {
|
||||||
|
case 400:
|
||||||
|
$data = ObjectSerializer::deserialize(
|
||||||
|
$e->getResponseBody(),
|
||||||
|
'\OpenAPI\Client\Model\Error',
|
||||||
|
$e->getResponseHeaders()
|
||||||
|
);
|
||||||
|
$e->setResponseObject($data);
|
||||||
|
throw $e;
|
||||||
|
case 404:
|
||||||
|
$data = ObjectSerializer::deserialize(
|
||||||
|
$e->getResponseBody(),
|
||||||
|
'\OpenAPI\Client\Model\Error',
|
||||||
|
$e->getResponseHeaders()
|
||||||
|
);
|
||||||
|
$e->setResponseObject($data);
|
||||||
|
throw $e;
|
||||||
|
case 422:
|
||||||
|
$data = ObjectSerializer::deserialize(
|
||||||
|
$e->getResponseBody(),
|
||||||
|
'\OpenAPI\Client\Model\Error',
|
||||||
|
$e->getResponseHeaders()
|
||||||
|
);
|
||||||
|
$e->setResponseObject($data);
|
||||||
|
throw $e;
|
||||||
|
case 500:
|
||||||
|
$data = ObjectSerializer::deserialize(
|
||||||
|
$e->getResponseBody(),
|
||||||
|
'\OpenAPI\Client\Model\Error',
|
||||||
|
$e->getResponseHeaders()
|
||||||
|
);
|
||||||
|
$e->setResponseObject($data);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation fakeDeletePetAsync
|
||||||
|
*
|
||||||
|
* @param string $pet_id The id of the pet to retrieve (required)
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeDeletePet'] to see the possible values for this operation
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @return PromiseInterface
|
||||||
|
*/
|
||||||
|
public function fakeDeletePetAsync(
|
||||||
|
string $pet_id,
|
||||||
|
string $contentType = self::contentTypes['fakeDeletePet'][0]
|
||||||
|
): PromiseInterface
|
||||||
|
{
|
||||||
|
return $this->fakeDeletePetAsyncWithHttpInfo($pet_id, $contentType)
|
||||||
|
->then(
|
||||||
|
function ($response) {
|
||||||
|
return $response[0];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operation fakeDeletePetAsyncWithHttpInfo
|
||||||
|
*
|
||||||
|
* @param string $pet_id The id of the pet to retrieve (required)
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeDeletePet'] to see the possible values for this operation
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @return PromiseInterface
|
||||||
|
*/
|
||||||
|
public function fakeDeletePetAsyncWithHttpInfo(
|
||||||
|
string $pet_id,
|
||||||
|
string $contentType = self::contentTypes['fakeDeletePet'][0]
|
||||||
|
): PromiseInterface
|
||||||
|
{
|
||||||
|
$returnType = '';
|
||||||
|
$request = $this->fakeDeletePetRequest($pet_id, $contentType);
|
||||||
|
|
||||||
|
return $this->client
|
||||||
|
->sendAsync($request, $this->createHttpClientOption())
|
||||||
|
->then(
|
||||||
|
function ($response) use ($returnType) {
|
||||||
|
return [null, $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 'fakeDeletePet'
|
||||||
|
*
|
||||||
|
* @param string $pet_id The id of the pet to retrieve (required)
|
||||||
|
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['fakeDeletePet'] to see the possible values for this operation
|
||||||
|
*
|
||||||
|
* @throws InvalidArgumentException
|
||||||
|
* @return \GuzzleHttp\Psr7\Request
|
||||||
|
*/
|
||||||
|
public function fakeDeletePetRequest(
|
||||||
|
string $pet_id,
|
||||||
|
string $contentType = self::contentTypes['fakeDeletePet'][0]
|
||||||
|
): Request
|
||||||
|
{
|
||||||
|
|
||||||
|
// verify the required parameter 'pet_id' is set
|
||||||
|
if ($pet_id === null || (is_array($pet_id) && count($pet_id) === 0)) {
|
||||||
|
throw new InvalidArgumentException(
|
||||||
|
'Missing the required parameter $pet_id when calling fakeDeletePet'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$resourcePath = '/fake/pet/{pet_id}';
|
||||||
|
$formParams = [];
|
||||||
|
$queryParams = [];
|
||||||
|
$headerParams = [];
|
||||||
|
$httpBody = '';
|
||||||
|
$multipart = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// path params
|
||||||
|
if ($pet_id !== null) {
|
||||||
|
$resourcePath = str_replace(
|
||||||
|
'{' . 'pet_id' . '}',
|
||||||
|
ObjectSerializer::toPathValue($pet_id),
|
||||||
|
$resourcePath
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$headers = $this->headerSelector->selectHeaders(
|
||||||
|
['application/json', ],
|
||||||
|
$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(
|
||||||
|
'DELETE',
|
||||||
|
$operationHost . $resourcePath . ($query ? "?{$query}" : ''),
|
||||||
|
$headers,
|
||||||
|
$httpBody
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Operation fakeEnumEndpoint
|
* Operation fakeEnumEndpoint
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,445 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Error
|
||||||
|
*
|
||||||
|
* PHP version 8.1
|
||||||
|
*
|
||||||
|
* @package OpenAPI\Client
|
||||||
|
* @author OpenAPI Generator team
|
||||||
|
* @link https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* @generated Generated by: https://openapi-generator.tech
|
||||||
|
* Generator version: 7.13.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error Class Doc Comment
|
||||||
|
*
|
||||||
|
* @description Returned when the server encounters an error, either in client input or internally
|
||||||
|
* @package OpenAPI\Client
|
||||||
|
* @author OpenAPI Generator team
|
||||||
|
* @link https://openapi-generator.tech
|
||||||
|
* @implements ArrayAccess<string, mixed>
|
||||||
|
*/
|
||||||
|
class Error implements ModelInterface, ArrayAccess, JsonSerializable
|
||||||
|
{
|
||||||
|
public const DISCRIMINATOR = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The original name of the model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected static string $openAPIModelName = 'Error';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of property to type mappings. Used for (de)serialization
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
protected static array $openAPITypes = [
|
||||||
|
'error' => 'string',
|
||||||
|
'errors' => 'string[]'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of property to format mappings. Used for (de)serialization
|
||||||
|
*
|
||||||
|
* @var array<string, string|null>
|
||||||
|
*/
|
||||||
|
protected static array $openAPIFormats = [
|
||||||
|
'error' => null,
|
||||||
|
'errors' => null
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of nullable properties. Used for (de)serialization
|
||||||
|
*
|
||||||
|
* @var array<string, bool>
|
||||||
|
*/
|
||||||
|
protected static array $openAPINullables = [
|
||||||
|
'error' => false,
|
||||||
|
'errors' => 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 = [
|
||||||
|
'error' => 'error',
|
||||||
|
'errors' => 'errors'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of attributes to setter functions (for deserialization of responses)
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
protected static array $setters = [
|
||||||
|
'error' => 'setError',
|
||||||
|
'errors' => 'setErrors'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of attributes to getter functions (for serialization of requests)
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
protected static array $getters = [
|
||||||
|
'error' => 'getError',
|
||||||
|
'errors' => 'getErrors'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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('error', $data ?? [], null);
|
||||||
|
$this->setIfExists('errors', $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['error'] === null) {
|
||||||
|
$invalidProperties[] = "'error' can't be null";
|
||||||
|
}
|
||||||
|
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 error
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getError(): string
|
||||||
|
{
|
||||||
|
return $this->container['error'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets error
|
||||||
|
*
|
||||||
|
* @param string $error A human readable error message
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setError(string $error): static
|
||||||
|
{
|
||||||
|
if (is_null($error)) {
|
||||||
|
throw new InvalidArgumentException('non-nullable error cannot be null');
|
||||||
|
}
|
||||||
|
$this->container['error'] = $error;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets errors
|
||||||
|
*
|
||||||
|
* @return string[]|null
|
||||||
|
*/
|
||||||
|
public function getErrors(): ?array
|
||||||
|
{
|
||||||
|
return $this->container['errors'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets errors
|
||||||
|
*
|
||||||
|
* @param string[]|null $errors Optional array of multiple errors encountered during processing
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setErrors(?array $errors): static
|
||||||
|
{
|
||||||
|
if (is_null($errors)) {
|
||||||
|
throw new InvalidArgumentException('non-nullable errors cannot be null');
|
||||||
|
}
|
||||||
|
$this->container['errors'] = $errors;
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ErrorTest
|
||||||
|
*
|
||||||
|
* PHP version 8.1
|
||||||
|
*
|
||||||
|
* @package OpenAPI\Client
|
||||||
|
* @author OpenAPI Generator team
|
||||||
|
* @link https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
*
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||||
|
*
|
||||||
|
* The version of the OpenAPI document: 1.0.0
|
||||||
|
* @generated Generated by: https://openapi-generator.tech
|
||||||
|
* Generator version: 7.13.0-SNAPSHOT
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Please update the test case below to test the model.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OpenAPI\Client\Test\Model;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ErrorTest Class Doc Comment
|
||||||
|
*
|
||||||
|
* @description Returned when the server encounters an error, either in client input or internally
|
||||||
|
* @package OpenAPI\Client
|
||||||
|
* @author OpenAPI Generator team
|
||||||
|
* @link https://openapi-generator.tech
|
||||||
|
*/
|
||||||
|
class ErrorTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup before running any test case
|
||||||
|
*/
|
||||||
|
public static function setUpBeforeClass(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup before running each test case
|
||||||
|
*/
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up after running each test case
|
||||||
|
*/
|
||||||
|
public function tearDown(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up after running all test cases
|
||||||
|
*/
|
||||||
|
public static function tearDownAfterClass(): void
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test "Error"
|
||||||
|
*/
|
||||||
|
public function testError()
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
self::markTestIncomplete('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test attribute "error"
|
||||||
|
*/
|
||||||
|
public function testPropertyError()
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
self::markTestIncomplete('Not implemented');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test attribute "errors"
|
||||||
|
*/
|
||||||
|
public function testPropertyErrors()
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
self::markTestIncomplete('Not implemented');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user