forked from loafle/openapi-generator-original
[PHP] 6.0.x make php implementation depend on meta packages for http client (#16368)
* add psr-18 support * update doc * fix test
This commit is contained in:
parent
2815e6a538
commit
d9423a4edb
12
bin/configs/php-psr-18.yaml
Normal file
12
bin/configs/php-psr-18.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
generatorName: php
|
||||
outputDir: samples/client/petstore/php/psr-18
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/php/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/php
|
||||
library: psr-18
|
||||
nameMappings:
|
||||
_type: underscore_type
|
||||
type_: type_with_underscore
|
||||
type-: type_with_dash
|
||||
parameterNameMappings:
|
||||
_type: underscore_type
|
||||
type_: type_with_underscore
|
@ -31,6 +31,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|hideGenerationTimestamp|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |true|
|
||||
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C# have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|library|HTTP library template (sub-template) to use|<dl><dt>**guzzle**</dt><dd>Guzzle</dd><dt>**psr-18**</dt><dd>psr/http-client-implementation, also known as PSR-18. (beta support)</dd></dl>|guzzle|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|
@ -35,6 +35,8 @@ import java.util.List;
|
||||
public class PhpClientCodegen extends AbstractPhpCodegen {
|
||||
@SuppressWarnings("hiding")
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(PhpClientCodegen.class);
|
||||
public static final String GUZZLE = "guzzle";
|
||||
public static final String PSR18 = "psr-18";
|
||||
|
||||
public PhpClientCodegen() {
|
||||
super();
|
||||
@ -82,6 +84,15 @@ public class PhpClientCodegen extends AbstractPhpCodegen {
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.ALLOW_UNICODE_IDENTIFIERS_DESC)
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
|
||||
supportedLibraries.put(GUZZLE, "Guzzle");
|
||||
supportedLibraries.put(PSR18, "psr/http-client-implementation, also known as PSR-18. (beta support)");
|
||||
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "HTTP library template (sub-template) to use");
|
||||
libraryOption.setEnum(supportedLibraries);
|
||||
// set GUZZLE as the default
|
||||
libraryOption.setDefault(GUZZLE);
|
||||
cliOptions.add(libraryOption);
|
||||
setLibrary(GUZZLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -114,5 +125,14 @@ public class PhpClientCodegen extends AbstractPhpCodegen {
|
||||
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||
supportingFiles.add(new SupportingFile(".php-cs-fixer.dist.php", "", ".php-cs-fixer.dist.php"));
|
||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.LIBRARY)) {
|
||||
this.setLibrary((String) additionalProperties.get(CodegenConstants.LIBRARY));
|
||||
}
|
||||
|
||||
if (PSR18.equals(getLibrary())) {
|
||||
supportingFiles.add(new SupportingFile("DebugPlugin.mustache", toSrcPath(invokerPackage, srcBasePath), "DebugPlugin.php"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
113
modules/openapi-generator/src/main/resources/php/libraries/psr-18/ApiException.mustache
vendored
Normal file
113
modules/openapi-generator/src/main/resources/php/libraries/psr-18/ApiException.mustache
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* ApiException
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
{{>partial_header}}
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace {{invokerPackage}};
|
||||
|
||||
use Exception;
|
||||
use Http\Client\Exception\RequestException;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* ApiException Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class ApiException extends RequestException
|
||||
{
|
||||
|
||||
/**
|
||||
* The HTTP body of the server response either as Json or string.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $responseBody;
|
||||
|
||||
/**
|
||||
* The HTTP header of the server response.
|
||||
*
|
||||
* @var string[]|null
|
||||
*/
|
||||
protected $responseHeaders;
|
||||
|
||||
/**
|
||||
* The deserialized response object
|
||||
*
|
||||
* @var \stdClass|string|null
|
||||
*/
|
||||
protected $responseObject;
|
||||
|
||||
public function __construct(
|
||||
$message,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response = null,
|
||||
Exception $previous = null
|
||||
) {
|
||||
parent::__construct($message, $request, $previous);
|
||||
if ($response) {
|
||||
$this->responseHeaders = $response->getHeaders();
|
||||
$this->responseBody = (string) $response->getBody();
|
||||
$this->code = $response->getStatusCode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTTP response header
|
||||
*
|
||||
* @return string[]|null HTTP response header
|
||||
*/
|
||||
public function getResponseHeaders()
|
||||
{
|
||||
return $this->responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTTP body of the server response either as Json or string
|
||||
*
|
||||
* @return \stdClass|string|null HTTP body of the server response either as \stdClass or string
|
||||
*/
|
||||
public function getResponseBody()
|
||||
{
|
||||
return $this->responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the deseralized response object (during deserialization)
|
||||
*
|
||||
* @param mixed $obj Deserialized response object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setResponseObject($obj)
|
||||
{
|
||||
$this->responseObject = $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the deseralized response object (during deserialization)
|
||||
*
|
||||
* @return mixed the deserialized response object
|
||||
*/
|
||||
public function getResponseObject()
|
||||
{
|
||||
return $this->responseObject;
|
||||
}
|
||||
}
|
92
modules/openapi-generator/src/main/resources/php/libraries/psr-18/DebugPlugin.mustache
vendored
Normal file
92
modules/openapi-generator/src/main/resources/php/libraries/psr-18/DebugPlugin.mustache
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuration
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
{{>partial_header}}
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace {{invokerPackage}};
|
||||
|
||||
use Http\Client\Common\Plugin;
|
||||
use Http\Promise\Promise;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use function is_resource;
|
||||
|
||||
/**
|
||||
* Configuration Class Doc Comment
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class DebugPlugin implements Plugin
|
||||
{
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* DebuggingPlugin constructor.
|
||||
*
|
||||
* @param resource $output
|
||||
*/
|
||||
public function __construct($output)
|
||||
{
|
||||
if (!is_resource($output)) {
|
||||
throw new \InvalidArgumentException('debugging resource is not valid');
|
||||
}
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
|
||||
{
|
||||
return $next($request)->then(
|
||||
function (ResponseInterface $response) use ($request) {
|
||||
$this->logSuccess($request, $response);
|
||||
|
||||
return $response;
|
||||
},
|
||||
function (ClientExceptionInterface $exception) use ($request) {
|
||||
$this->logError($request, $exception);
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function logSuccess(RequestInterface $request, ResponseInterface $response): void
|
||||
{
|
||||
$methodAndPath = $request->getMethod() . ' ' . $request->getUri()->getPath();
|
||||
$protocol = $response->getProtocolVersion();
|
||||
$responseCode = $response->getStatusCode();
|
||||
\fprintf($this->output, '<%s HTTP/%s> %s', $methodAndPath, $protocol, $responseCode);
|
||||
\fwrite($this->output, "\n");
|
||||
}
|
||||
|
||||
private function logError(RequestInterface $request, ClientExceptionInterface $exception): void
|
||||
{
|
||||
$methodAndPath = $request->getMethod() . ' ' . $request->getUri()->getPath();
|
||||
$protocol = $request->getProtocolVersion();
|
||||
$error = $exception->getMessage();
|
||||
$responseCode = $exception->getCode();
|
||||
\fprintf($this->output, '<%s HTTP/%s> %s %s', $methodAndPath, $responseCode, $error, $protocol);
|
||||
\fwrite($this->output, "\n");
|
||||
}
|
||||
}
|
159
modules/openapi-generator/src/main/resources/php/libraries/psr-18/README.mustache
vendored
Normal file
159
modules/openapi-generator/src/main/resources/php/libraries/psr-18/README.mustache
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
# {{packageName}}
|
||||
|
||||
{{#appDescriptionWithNewLines}}
|
||||
{{{appDescriptionWithNewLines}}}
|
||||
{{/appDescriptionWithNewLines}}
|
||||
|
||||
{{#infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}).
|
||||
{{/infoUrl}}
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
### Requirements
|
||||
|
||||
PHP 7.2 and later.
|
||||
|
||||
### Composer
|
||||
|
||||
To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}.git"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"{{gitUserId}}/{{gitRepoId}}": "*@dev"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then run `composer install`
|
||||
|
||||
Your project is free to choose the http client of your choice
|
||||
Please require packages that will provide http client functionality:
|
||||
https://packagist.org/providers/psr/http-client-implementation
|
||||
https://packagist.org/providers/php-http/async-client-implementation
|
||||
https://packagist.org/providers/psr/http-factory-implementation
|
||||
|
||||
As an example:
|
||||
|
||||
```
|
||||
composer require guzzlehttp/guzzle php-http/guzzle7-adapter http-interop/http-factory-guzzle
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
|
||||
Download the files and include `autoload.php`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once('/path/to/{{packageName}}/vendor/autoload.php');
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
|
||||
{{> php_doc_auth_partial}}
|
||||
$apiInstance = new {{invokerPackage}}\Api\{{classname}}(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(){{#hasAuthMethods}},
|
||||
$config{{/hasAuthMethods}}
|
||||
);
|
||||
{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{description}}}{{/description}}
|
||||
{{/allParams}}
|
||||
|
||||
try {
|
||||
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
|
||||
print_r($result);{{/returnType}}
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}/{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
|
||||
## Models
|
||||
|
||||
{{#models}}{{#model}}- [{{{classname}}}]({{modelDocPath}}/{{{classname}}}.md){{/model}}
|
||||
{{/models}}
|
||||
|
||||
## Authorization
|
||||
{{^authMethods}}
|
||||
All endpoints do not require authorization.
|
||||
{{/authMethods}}
|
||||
{{#authMethods}}
|
||||
{{#last}} Authentication schemes defined for the API:{{/last}}
|
||||
### {{{name}}}
|
||||
{{#isApiKey}}
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: {{{keyParamName}}}
|
||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
{{#isBasicBasic}}
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
|
||||
- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
|
||||
{{/isBasicBearer}}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
|
||||
- **Type**: `OAuth`
|
||||
- **Flow**: `{{{flow}}}`
|
||||
- **Authorization URL**: `{{{authorizationUrl}}}`
|
||||
- **Scopes**: {{^scopes}}N/A{{/scopes}}
|
||||
{{#scopes}}
|
||||
- **{{{scope}}}**: {{{description}}}
|
||||
{{/scopes}}
|
||||
{{/isOAuth}}
|
||||
|
||||
{{/authMethods}}
|
||||
## Tests
|
||||
|
||||
To run the tests, use:
|
||||
|
||||
```bash
|
||||
composer install
|
||||
vendor/bin/phpunit
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
{{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
|
||||
{{/-last}}{{/apis}}{{/apiInfo}}
|
||||
## About this package
|
||||
|
||||
This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: `{{appVersion}}`
|
||||
{{#artifactVersion}}
|
||||
- Package version: `{{artifactVersion}}`
|
||||
{{/artifactVersion}}
|
||||
{{^hideGenerationTimestamp}}
|
||||
- Build date: `{{generatedDate}}`
|
||||
{{/hideGenerationTimestamp}}
|
||||
- Build package: `{{generatorClass}}`
|
779
modules/openapi-generator/src/main/resources/php/libraries/psr-18/api.mustache
vendored
Normal file
779
modules/openapi-generator/src/main/resources/php/libraries/psr-18/api.mustache
vendored
Normal file
@ -0,0 +1,779 @@
|
||||
<?php
|
||||
/**
|
||||
* {{classname}}
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
{{>partial_header}}
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace {{apiPackage}};
|
||||
|
||||
use GuzzleHttp\Psr7\MultipartStream;
|
||||
use GuzzleHttp\Psr7\Query;
|
||||
use Http\Client\Common\Plugin\ErrorPlugin;
|
||||
use Http\Client\Common\Plugin\RedirectPlugin;
|
||||
use Http\Client\Common\PluginClient;
|
||||
use Http\Client\Common\PluginClientFactory;
|
||||
use Http\Client\Exception\HttpException;
|
||||
use Http\Client\HttpAsyncClient;
|
||||
use Http\Discovery\HttpAsyncClientDiscovery;
|
||||
use Http\Discovery\Psr17FactoryDiscovery;
|
||||
use Http\Discovery\Psr18ClientDiscovery;
|
||||
use Http\Message\RequestFactory;
|
||||
use Http\Promise\Promise;
|
||||
use {{invokerPackage}}\ApiException;
|
||||
use {{invokerPackage}}\Configuration;
|
||||
use {{invokerPackage}}\DebugPlugin;
|
||||
use {{invokerPackage}}\HeaderSelector;
|
||||
use {{invokerPackage}}\ObjectSerializer;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\UriFactoryInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* {{classname}} Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package {{invokerPackage}}
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
{{#operations}}class {{classname}}
|
||||
{
|
||||
/**
|
||||
* @var PluginClient
|
||||
*/
|
||||
protected $httpClient;
|
||||
|
||||
/**
|
||||
* @var PluginClient
|
||||
*/
|
||||
protected $httpAsyncClient;
|
||||
|
||||
/**
|
||||
* @var UriFactoryInterface
|
||||
*/
|
||||
protected $uriFactory;
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var HeaderSelector
|
||||
*/
|
||||
protected $headerSelector;
|
||||
|
||||
/**
|
||||
* @var int Host index
|
||||
*/
|
||||
protected $hostIndex;
|
||||
|
||||
/**
|
||||
* @var RequestFactoryInterface
|
||||
*/
|
||||
protected $requestFactory;
|
||||
|
||||
/**
|
||||
* @var StreamFactoryInterface
|
||||
*/
|
||||
protected $streamFactory;
|
||||
|
||||
public function __construct(
|
||||
ClientInterface $httpClient = null,
|
||||
Configuration $config = null,
|
||||
HttpAsyncClient $httpAsyncClient = null,
|
||||
UriFactoryInterface $uriFactory = null,
|
||||
RequestFactoryInterface $requestFactory = null,
|
||||
StreamFactoryInterface $streamFactory = null,
|
||||
HeaderSelector $selector = null,
|
||||
?array $plugins = null,
|
||||
$hostIndex = 0
|
||||
) {
|
||||
$this->config = $config ?? (new Configuration())->setHost('{{basePath}}');
|
||||
$this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
|
||||
$this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory();
|
||||
|
||||
$plugins = $plugins ?? [
|
||||
new RedirectPlugin(['strict' => true]),
|
||||
new ErrorPlugin(),
|
||||
];
|
||||
|
||||
if ($this->config->getDebug()) {
|
||||
$plugins[] = new DebugPlugin(fopen($this->config->getDebugFile(), 'ab'));
|
||||
}
|
||||
|
||||
$this->httpClient = (new PluginClientFactory())->createClient(
|
||||
$httpClient ?? Psr18ClientDiscovery::find(),
|
||||
$plugins
|
||||
);
|
||||
|
||||
$this->httpAsyncClient = (new PluginClientFactory())->createClient(
|
||||
$httpAsyncClient ?? HttpAsyncClientDiscovery::find(),
|
||||
$plugins
|
||||
);
|
||||
|
||||
$this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUriFactory();
|
||||
|
||||
$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}}
|
||||
/**
|
||||
* Operation {{{operationId}}}
|
||||
{{#summary}}
|
||||
*
|
||||
* {{.}}
|
||||
{{/summary}}
|
||||
*
|
||||
{{#description}}
|
||||
* {{.}}
|
||||
*
|
||||
{{/description}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
||||
*
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#servers}}
|
||||
{{#-first}}
|
||||
* This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
||||
{{/-first}}
|
||||
* URL: {{{url}}}
|
||||
{{#-last}}
|
||||
*
|
||||
{{/-last}}
|
||||
{{/servers}}
|
||||
{{#allParams}}
|
||||
* @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
|
||||
{{/allParams}}
|
||||
*
|
||||
* @throws \{{invokerPackage}}\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return {{#returnType}}{{#responses}}{{#dataType}}{{^-first}}|{{/-first}}{{/dataType}}{{{dataType}}}{{/responses}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
*/
|
||||
public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
|
||||
{
|
||||
{{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
|
||||
return $response;{{/returnType}}
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation {{{operationId}}}WithHttpInfo
|
||||
{{#summary}}
|
||||
*
|
||||
* {{.}}
|
||||
{{/summary}}
|
||||
*
|
||||
{{#description}}
|
||||
* {{.}}
|
||||
*
|
||||
{{/description}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
||||
*
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#servers}}
|
||||
{{#-first}}
|
||||
* This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
||||
{{/-first}}
|
||||
* URL: {{{url}}}
|
||||
{{#-last}}
|
||||
*
|
||||
{{/-last}}
|
||||
{{/servers}}
|
||||
{{#allParams}}
|
||||
* @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
|
||||
{{/allParams}}
|
||||
*
|
||||
* @throws \{{invokerPackage}}\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return array of {{#returnType}}{{#responses}}{{#dataType}}{{^-first}}|{{/-first}}{{/dataType}}{{{dataType}}}{{/responses}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
|
||||
*/
|
||||
public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
|
||||
{
|
||||
$request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});
|
||||
|
||||
try {
|
||||
try {
|
||||
$response = $this->httpClient->sendRequest($request);
|
||||
} catch (HttpException $e) {
|
||||
$response = $e->getResponse();
|
||||
throw new ApiException(
|
||||
sprintf(
|
||||
'[%d] Error connecting to the API (%s)',
|
||||
$response->getStatusCode(),
|
||||
(string) $request->getUri()
|
||||
),
|
||||
$request,
|
||||
$response,
|
||||
$e
|
||||
);
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
throw new ApiException(
|
||||
"[{$e->getCode()}] {$e->getMessage()}",
|
||||
$request,
|
||||
null,
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
{{#returnType}}
|
||||
{{#responses}}
|
||||
{{#-first}}
|
||||
|
||||
switch($statusCode) {
|
||||
{{/-first}}
|
||||
{{#dataType}}
|
||||
{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
|
||||
if ('{{{dataType}}}' === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, '{{{dataType}}}', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
{{/dataType}}
|
||||
{{#-last}}
|
||||
}
|
||||
{{/-last}}
|
||||
{{/responses}}
|
||||
|
||||
$returnType = '{{{returnType}}}';
|
||||
if ($returnType === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
|
||||
return [null, $statusCode, $response->getHeaders()];
|
||||
{{/returnType}}
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
{{#responses}}
|
||||
{{#dataType}}
|
||||
{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
|
||||
$data = ObjectSerializer::deserialize(
|
||||
$e->getResponseBody(),
|
||||
'{{{dataType}}}',
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
{{/dataType}}
|
||||
{{/responses}}
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation {{{operationId}}}Async
|
||||
*
|
||||
{{#summary}}
|
||||
* {{.}}
|
||||
*
|
||||
{{/summary}}
|
||||
{{#description}}
|
||||
* {{.}}
|
||||
*
|
||||
{{/description}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
||||
*
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#servers}}
|
||||
{{#-first}}
|
||||
* This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
||||
{{/-first}}
|
||||
* URL: {{{url}}}
|
||||
{{#-last}}
|
||||
*
|
||||
{{/-last}}
|
||||
{{/servers}}
|
||||
{{#allParams}}
|
||||
* @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
|
||||
{{/allParams}}
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return Promise
|
||||
*/
|
||||
public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
|
||||
{
|
||||
return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
|
||||
->then(
|
||||
function ($response) {
|
||||
return $response[0];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation {{{operationId}}}AsyncWithHttpInfo
|
||||
*
|
||||
{{#summary}}
|
||||
* {{.}}
|
||||
*
|
||||
{{/summary}}
|
||||
{{#description}}
|
||||
* {{.}}
|
||||
*
|
||||
{{/description}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
||||
*
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#servers}}
|
||||
{{#-first}}
|
||||
* This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
||||
{{/-first}}
|
||||
* URL: {{{url}}}
|
||||
{{#-last}}
|
||||
*
|
||||
{{/-last}}
|
||||
{{/servers}}
|
||||
{{#allParams}}
|
||||
* @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
|
||||
{{/allParams}}
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return Promise
|
||||
*/
|
||||
public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
|
||||
{
|
||||
$returnType = '{{{returnType}}}';
|
||||
$request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});
|
||||
|
||||
return $this->httpAsyncClient->sendAsyncRequest($request)
|
||||
->then(
|
||||
function ($response) use ($returnType) {
|
||||
{{#returnType}}
|
||||
if ($returnType === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return [null, $response->getStatusCode(), $response->getHeaders()];
|
||||
{{/returnType}}
|
||||
},
|
||||
function (HttpException $exception) {
|
||||
$response = $exception->getResponse();
|
||||
$statusCode = $response->getStatusCode();
|
||||
throw new ApiException(
|
||||
sprintf(
|
||||
'[%d] Error connecting to the API (%s)',
|
||||
$statusCode,
|
||||
$exception->getRequest()->getUri()
|
||||
),
|
||||
$exception->getRequest(),
|
||||
$exception->getResponse(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create request for operation '{{{operationId}}}'
|
||||
*
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
* Note: the input parameter is an associative array with the keys listed as the parameter name below
|
||||
*
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#servers}}
|
||||
{{#-first}}
|
||||
* This oepration contains host(s) defined in the OpenAP spec. Use 'hostIndex' to select the host.
|
||||
{{/-first}}
|
||||
* URL: {{{url}}}
|
||||
{{#-last}}
|
||||
*
|
||||
{{/-last}}
|
||||
{{/servers}}
|
||||
{{#allParams}}
|
||||
* @param {{{dataType}}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
|
||||
{{/allParams}}
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
|
||||
{
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
// unbox the parameters from the associative array
|
||||
{{#allParams}}
|
||||
${{paramName}} = array_key_exists('{{paramName}}', $associative_array) ? $associative_array['{{paramName}}'] : {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}};
|
||||
{{/allParams}}
|
||||
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if (${{paramName}} === null || (is_array(${{paramName}}) && count(${{paramName}}) === 0)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Missing the required parameter ${{paramName}} when calling {{operationId}}'
|
||||
);
|
||||
}
|
||||
{{/required}}
|
||||
{{#hasValidation}}
|
||||
{{#maxLength}}
|
||||
if ({{^required}}${{paramName}} !== null && {{/required}}strlen(${{paramName}}) > {{maxLength}}) {
|
||||
throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than or equal to {{maxLength}}.');
|
||||
}
|
||||
{{/maxLength}}
|
||||
{{#minLength}}
|
||||
if ({{^required}}${{paramName}} !== null && {{/required}}strlen(${{paramName}}) < {{minLength}}) {
|
||||
throw new \InvalidArgumentException('invalid length for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than or equal to {{minLength}}.');
|
||||
}
|
||||
{{/minLength}}
|
||||
{{#maximum}}
|
||||
if ({{^required}}${{paramName}} !== null && {{/required}}${{paramName}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{maximum}}) {
|
||||
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{maximum}}.');
|
||||
}
|
||||
{{/maximum}}
|
||||
{{#minimum}}
|
||||
if ({{^required}}${{paramName}} !== null && {{/required}}${{paramName}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{minimum}}) {
|
||||
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, must be bigger than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{minimum}}.');
|
||||
}
|
||||
{{/minimum}}
|
||||
{{#pattern}}
|
||||
if ({{^required}}${{paramName}} !== null && {{/required}}!preg_match("{{{pattern}}}", ${{paramName}})) {
|
||||
throw new \InvalidArgumentException("invalid value for \"{{paramName}}\" when calling {{classname}}.{{operationId}}, must conform to the pattern {{{pattern}}}.");
|
||||
}
|
||||
{{/pattern}}
|
||||
{{#maxItems}}
|
||||
if ({{^required}}${{paramName}} !== null && {{/required}}count(${{paramName}}) > {{maxItems}}) {
|
||||
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be less than or equal to {{maxItems}}.');
|
||||
}
|
||||
{{/maxItems}}
|
||||
{{#minItems}}
|
||||
if ({{^required}}${{paramName}} !== null && {{/required}}count(${{paramName}}) < {{minItems}}) {
|
||||
throw new \InvalidArgumentException('invalid value for "${{paramName}}" when calling {{classname}}.{{operationId}}, number of items must be greater than or equal to {{minItems}}.');
|
||||
}
|
||||
{{/minItems}}
|
||||
|
||||
{{/hasValidation}}
|
||||
{{/allParams}}
|
||||
|
||||
$resourcePath = '{{{path}}}';
|
||||
$formParams = [];
|
||||
$queryParams = [];
|
||||
$headerParams = [];
|
||||
$httpBody = null;
|
||||
$multipart = false;
|
||||
|
||||
{{#queryParams}}
|
||||
// query params
|
||||
{{#isExplode}}
|
||||
if (${{paramName}} !== null) {
|
||||
{{#style}}
|
||||
if('form' === '{{style}}' && is_array(${{paramName}})) {
|
||||
foreach(${{paramName}} as $key => $value) {
|
||||
$queryParams[$key] = $value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$queryParams['{{baseName}}'] = ${{paramName}};
|
||||
}
|
||||
{{/style}}
|
||||
{{^style}}
|
||||
$queryParams['{{baseName}}'] = ${{paramName}};
|
||||
{{/style}}
|
||||
}
|
||||
{{/isExplode}}
|
||||
{{^isExplode}}
|
||||
if (is_array(${{paramName}})) {
|
||||
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{#style}}{{style}}{{/style}}{{^style}}{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}{{/style}}', true);
|
||||
}
|
||||
if (${{paramName}} !== null) {
|
||||
$queryParams['{{baseName}}'] = ${{paramName}};
|
||||
}
|
||||
{{/isExplode}}
|
||||
{{/queryParams}}
|
||||
|
||||
{{#headerParams}}
|
||||
// header params
|
||||
{{#collectionFormat}}
|
||||
if (is_array(${{paramName}})) {
|
||||
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{collectionFormat}}');
|
||||
}
|
||||
{{/collectionFormat}}
|
||||
if (${{paramName}} !== null) {
|
||||
$headerParams['{{baseName}}'] = ObjectSerializer::toHeaderValue(${{paramName}});
|
||||
}
|
||||
{{/headerParams}}
|
||||
|
||||
{{#pathParams}}
|
||||
// path params
|
||||
{{#collectionFormat}}
|
||||
if (is_array(${{paramName}})) {
|
||||
${{paramName}} = ObjectSerializer::serializeCollection(${{paramName}}, '{{collectionFormat}}');
|
||||
}
|
||||
{{/collectionFormat}}
|
||||
if (${{paramName}} !== null) {
|
||||
$resourcePath = str_replace(
|
||||
'{' . '{{baseName}}' . '}',
|
||||
ObjectSerializer::toPathValue(${{paramName}}),
|
||||
$resourcePath
|
||||
);
|
||||
}
|
||||
{{/pathParams}}
|
||||
|
||||
{{#formParams}}
|
||||
// form params
|
||||
if (${{paramName}} !== null) {
|
||||
{{#isFile}}
|
||||
$multipart = true;
|
||||
$formParams['{{baseName}}'] = [];
|
||||
$paramFiles = is_array(${{paramName}}) ? ${{paramName}} : [${{paramName}}];
|
||||
foreach ($paramFiles as $paramFile) {
|
||||
$formParams['{{baseName}}'][] = \GuzzleHttp\Psr7\try_fopen(
|
||||
ObjectSerializer::toFormValue($paramFile),
|
||||
'rb'
|
||||
);
|
||||
}
|
||||
{{/isFile}}
|
||||
{{^isFile}}
|
||||
$formParams['{{baseName}}'] = ObjectSerializer::toFormValue(${{paramName}});
|
||||
{{/isFile}}
|
||||
}
|
||||
{{/formParams}}
|
||||
|
||||
if ($multipart) {
|
||||
$headers = $this->headerSelector->selectHeadersForMultipart(
|
||||
[{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}]
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
[{{#produces}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/produces}}],
|
||||
[{{#consumes}}'{{{mediaType}}}'{{^-last}}, {{/-last}}{{/consumes}}]
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
{{#bodyParams}}
|
||||
if (isset(${{paramName}})) {
|
||||
if ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = json_encode(ObjectSerializer::sanitizeForSerialization(${{paramName}}));
|
||||
} else {
|
||||
$httpBody = ${{paramName}};
|
||||
}
|
||||
} elseif (count($formParams) > 0) {
|
||||
{{/bodyParams}}
|
||||
{{^bodyParams}}
|
||||
if (count($formParams) > 0) {
|
||||
{{/bodyParams}}
|
||||
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 ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = json_encode($formParams);
|
||||
|
||||
} else {
|
||||
// for HTTP post (form)
|
||||
$httpBody = Query::build($formParams);
|
||||
}
|
||||
}
|
||||
|
||||
{{#authMethods}}
|
||||
{{#isApiKey}}
|
||||
// this endpoint requires API key authentication
|
||||
$apiKey = $this->config->getApiKeyWithPrefix('{{keyParamName}}');
|
||||
if ($apiKey !== null) {
|
||||
{{#isKeyInHeader}}$headers['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}}
|
||||
}
|
||||
{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
{{#isBasicBasic}}
|
||||
// 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());
|
||||
}
|
||||
{{/isBasicBasic}}
|
||||
{{#isBasicBearer}}
|
||||
// this endpoint requires Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} authentication (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
}
|
||||
{{/isBasicBearer}}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
// this endpoint requires OAuth (access token)
|
||||
if ($this->config->getAccessToken() !== null) {
|
||||
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
|
||||
}
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
|
||||
$defaultHeaders = [];
|
||||
if ($this->config->getUserAgent()) {
|
||||
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||||
}
|
||||
|
||||
$headers = array_merge(
|
||||
$defaultHeaders,
|
||||
$headerParams,
|
||||
$headers
|
||||
);
|
||||
|
||||
{{^servers.0}}
|
||||
$operationHost = $this->config->getHost();
|
||||
{{/servers.0}}
|
||||
{{#servers.0}}
|
||||
$operationHosts = [{{#servers}}"{{{url}}}"{{^-last}}, {{/-last}}{{/servers}}];
|
||||
if ($this->hostIndex < 0 || $this->hostIndex >= sizeof($operationHosts)) {
|
||||
throw new \InvalidArgumentException("Invalid index {$this->hostIndex} when selecting the host. Must be less than ".sizeof($operationHosts));
|
||||
}
|
||||
$operationHost = $operationHosts[$this->hostIndex];
|
||||
{{/servers.0}}
|
||||
|
||||
$uri = $this->createUri($operationHost, $resourcePath, $queryParams);
|
||||
|
||||
return $this->createRequest('{{httpMethod}}', $uri, $headers, $httpBody);
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string|UriInterface $uri
|
||||
* @param array $headers
|
||||
* @param string|StreamInterface|null $body
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
protected function createRequest(string $method, $uri, array $headers = [], $body = null): RequestInterface
|
||||
{
|
||||
if ($this->requestFactory instanceof RequestFactory) {
|
||||
return $this->requestFactory->createRequest(
|
||||
$method,
|
||||
$uri,
|
||||
$headers,
|
||||
$body
|
||||
);
|
||||
}
|
||||
|
||||
if (is_string($body) && '' !== $body && null === $this->streamFactory) {
|
||||
throw new \RuntimeException('Cannot create request: A stream factory is required to create a request with a non-empty string body.');
|
||||
}
|
||||
|
||||
$request = $this->requestFactory->createRequest($method, $uri);
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
$request = $request->withHeader($key, $value);
|
||||
}
|
||||
|
||||
if (null !== $body && '' !== $body) {
|
||||
$request = $request->withBody(
|
||||
is_string($body) ? $this->streamFactory->createStream($body) : $body
|
||||
);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
private function createUri(
|
||||
string $operationHost,
|
||||
string $resourcePath,
|
||||
array $queryParams
|
||||
): UriInterface {
|
||||
$parsedUrl = parse_url($operationHost);
|
||||
|
||||
$host = $parsedUrl['host'] ?? null;
|
||||
$scheme = $parsedUrl['scheme'] ?? null;
|
||||
$basePath = $parsedUrl['path'] ?? null;
|
||||
$port = $parsedUrl['port'] ?? null;
|
||||
$user = $parsedUrl['user'] ?? null;
|
||||
$password = $parsedUrl['pass'] ?? null;
|
||||
|
||||
$uri = $this->uriFactory->createUri($basePath . $resourcePath)
|
||||
->withHost($host)
|
||||
->withScheme($scheme)
|
||||
->withPort($port)
|
||||
->withQuery(Query::build($queryParams));
|
||||
|
||||
if ($user) {
|
||||
$uri = $uri->withUserInfo($user, $password);
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
}
|
||||
{{/operations}}
|
78
modules/openapi-generator/src/main/resources/php/libraries/psr-18/api_doc.mustache
vendored
Normal file
78
modules/openapi-generator/src/main/resources/php/libraries/psr-18/api_doc.mustache
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
# {{invokerPackage}}\{{classname}}{{#description}}
|
||||
|
||||
{{description}}{{/description}}
|
||||
|
||||
All URIs are relative to {{basePath}}.
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#operations}}{{#operation}}[**{{operationId}}()**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
|
||||
{{/operation}}{{/operations}}{{#operations}}{{#operation}}
|
||||
|
||||
## `{{{operationId}}}()`
|
||||
|
||||
```php
|
||||
{{{operationId}}}({{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}: {{{returnType}}}{{/returnType}}
|
||||
```
|
||||
|
||||
{{{summary}}}{{#notes}}
|
||||
|
||||
{{{notes}}}{{/notes}}
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
{{> php_doc_auth_partial}}
|
||||
$apiInstance = new {{invokerPackage}}\Api\{{classname}}(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(){{#hasAuthMethods}},
|
||||
$config{{/hasAuthMethods}}
|
||||
);
|
||||
{{^vendorExtensions.x-group-parameters}}
|
||||
{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{description}}}{{/description}}
|
||||
{{/allParams}}
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
{{#allParams}}$associate_array['{{paramName}}'] = {{{example}}}; // {{{dataType}}}{{#description}} | {{{description}}}{{/description}}
|
||||
{{/allParams}}
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
|
||||
try {
|
||||
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associate_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
|
||||
print_r($result);{{/returnType}}
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
{{#vendorExtensions.x-group-parameters}}
|
||||
Note: the input parameter is an associative array with the keys listed as the parameter name below.
|
||||
|
||||
{{/vendorExtensions.x-group-parameters}}
|
||||
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
|
||||
{{#allParams}} **{{paramName}}** | {{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{{dataType}}}**](../Model/{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{defaultValue}}]{{/defaultValue}}
|
||||
{{/allParams}}
|
||||
|
||||
### Return type
|
||||
|
||||
{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**](../Model/{{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: {{#consumes}}`{{{mediaType}}}`{{^-last}}, {{/-last}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
|
||||
- **Accept**: {{#produces}}`{{{mediaType}}}`{{^-last}}, {{/-last}}{{/produces}}{{^produces}}Not defined{{/produces}}
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md){{/operation}}{{/operations}}
|
54
modules/openapi-generator/src/main/resources/php/libraries/psr-18/composer.mustache
vendored
Normal file
54
modules/openapi-generator/src/main/resources/php/libraries/psr-18/composer.mustache
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"name": "{{gitUserId}}/{{gitRepoId}}",
|
||||
{{#artifactVersion}}
|
||||
"version": "{{artifactVersion}}",
|
||||
{{/artifactVersion}}
|
||||
"description": "{{{appDescription}}}",
|
||||
"keywords": [
|
||||
"openapitools",
|
||||
"openapi-generator",
|
||||
"openapi",
|
||||
"php",
|
||||
"sdk",
|
||||
"rest",
|
||||
"api"
|
||||
],
|
||||
"homepage": "https://openapi-generator.tech",
|
||||
"license": "unlicense",
|
||||
"authors": [
|
||||
{
|
||||
"name": "OpenAPI-Generator contributors",
|
||||
"homepage": "https://openapi-generator.tech"
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"guzzlehttp/psr7": "^1.8 || ^2.0",
|
||||
"php-http/async-client-implementation": "^1.0",
|
||||
"php-http/client-common": "^2.4",
|
||||
"php-http/discovery": "^1.14",
|
||||
"php-http/httplug": "^2.2",
|
||||
"psr/http-client-implementation": "^1.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-factory-implementation": "^1.0",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.0 || ^9.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.12",
|
||||
"guzzlehttp/guzzle": "^7.0",
|
||||
"php-http/guzzle7-adapter": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "{{escapedInvokerPackage}}\\Test\\" : "{{testBasePath}}/" }
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@ public class PhpClientOptionsProvider implements OptionsProvider {
|
||||
public static final String ARTIFACTURL_VALUE = "https://anotherUrl.com";
|
||||
public static final String DEVELOPER_ORGANIZATION_VALUE = "openapi generator contributors";
|
||||
public static final String COMPOSER_PACKAGE_NAME_VALUE = "package/name";
|
||||
public static final String LIBRARY_VALUE = "psr-18";
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
@ -72,6 +73,7 @@ public class PhpClientOptionsProvider implements OptionsProvider {
|
||||
.put(CodegenConstants.ARTIFACT_URL, ARTIFACTURL_VALUE)
|
||||
.put(CodegenConstants.DEVELOPER_ORGANIZATION, DEVELOPER_ORGANIZATION_VALUE)
|
||||
.put(CodegenConstants.COMPOSER_PACKAGE_NAME, COMPOSER_PACKAGE_NAME_VALUE)
|
||||
.put(CodegenConstants.LIBRARY, LIBRARY_VALUE)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ import org.openapitools.codegen.AbstractOptionsTest;
|
||||
import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.languages.PhpClientCodegen;
|
||||
import org.openapitools.codegen.options.PhpClientOptionsProvider;
|
||||
import org.openapitools.codegen.options.PhpLumenServerOptionsProvider;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -54,5 +53,6 @@ public class PhpClientOptionsTest extends AbstractOptionsTest {
|
||||
verify(clientCodegen).setDeveloperOrganizationUrl(PhpClientOptionsProvider.DEVELOPER_ORGANIZATION_URL_VALUE);
|
||||
verify(clientCodegen).setArtifactUrl(PhpClientOptionsProvider.ARTIFACTURL_VALUE);
|
||||
verify(clientCodegen).setDeveloperOrganization(PhpClientOptionsProvider.DEVELOPER_ORGANIZATION_VALUE);
|
||||
verify(clientCodegen).setLibrary(PhpClientOptionsProvider.LIBRARY_VALUE);
|
||||
}
|
||||
}
|
||||
|
15
samples/client/petstore/php/psr-18/.gitignore
vendored
Normal file
15
samples/client/petstore/php/psr-18/.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore
|
||||
|
||||
composer.phar
|
||||
/vendor/
|
||||
|
||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
||||
# composer.lock
|
||||
|
||||
# php-cs-fixer cache
|
||||
.php_cs.cache
|
||||
.php-cs-fixer.cache
|
||||
|
||||
# PHPUnit cache
|
||||
.phpunit.result.cache
|
23
samples/client/petstore/php/psr-18/.openapi-generator-ignore
Normal file
23
samples/client/petstore/php/psr-18/.openapi-generator-ignore
Normal file
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
123
samples/client/petstore/php/psr-18/.openapi-generator/FILES
Normal file
123
samples/client/petstore/php/psr-18/.openapi-generator/FILES
Normal file
@ -0,0 +1,123 @@
|
||||
.gitignore
|
||||
.php-cs-fixer.dist.php
|
||||
.travis.yml
|
||||
README.md
|
||||
composer.json
|
||||
docs/Api/AnotherFakeApi.md
|
||||
docs/Api/DefaultApi.md
|
||||
docs/Api/FakeApi.md
|
||||
docs/Api/FakeClassnameTags123Api.md
|
||||
docs/Api/PetApi.md
|
||||
docs/Api/StoreApi.md
|
||||
docs/Api/UserApi.md
|
||||
docs/Model/AdditionalPropertiesClass.md
|
||||
docs/Model/AllOfWithSingleRef.md
|
||||
docs/Model/Animal.md
|
||||
docs/Model/ApiResponse.md
|
||||
docs/Model/ArrayOfArrayOfNumberOnly.md
|
||||
docs/Model/ArrayOfNumberOnly.md
|
||||
docs/Model/ArrayTest.md
|
||||
docs/Model/Capitalization.md
|
||||
docs/Model/Cat.md
|
||||
docs/Model/Category.md
|
||||
docs/Model/ClassModel.md
|
||||
docs/Model/Client.md
|
||||
docs/Model/DeprecatedObject.md
|
||||
docs/Model/Dog.md
|
||||
docs/Model/EnumArrays.md
|
||||
docs/Model/EnumClass.md
|
||||
docs/Model/EnumTest.md
|
||||
docs/Model/FakeBigDecimalMap200Response.md
|
||||
docs/Model/File.md
|
||||
docs/Model/FileSchemaTestClass.md
|
||||
docs/Model/Foo.md
|
||||
docs/Model/FooGetDefaultResponse.md
|
||||
docs/Model/FormatTest.md
|
||||
docs/Model/HasOnlyReadOnly.md
|
||||
docs/Model/HealthCheckResult.md
|
||||
docs/Model/MapTest.md
|
||||
docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md
|
||||
docs/Model/Model200Response.md
|
||||
docs/Model/ModelList.md
|
||||
docs/Model/ModelReturn.md
|
||||
docs/Model/Name.md
|
||||
docs/Model/NullableClass.md
|
||||
docs/Model/NumberOnly.md
|
||||
docs/Model/ObjectWithDeprecatedFields.md
|
||||
docs/Model/Order.md
|
||||
docs/Model/OuterComposite.md
|
||||
docs/Model/OuterEnum.md
|
||||
docs/Model/OuterEnumDefaultValue.md
|
||||
docs/Model/OuterEnumInteger.md
|
||||
docs/Model/OuterEnumIntegerDefaultValue.md
|
||||
docs/Model/OuterObjectWithEnumProperty.md
|
||||
docs/Model/Pet.md
|
||||
docs/Model/PropertyNameMapping.md
|
||||
docs/Model/ReadOnlyFirst.md
|
||||
docs/Model/SingleRefType.md
|
||||
docs/Model/SpecialModelName.md
|
||||
docs/Model/Tag.md
|
||||
docs/Model/User.md
|
||||
git_push.sh
|
||||
lib/Api/AnotherFakeApi.php
|
||||
lib/Api/DefaultApi.php
|
||||
lib/Api/FakeApi.php
|
||||
lib/Api/FakeClassnameTags123Api.php
|
||||
lib/Api/PetApi.php
|
||||
lib/Api/StoreApi.php
|
||||
lib/Api/UserApi.php
|
||||
lib/ApiException.php
|
||||
lib/Configuration.php
|
||||
lib/DebugPlugin.php
|
||||
lib/HeaderSelector.php
|
||||
lib/Model/AdditionalPropertiesClass.php
|
||||
lib/Model/AllOfWithSingleRef.php
|
||||
lib/Model/Animal.php
|
||||
lib/Model/ApiResponse.php
|
||||
lib/Model/ArrayOfArrayOfNumberOnly.php
|
||||
lib/Model/ArrayOfNumberOnly.php
|
||||
lib/Model/ArrayTest.php
|
||||
lib/Model/Capitalization.php
|
||||
lib/Model/Cat.php
|
||||
lib/Model/Category.php
|
||||
lib/Model/ClassModel.php
|
||||
lib/Model/Client.php
|
||||
lib/Model/DeprecatedObject.php
|
||||
lib/Model/Dog.php
|
||||
lib/Model/EnumArrays.php
|
||||
lib/Model/EnumClass.php
|
||||
lib/Model/EnumTest.php
|
||||
lib/Model/FakeBigDecimalMap200Response.php
|
||||
lib/Model/File.php
|
||||
lib/Model/FileSchemaTestClass.php
|
||||
lib/Model/Foo.php
|
||||
lib/Model/FooGetDefaultResponse.php
|
||||
lib/Model/FormatTest.php
|
||||
lib/Model/HasOnlyReadOnly.php
|
||||
lib/Model/HealthCheckResult.php
|
||||
lib/Model/MapTest.php
|
||||
lib/Model/MixedPropertiesAndAdditionalPropertiesClass.php
|
||||
lib/Model/Model200Response.php
|
||||
lib/Model/ModelInterface.php
|
||||
lib/Model/ModelList.php
|
||||
lib/Model/ModelReturn.php
|
||||
lib/Model/Name.php
|
||||
lib/Model/NullableClass.php
|
||||
lib/Model/NumberOnly.php
|
||||
lib/Model/ObjectWithDeprecatedFields.php
|
||||
lib/Model/Order.php
|
||||
lib/Model/OuterComposite.php
|
||||
lib/Model/OuterEnum.php
|
||||
lib/Model/OuterEnumDefaultValue.php
|
||||
lib/Model/OuterEnumInteger.php
|
||||
lib/Model/OuterEnumIntegerDefaultValue.php
|
||||
lib/Model/OuterObjectWithEnumProperty.php
|
||||
lib/Model/Pet.php
|
||||
lib/Model/PropertyNameMapping.php
|
||||
lib/Model/ReadOnlyFirst.php
|
||||
lib/Model/SingleRefType.php
|
||||
lib/Model/SpecialModelName.php
|
||||
lib/Model/Tag.php
|
||||
lib/Model/User.php
|
||||
lib/ObjectSerializer.php
|
||||
phpunit.xml.dist
|
@ -0,0 +1 @@
|
||||
7.0.0-SNAPSHOT
|
29
samples/client/petstore/php/psr-18/.php-cs-fixer.dist.php
Normal file
29
samples/client/petstore/php/psr-18/.php-cs-fixer.dist.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @generated
|
||||
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/HEAD/doc/config.rst
|
||||
*/
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__)
|
||||
->exclude('vendor')
|
||||
->exclude('test')
|
||||
->exclude('tests')
|
||||
;
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PSR12' => true,
|
||||
'phpdoc_order' => true,
|
||||
'array_syntax' => [ 'syntax' => 'short' ],
|
||||
'strict_comparison' => true,
|
||||
'strict_param' => true,
|
||||
'no_trailing_whitespace' => false,
|
||||
'no_trailing_whitespace_in_comment' => false,
|
||||
'braces' => false,
|
||||
'single_blank_line_at_eof' => false,
|
||||
'blank_line_after_namespace' => false,
|
||||
'no_leading_import_slash' => false,
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
8
samples/client/petstore/php/psr-18/.travis.yml
Normal file
8
samples/client/petstore/php/psr-18/.travis.yml
Normal file
@ -0,0 +1,8 @@
|
||||
language: php
|
||||
# Bionic environment has preinstalled PHP from 7.1 to 7.4
|
||||
# https://docs.travis-ci.com/user/reference/bionic/#php-support
|
||||
dist: bionic
|
||||
php:
|
||||
- 7.4
|
||||
before_install: "composer install"
|
||||
script: "vendor/bin/phpunit"
|
239
samples/client/petstore/php/psr-18/README.md
Normal file
239
samples/client/petstore/php/psr-18/README.md
Normal file
@ -0,0 +1,239 @@
|
||||
# OpenAPIClient-php
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
### Requirements
|
||||
|
||||
PHP 7.2 and later.
|
||||
|
||||
### Composer
|
||||
|
||||
To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"GIT_USER_ID/GIT_REPO_ID": "*@dev"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then run `composer install`
|
||||
|
||||
Your project is free to choose the http client of your choice
|
||||
Please require packages that will provide http client functionality:
|
||||
https://packagist.org/providers/psr/http-client-implementation
|
||||
https://packagist.org/providers/php-http/async-client-implementation
|
||||
https://packagist.org/providers/psr/http-factory-implementation
|
||||
|
||||
As an example:
|
||||
|
||||
```
|
||||
composer require guzzlehttp/guzzle php-http/guzzle7-adapter http-interop/http-factory-guzzle
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
|
||||
Download the files and include `autoload.php`:
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\AnotherFakeApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model
|
||||
|
||||
try {
|
||||
$result = $apiInstance->call123TestSpecialTags($client);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling AnotherFakeApi->call123TestSpecialTags: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeApi* | [**call123TestSpecialTags**](docs/Api/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
*DefaultApi* | [**fooGet**](docs/Api/DefaultApi.md#fooget) | **GET** /foo |
|
||||
*FakeApi* | [**fakeBigDecimalMap**](docs/Api/FakeApi.md#fakebigdecimalmap) | **GET** /fake/BigDecimalMap |
|
||||
*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* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
|
||||
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
|
||||
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
|
||||
*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
|
||||
*FakeApi* | [**fakePropertyEnumIntegerSerialize**](docs/Api/FakeApi.md#fakepropertyenumintegerserialize) | **POST** /fake/property/enum-int |
|
||||
*FakeApi* | [**getParameterNameMapping**](docs/Api/FakeApi.md#getparameternamemapping) | **GET** /fake/parameter-name-mapping | parameter name mapping test
|
||||
*FakeApi* | [**testBodyWithBinary**](docs/Api/FakeApi.md#testbodywithbinary) | **PUT** /fake/body-with-binary |
|
||||
*FakeApi* | [**testBodyWithFileSchema**](docs/Api/FakeApi.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema |
|
||||
*FakeApi* | [**testBodyWithQueryParams**](docs/Api/FakeApi.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params |
|
||||
*FakeApi* | [**testClientModel**](docs/Api/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model
|
||||
*FakeApi* | [**testEndpointParameters**](docs/Api/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeApi* | [**testEnumParameters**](docs/Api/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters
|
||||
*FakeApi* | [**testGroupParameters**](docs/Api/FakeApi.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
*FakeApi* | [**testInlineAdditionalProperties**](docs/Api/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeApi* | [**testQueryParameterCollectionFormat**](docs/Api/FakeApi.md#testqueryparametercollectionformat) | **PUT** /fake/test-query-parameters |
|
||||
*FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | [**deletePet**](docs/Api/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PetApi* | [**findPetsByStatus**](docs/Api/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PetApi* | [**findPetsByTags**](docs/Api/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PetApi* | [**getPetById**](docs/Api/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PetApi* | [**updatePet**](docs/Api/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
|
||||
*PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*PetApi* | [**uploadFileWithRequiredFile**](docs/Api/PetApi.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
*StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
*StoreApi* | [**placeOrder**](docs/Api/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
|
||||
*UserApi* | [**createUser**](docs/Api/UserApi.md#createuser) | **POST** /user | Create user
|
||||
*UserApi* | [**createUsersWithArrayInput**](docs/Api/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*UserApi* | [**createUsersWithListInput**](docs/Api/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*UserApi* | [**deleteUser**](docs/Api/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
|
||||
*UserApi* | [**getUserByName**](docs/Api/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
|
||||
*UserApi* | [**loginUser**](docs/Api/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
|
||||
*UserApi* | [**logoutUser**](docs/Api/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
|
||||
*UserApi* | [**updateUser**](docs/Api/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
## Models
|
||||
|
||||
- [AdditionalPropertiesClass](docs/Model/AdditionalPropertiesClass.md)
|
||||
- [AllOfWithSingleRef](docs/Model/AllOfWithSingleRef.md)
|
||||
- [Animal](docs/Model/Animal.md)
|
||||
- [ApiResponse](docs/Model/ApiResponse.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/Model/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/Model/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/Model/ArrayTest.md)
|
||||
- [Capitalization](docs/Model/Capitalization.md)
|
||||
- [Cat](docs/Model/Cat.md)
|
||||
- [Category](docs/Model/Category.md)
|
||||
- [ClassModel](docs/Model/ClassModel.md)
|
||||
- [Client](docs/Model/Client.md)
|
||||
- [DeprecatedObject](docs/Model/DeprecatedObject.md)
|
||||
- [Dog](docs/Model/Dog.md)
|
||||
- [EnumArrays](docs/Model/EnumArrays.md)
|
||||
- [EnumClass](docs/Model/EnumClass.md)
|
||||
- [EnumTest](docs/Model/EnumTest.md)
|
||||
- [FakeBigDecimalMap200Response](docs/Model/FakeBigDecimalMap200Response.md)
|
||||
- [File](docs/Model/File.md)
|
||||
- [FileSchemaTestClass](docs/Model/FileSchemaTestClass.md)
|
||||
- [Foo](docs/Model/Foo.md)
|
||||
- [FooGetDefaultResponse](docs/Model/FooGetDefaultResponse.md)
|
||||
- [FormatTest](docs/Model/FormatTest.md)
|
||||
- [HasOnlyReadOnly](docs/Model/HasOnlyReadOnly.md)
|
||||
- [HealthCheckResult](docs/Model/HealthCheckResult.md)
|
||||
- [MapTest](docs/Model/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model/Model200Response.md)
|
||||
- [ModelList](docs/Model/ModelList.md)
|
||||
- [ModelReturn](docs/Model/ModelReturn.md)
|
||||
- [Name](docs/Model/Name.md)
|
||||
- [NullableClass](docs/Model/NullableClass.md)
|
||||
- [NumberOnly](docs/Model/NumberOnly.md)
|
||||
- [ObjectWithDeprecatedFields](docs/Model/ObjectWithDeprecatedFields.md)
|
||||
- [Order](docs/Model/Order.md)
|
||||
- [OuterComposite](docs/Model/OuterComposite.md)
|
||||
- [OuterEnum](docs/Model/OuterEnum.md)
|
||||
- [OuterEnumDefaultValue](docs/Model/OuterEnumDefaultValue.md)
|
||||
- [OuterEnumInteger](docs/Model/OuterEnumInteger.md)
|
||||
- [OuterEnumIntegerDefaultValue](docs/Model/OuterEnumIntegerDefaultValue.md)
|
||||
- [OuterObjectWithEnumProperty](docs/Model/OuterObjectWithEnumProperty.md)
|
||||
- [Pet](docs/Model/Pet.md)
|
||||
- [PropertyNameMapping](docs/Model/PropertyNameMapping.md)
|
||||
- [ReadOnlyFirst](docs/Model/ReadOnlyFirst.md)
|
||||
- [SingleRefType](docs/Model/SingleRefType.md)
|
||||
- [SpecialModelName](docs/Model/SpecialModelName.md)
|
||||
- [Tag](docs/Model/Tag.md)
|
||||
- [User](docs/Model/User.md)
|
||||
|
||||
## Authorization
|
||||
|
||||
### petstore_auth
|
||||
|
||||
- **Type**: `OAuth`
|
||||
- **Flow**: `implicit`
|
||||
- **Authorization URL**: `http://petstore.swagger.io/api/oauth/dialog`
|
||||
- **Scopes**:
|
||||
- **write:pets**: modify pets in your account
|
||||
- **read:pets**: read your pets
|
||||
|
||||
|
||||
### api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
|
||||
|
||||
### api_key_query
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key_query
|
||||
- **Location**: URL query string
|
||||
|
||||
|
||||
|
||||
### http_basic_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
|
||||
### bearer_test
|
||||
|
||||
- **Type**: Bearer authentication (JWT)
|
||||
|
||||
|
||||
### http_signature_test
|
||||
|
||||
## Tests
|
||||
|
||||
To run the tests, use:
|
||||
|
||||
```bash
|
||||
composer install
|
||||
vendor/bin/phpunit
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
||||
## About this package
|
||||
|
||||
This PHP package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: `1.0.0`
|
||||
- Build package: `org.openapitools.codegen.languages.PhpClientCodegen`
|
51
samples/client/petstore/php/psr-18/composer.json
Normal file
51
samples/client/petstore/php/psr-18/composer.json
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "GIT_USER_ID/GIT_REPO_ID",
|
||||
"description": "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\",
|
||||
"keywords": [
|
||||
"openapitools",
|
||||
"openapi-generator",
|
||||
"openapi",
|
||||
"php",
|
||||
"sdk",
|
||||
"rest",
|
||||
"api"
|
||||
],
|
||||
"homepage": "https://openapi-generator.tech",
|
||||
"license": "unlicense",
|
||||
"authors": [
|
||||
{
|
||||
"name": "OpenAPI-Generator contributors",
|
||||
"homepage": "https://openapi-generator.tech"
|
||||
}
|
||||
],
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"guzzlehttp/psr7": "^1.8 || ^2.0",
|
||||
"php-http/async-client-implementation": "^1.0",
|
||||
"php-http/client-common": "^2.4",
|
||||
"php-http/discovery": "^1.14",
|
||||
"php-http/httplug": "^2.2",
|
||||
"psr/http-client-implementation": "^1.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-factory-implementation": "^1.0",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8.0 || ^9.0",
|
||||
"friendsofphp/php-cs-fixer": "^2.12",
|
||||
"guzzlehttp/guzzle": "^7.0",
|
||||
"php-http/guzzle7-adapter": "^1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "OpenAPI\\Client\\" : "lib/" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "OpenAPI\\Client\\Test\\" : "test/" }
|
||||
}
|
||||
}
|
4983
samples/client/petstore/php/psr-18/composer.lock
generated
Normal file
4983
samples/client/petstore/php/psr-18/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,64 @@
|
||||
# OpenAPI\Client\AnotherFakeApi
|
||||
|
||||
All URIs are relative to http://petstore.swagger.io:80/v2.
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**call123TestSpecialTags()**](AnotherFakeApi.md#call123TestSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
|
||||
|
||||
## `call123TestSpecialTags()`
|
||||
|
||||
```php
|
||||
call123TestSpecialTags($client): \OpenAPI\Client\Model\Client
|
||||
```
|
||||
|
||||
To test special tags
|
||||
|
||||
To test special tags and operation ID starting with number
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\AnotherFakeApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model
|
||||
|
||||
try {
|
||||
$result = $apiInstance->call123TestSpecialTags($client);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling AnotherFakeApi->call123TestSpecialTags: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**client** | [**\OpenAPI\Client\Model\Client**](../Model/Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\Client**](../Model/Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`
|
||||
- **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)
|
59
samples/client/petstore/php/psr-18/docs/Api/DefaultApi.md
Normal file
59
samples/client/petstore/php/psr-18/docs/Api/DefaultApi.md
Normal file
@ -0,0 +1,59 @@
|
||||
# OpenAPI\Client\DefaultApi
|
||||
|
||||
All URIs are relative to http://petstore.swagger.io:80/v2.
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**fooGet()**](DefaultApi.md#fooGet) | **GET** /foo |
|
||||
|
||||
|
||||
## `fooGet()`
|
||||
|
||||
```php
|
||||
fooGet(): \OpenAPI\Client\Model\FooGetDefaultResponse
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 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 `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
|
||||
try {
|
||||
$result = $apiInstance->fooGet();
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling DefaultApi->fooGet: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\FooGetDefaultResponse**](../Model/FooGetDefaultResponse.md)
|
||||
|
||||
### 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)
|
1159
samples/client/petstore/php/psr-18/docs/Api/FakeApi.md
Normal file
1159
samples/client/petstore/php/psr-18/docs/Api/FakeApi.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,70 @@
|
||||
# OpenAPI\Client\FakeClassnameTags123Api
|
||||
|
||||
All URIs are relative to http://petstore.swagger.io:80/v2.
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**testClassname()**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
|
||||
|
||||
## `testClassname()`
|
||||
|
||||
```php
|
||||
testClassname($client): \OpenAPI\Client\Model\Client
|
||||
```
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
To test class name in snake case
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure API key authorization: api_key_query
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key_query', 'YOUR_API_KEY');
|
||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\FakeClassnameTags123Api(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model
|
||||
|
||||
try {
|
||||
$result = $apiInstance->testClassname($client);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeClassnameTags123Api->testClassname: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**client** | [**\OpenAPI\Client\Model\Client**](../Model/Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\Client**](../Model/Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key_query](../../README.md#api_key_query)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`
|
||||
- **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)
|
568
samples/client/petstore/php/psr-18/docs/Api/PetApi.md
Normal file
568
samples/client/petstore/php/psr-18/docs/Api/PetApi.md
Normal file
@ -0,0 +1,568 @@
|
||||
# OpenAPI\Client\PetApi
|
||||
|
||||
All URIs are relative to http://petstore.swagger.io:80/v2.
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**addPet()**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
|
||||
[**deletePet()**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
[**findPetsByStatus()**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
[**findPetsByTags()**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
[**getPetById()**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||
[**updatePet()**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
|
||||
[**updatePetWithForm()**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
[**uploadFile()**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
[**uploadFileWithRequiredFile()**](PetApi.md#uploadFileWithRequiredFile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
|
||||
|
||||
## `addPet()`
|
||||
|
||||
```php
|
||||
addPet($pet)
|
||||
```
|
||||
|
||||
Add a new pet to the store
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
$apiInstance->addPet($pet);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`, `application/xml`
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `deletePet()`
|
||||
|
||||
```php
|
||||
deletePet($pet_id, $api_key)
|
||||
```
|
||||
|
||||
Deletes a pet
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 56; // int | Pet id to delete
|
||||
$api_key = 'api_key_example'; // string
|
||||
|
||||
try {
|
||||
$apiInstance->deletePet($pet_id, $api_key);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->deletePet: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **int**| Pet id to delete |
|
||||
**api_key** | **string**| | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `findPetsByStatus()`
|
||||
|
||||
```php
|
||||
findPetsByStatus($status): \OpenAPI\Client\Model\Pet[]
|
||||
```
|
||||
|
||||
Finds Pets by status
|
||||
|
||||
Multiple status values can be provided with comma separated strings
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$status = array('status_example'); // string[] | Status values that need to be considered for filter
|
||||
|
||||
try {
|
||||
$result = $apiInstance->findPetsByStatus($status);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->findPetsByStatus: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**status** | [**string[]**](../Model/string.md)| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\Pet[]**](../Model/Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: `application/xml`, `application/json`
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `findPetsByTags()`
|
||||
|
||||
```php
|
||||
findPetsByTags($tags): \OpenAPI\Client\Model\Pet[]
|
||||
```
|
||||
|
||||
Finds Pets by tags
|
||||
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$tags = array('tags_example'); // string[] | Tags to filter by
|
||||
|
||||
try {
|
||||
$result = $apiInstance->findPetsByTags($tags);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->findPetsByTags: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**tags** | [**string[]**](../Model/string.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\Pet[]**](../Model/Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: `application/xml`, `application/json`
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `getPetById()`
|
||||
|
||||
```php
|
||||
getPetById($pet_id): \OpenAPI\Client\Model\Pet
|
||||
```
|
||||
|
||||
Find pet by ID
|
||||
|
||||
Returns a single pet
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure API key authorization: api_key
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
|
||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 56; // int | ID of pet to return
|
||||
|
||||
try {
|
||||
$result = $apiInstance->getPetById($pet_id);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->getPetById: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **int**| ID of pet to return |
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: `application/xml`, `application/json`
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `updatePet()`
|
||||
|
||||
```php
|
||||
updatePet($pet)
|
||||
```
|
||||
|
||||
Update an existing pet
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet = new \OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
$apiInstance->updatePet($pet);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->updatePet: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet** | [**\OpenAPI\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`, `application/xml`
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `updatePetWithForm()`
|
||||
|
||||
```php
|
||||
updatePetWithForm($pet_id, $name, $status)
|
||||
```
|
||||
|
||||
Updates a pet in the store with form data
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 56; // int | ID of pet that needs to be updated
|
||||
$name = 'name_example'; // string | Updated name of the pet
|
||||
$status = 'status_example'; // string | Updated status of the pet
|
||||
|
||||
try {
|
||||
$apiInstance->updatePetWithForm($pet_id, $name, $status);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->updatePetWithForm: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **int**| ID of pet that needs to be updated |
|
||||
**name** | **string**| Updated name of the pet | [optional]
|
||||
**status** | **string**| Updated status of the pet | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/x-www-form-urlencoded`
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `uploadFile()`
|
||||
|
||||
```php
|
||||
uploadFile($pet_id, $additional_metadata, $file): \OpenAPI\Client\Model\ApiResponse
|
||||
```
|
||||
|
||||
uploads an image
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 56; // int | ID of pet to update
|
||||
$additional_metadata = 'additional_metadata_example'; // string | Additional data to pass to server
|
||||
$file = "/path/to/file.txt"; // \SplFileObject | file to upload
|
||||
|
||||
try {
|
||||
$result = $apiInstance->uploadFile($pet_id, $additional_metadata, $file);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->uploadFile: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **int**| ID of pet to update |
|
||||
**additional_metadata** | **string**| Additional data to pass to server | [optional]
|
||||
**file** | **\SplFileObject****\SplFileObject**| file to upload | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\ApiResponse**](../Model/ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `multipart/form-data`
|
||||
- **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)
|
||||
|
||||
## `uploadFileWithRequiredFile()`
|
||||
|
||||
```php
|
||||
uploadFileWithRequiredFile($pet_id, $required_file, $additional_metadata): \OpenAPI\Client\Model\ApiResponse
|
||||
```
|
||||
|
||||
uploads an image (required)
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 56; // int | ID of pet to update
|
||||
$required_file = "/path/to/file.txt"; // \SplFileObject | file to upload
|
||||
$additional_metadata = 'additional_metadata_example'; // string | Additional data to pass to server
|
||||
|
||||
try {
|
||||
$result = $apiInstance->uploadFileWithRequiredFile($pet_id, $required_file, $additional_metadata);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->uploadFileWithRequiredFile: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**pet_id** | **int**| ID of pet to update |
|
||||
**required_file** | **\SplFileObject****\SplFileObject**| file to upload |
|
||||
**additional_metadata** | **string**| Additional data to pass to server | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\ApiResponse**](../Model/ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `multipart/form-data`
|
||||
- **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)
|
237
samples/client/petstore/php/psr-18/docs/Api/StoreApi.md
Normal file
237
samples/client/petstore/php/psr-18/docs/Api/StoreApi.md
Normal file
@ -0,0 +1,237 @@
|
||||
# OpenAPI\Client\StoreApi
|
||||
|
||||
All URIs are relative to http://petstore.swagger.io:80/v2.
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**deleteOrder()**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
[**getInventory()**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
[**getOrderById()**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
[**placeOrder()**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
|
||||
|
||||
|
||||
## `deleteOrder()`
|
||||
|
||||
```php
|
||||
deleteOrder($order_id)
|
||||
```
|
||||
|
||||
Delete purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\StoreApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$order_id = 'order_id_example'; // string | ID of the order that needs to be deleted
|
||||
|
||||
try {
|
||||
$apiInstance->deleteOrder($order_id);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling StoreApi->deleteOrder: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**order_id** | **string**| ID of the order that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `getInventory()`
|
||||
|
||||
```php
|
||||
getInventory(): array<string,int>
|
||||
```
|
||||
|
||||
Returns pet inventories by status
|
||||
|
||||
Returns a map of status codes to quantities
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
// Configure API key authorization: api_key
|
||||
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
|
||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\StoreApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
|
||||
try {
|
||||
$result = $apiInstance->getInventory();
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling StoreApi->getInventory: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**array<string,int>**
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../../README.md#api_key)
|
||||
|
||||
### 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)
|
||||
|
||||
## `getOrderById()`
|
||||
|
||||
```php
|
||||
getOrderById($order_id): \OpenAPI\Client\Model\Order
|
||||
```
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\StoreApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$order_id = 56; // int | ID of pet that needs to be fetched
|
||||
|
||||
try {
|
||||
$result = $apiInstance->getOrderById($order_id);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling StoreApi->getOrderById: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**order_id** | **int**| ID of pet that needs to be fetched |
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\Order**](../Model/Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: `application/xml`, `application/json`
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `placeOrder()`
|
||||
|
||||
```php
|
||||
placeOrder($order): \OpenAPI\Client\Model\Order
|
||||
```
|
||||
|
||||
Place an order for a pet
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\StoreApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$order = new \OpenAPI\Client\Model\Order(); // \OpenAPI\Client\Model\Order | order placed for purchasing the pet
|
||||
|
||||
try {
|
||||
$result = $apiInstance->placeOrder($order);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling StoreApi->placeOrder: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**order** | [**\OpenAPI\Client\Model\Order**](../Model/Order.md)| order placed for purchasing the pet |
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\Order**](../Model/Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`
|
||||
- **Accept**: `application/xml`, `application/json`
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
458
samples/client/petstore/php/psr-18/docs/Api/UserApi.md
Normal file
458
samples/client/petstore/php/psr-18/docs/Api/UserApi.md
Normal file
@ -0,0 +1,458 @@
|
||||
# OpenAPI\Client\UserApi
|
||||
|
||||
All URIs are relative to http://petstore.swagger.io:80/v2.
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**createUser()**](UserApi.md#createUser) | **POST** /user | Create user
|
||||
[**createUsersWithArrayInput()**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
[**createUsersWithListInput()**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
[**deleteUser()**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user
|
||||
[**getUserByName()**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name
|
||||
[**loginUser()**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system
|
||||
[**logoutUser()**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||
[**updateUser()**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## `createUser()`
|
||||
|
||||
```php
|
||||
createUser($user)
|
||||
```
|
||||
|
||||
Create user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$user = new \OpenAPI\Client\Model\User(); // \OpenAPI\Client\Model\User | Created user object
|
||||
|
||||
try {
|
||||
$apiInstance->createUser($user);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->createUser: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**user** | [**\OpenAPI\Client\Model\User**](../Model/User.md)| Created user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `createUsersWithArrayInput()`
|
||||
|
||||
```php
|
||||
createUsersWithArrayInput($user)
|
||||
```
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$user = array(new \OpenAPI\Client\Model\User()); // \OpenAPI\Client\Model\User[] | List of user object
|
||||
|
||||
try {
|
||||
$apiInstance->createUsersWithArrayInput($user);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->createUsersWithArrayInput: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**user** | [**\OpenAPI\Client\Model\User[]**](../Model/User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `createUsersWithListInput()`
|
||||
|
||||
```php
|
||||
createUsersWithListInput($user)
|
||||
```
|
||||
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$user = array(new \OpenAPI\Client\Model\User()); // \OpenAPI\Client\Model\User[] | List of user object
|
||||
|
||||
try {
|
||||
$apiInstance->createUsersWithListInput($user);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->createUsersWithListInput: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**user** | [**\OpenAPI\Client\Model\User[]**](../Model/User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `deleteUser()`
|
||||
|
||||
```php
|
||||
deleteUser($username)
|
||||
```
|
||||
|
||||
Delete user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$username = 'username_example'; // string | The name that needs to be deleted
|
||||
|
||||
try {
|
||||
$apiInstance->deleteUser($username);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->deleteUser: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **string**| The name that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `getUserByName()`
|
||||
|
||||
```php
|
||||
getUserByName($username): \OpenAPI\Client\Model\User
|
||||
```
|
||||
|
||||
Get user by user name
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$username = 'username_example'; // string | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
try {
|
||||
$result = $apiInstance->getUserByName($username);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->getUserByName: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **string**| The name that needs to be fetched. Use user1 for testing. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**\OpenAPI\Client\Model\User**](../Model/User.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: `application/xml`, `application/json`
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `loginUser()`
|
||||
|
||||
```php
|
||||
loginUser($username, $password): string
|
||||
```
|
||||
|
||||
Logs user into the system
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$username = 'username_example'; // string | The user name for login
|
||||
$password = 'password_example'; // string | The password for login in clear text
|
||||
|
||||
try {
|
||||
$result = $apiInstance->loginUser($username, $password);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->loginUser: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **string**| The user name for login |
|
||||
**password** | **string**| The password for login in clear text |
|
||||
|
||||
### Return type
|
||||
|
||||
**string**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: `application/xml`, `application/json`
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `logoutUser()`
|
||||
|
||||
```php
|
||||
logoutUser()
|
||||
```
|
||||
|
||||
Logs out current logged in user session
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
|
||||
try {
|
||||
$apiInstance->logoutUser();
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->logoutUser: ', $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**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
||||
|
||||
## `updateUser()`
|
||||
|
||||
```php
|
||||
updateUser($username, $user)
|
||||
```
|
||||
|
||||
Updated user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
|
||||
|
||||
$apiInstance = new OpenAPI\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `Psr\Http\Client\ClientInterface`.
|
||||
// This is optional, `Psr18ClientDiscovery` will be used to find http client. For instance `GuzzleHttp\Client` implements that interface
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$username = 'username_example'; // string | name that need to be deleted
|
||||
$user = new \OpenAPI\Client\Model\User(); // \OpenAPI\Client\Model\User | Updated user object
|
||||
|
||||
try {
|
||||
$apiInstance->updateUser($username, $user);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->updateUser: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**username** | **string**| name that need to be deleted |
|
||||
**user** | [**\OpenAPI\Client\Model\User**](../Model/User.md)| Updated user object |
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: `application/json`
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
|
||||
[[Back to Model list]](../../README.md#models)
|
||||
[[Back to README]](../../README.md)
|
@ -0,0 +1,10 @@
|
||||
# # AdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**map_property** | **array<string,string>** | | [optional]
|
||||
**map_of_map_property** | **array<string,array<string,string>>** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,10 @@
|
||||
# # AllOfWithSingleRef
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**username** | **string** | | [optional]
|
||||
**single_ref_type** | [**\OpenAPI\Client\Model\SingleRefType**](SingleRefType.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
10
samples/client/petstore/php/psr-18/docs/Model/Animal.md
Normal file
10
samples/client/petstore/php/psr-18/docs/Model/Animal.md
Normal file
@ -0,0 +1,10 @@
|
||||
# # Animal
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**class_name** | **string** | |
|
||||
**color** | **string** | | [optional] [default to 'red']
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
11
samples/client/petstore/php/psr-18/docs/Model/ApiResponse.md
Normal file
11
samples/client/petstore/php/psr-18/docs/Model/ApiResponse.md
Normal file
@ -0,0 +1,11 @@
|
||||
# # ApiResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **int** | | [optional]
|
||||
**type** | **string** | | [optional]
|
||||
**message** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_array_number** | **float[][]** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # ArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_number** | **float[]** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
11
samples/client/petstore/php/psr-18/docs/Model/ArrayTest.md
Normal file
11
samples/client/petstore/php/psr-18/docs/Model/ArrayTest.md
Normal file
@ -0,0 +1,11 @@
|
||||
# # ArrayTest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_of_string** | **string[]** | | [optional]
|
||||
**array_array_of_integer** | **int[][]** | | [optional]
|
||||
**array_array_of_model** | **\OpenAPI\Client\Model\ReadOnlyFirst[][]** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,14 @@
|
||||
# # Capitalization
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**small_camel** | **string** | | [optional]
|
||||
**capital_camel** | **string** | | [optional]
|
||||
**small_snake** | **string** | | [optional]
|
||||
**capital_snake** | **string** | | [optional]
|
||||
**sca_eth_flow_points** | **string** | | [optional]
|
||||
**att_name** | **string** | Name of the pet | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
9
samples/client/petstore/php/psr-18/docs/Model/Cat.md
Normal file
9
samples/client/petstore/php/psr-18/docs/Model/Cat.md
Normal file
@ -0,0 +1,9 @@
|
||||
# # Cat
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**declawed** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
10
samples/client/petstore/php/psr-18/docs/Model/Category.md
Normal file
10
samples/client/petstore/php/psr-18/docs/Model/Category.md
Normal file
@ -0,0 +1,10 @@
|
||||
# # Category
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**name** | **string** | | [default to 'default-name']
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # ClassModel
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**_class** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
9
samples/client/petstore/php/psr-18/docs/Model/Client.md
Normal file
9
samples/client/petstore/php/psr-18/docs/Model/Client.md
Normal file
@ -0,0 +1,9 @@
|
||||
# # Client
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**client** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # DeprecatedObject
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
9
samples/client/petstore/php/psr-18/docs/Model/Dog.md
Normal file
9
samples/client/petstore/php/psr-18/docs/Model/Dog.md
Normal file
@ -0,0 +1,9 @@
|
||||
# # Dog
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**breed** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
10
samples/client/petstore/php/psr-18/docs/Model/EnumArrays.md
Normal file
10
samples/client/petstore/php/psr-18/docs/Model/EnumArrays.md
Normal file
@ -0,0 +1,10 @@
|
||||
# # EnumArrays
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**just_symbol** | **string** | | [optional]
|
||||
**array_enum** | **string[]** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,8 @@
|
||||
# # EnumClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
16
samples/client/petstore/php/psr-18/docs/Model/EnumTest.md
Normal file
16
samples/client/petstore/php/psr-18/docs/Model/EnumTest.md
Normal file
@ -0,0 +1,16 @@
|
||||
# # EnumTest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**enum_string** | **string** | | [optional]
|
||||
**enum_string_required** | **string** | |
|
||||
**enum_integer** | **int** | | [optional]
|
||||
**enum_number** | **float** | | [optional]
|
||||
**outer_enum** | [**\OpenAPI\Client\Model\OuterEnum**](OuterEnum.md) | | [optional]
|
||||
**outer_enum_integer** | [**\OpenAPI\Client\Model\OuterEnumInteger**](OuterEnumInteger.md) | | [optional]
|
||||
**outer_enum_default_value** | [**\OpenAPI\Client\Model\OuterEnumDefaultValue**](OuterEnumDefaultValue.md) | | [optional]
|
||||
**outer_enum_integer_default_value** | [**\OpenAPI\Client\Model\OuterEnumIntegerDefaultValue**](OuterEnumIntegerDefaultValue.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,10 @@
|
||||
# # FakeBigDecimalMap200Response
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**some_id** | **float** | | [optional]
|
||||
**some_map** | **array<string,float>** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
9
samples/client/petstore/php/psr-18/docs/Model/File.md
Normal file
9
samples/client/petstore/php/psr-18/docs/Model/File.md
Normal file
@ -0,0 +1,9 @@
|
||||
# # File
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**source_uri** | **string** | Test capitalization | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,10 @@
|
||||
# # FileSchemaTestClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**file** | [**\OpenAPI\Client\Model\File**](File.md) | | [optional]
|
||||
**files** | [**\OpenAPI\Client\Model\File[]**](File.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
9
samples/client/petstore/php/psr-18/docs/Model/Foo.md
Normal file
9
samples/client/petstore/php/psr-18/docs/Model/Foo.md
Normal file
@ -0,0 +1,9 @@
|
||||
# # Foo
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **string** | | [optional] [default to 'bar']
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # FooGetDefaultResponse
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**string** | [**\OpenAPI\Client\Model\Foo**](Foo.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
24
samples/client/petstore/php/psr-18/docs/Model/FormatTest.md
Normal file
24
samples/client/petstore/php/psr-18/docs/Model/FormatTest.md
Normal file
@ -0,0 +1,24 @@
|
||||
# # FormatTest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**integer** | **int** | | [optional]
|
||||
**int32** | **int** | | [optional]
|
||||
**int64** | **int** | | [optional]
|
||||
**number** | **float** | |
|
||||
**float** | **float** | | [optional]
|
||||
**double** | **float** | | [optional]
|
||||
**decimal** | **float** | | [optional]
|
||||
**string** | **string** | | [optional]
|
||||
**byte** | **string** | |
|
||||
**binary** | **\SplFileObject** | | [optional]
|
||||
**date** | **\DateTime** | |
|
||||
**date_time** | **\DateTime** | | [optional]
|
||||
**uuid** | **string** | | [optional]
|
||||
**password** | **string** | |
|
||||
**pattern_with_digits** | **string** | A string that is a 10 digit number. Can have leading zeros. | [optional]
|
||||
**pattern_with_digits_and_delimiter** | **string** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,10 @@
|
||||
# # HasOnlyReadOnly
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **string** | | [optional] [readonly]
|
||||
**foo** | **string** | | [optional] [readonly]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # HealthCheckResult
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**nullable_message** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
12
samples/client/petstore/php/psr-18/docs/Model/MapTest.md
Normal file
12
samples/client/petstore/php/psr-18/docs/Model/MapTest.md
Normal file
@ -0,0 +1,12 @@
|
||||
# # MapTest
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**map_map_of_string** | **array<string,array<string,string>>** | | [optional]
|
||||
**map_of_enum_string** | **array<string,string>** | | [optional]
|
||||
**direct_map** | **array<string,bool>** | | [optional]
|
||||
**indirect_map** | **array<string,bool>** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,11 @@
|
||||
# # MixedPropertiesAndAdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**uuid** | **string** | | [optional]
|
||||
**date_time** | **\DateTime** | | [optional]
|
||||
**map** | [**array<string,\OpenAPI\Client\Model\Animal>**](Animal.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,10 @@
|
||||
# # Model200Response
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **int** | | [optional]
|
||||
**class** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # ModelList
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**_123_list** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # ModelReturn
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**return** | **int** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
12
samples/client/petstore/php/psr-18/docs/Model/Name.md
Normal file
12
samples/client/petstore/php/psr-18/docs/Model/Name.md
Normal file
@ -0,0 +1,12 @@
|
||||
# # Name
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **int** | |
|
||||
**snake_case** | **int** | | [optional] [readonly]
|
||||
**property** | **string** | | [optional]
|
||||
**_123_number** | **int** | | [optional] [readonly]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,20 @@
|
||||
# # NullableClass
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**integer_prop** | **int** | | [optional]
|
||||
**number_prop** | **float** | | [optional]
|
||||
**boolean_prop** | **bool** | | [optional]
|
||||
**string_prop** | **string** | | [optional]
|
||||
**date_prop** | **\DateTime** | | [optional]
|
||||
**datetime_prop** | **\DateTime** | | [optional]
|
||||
**array_nullable_prop** | **object[]** | | [optional]
|
||||
**array_and_items_nullable_prop** | **object[]** | | [optional]
|
||||
**array_items_nullable** | **object[]** | | [optional]
|
||||
**object_nullable_prop** | **array<string,object>** | | [optional]
|
||||
**object_and_items_nullable_prop** | **array<string,object>** | | [optional]
|
||||
**object_items_nullable** | **array<string,object>** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # NumberOnly
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**just_number** | **float** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,12 @@
|
||||
# # ObjectWithDeprecatedFields
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**uuid** | **string** | | [optional]
|
||||
**id** | **float** | | [optional]
|
||||
**deprecated_ref** | [**\OpenAPI\Client\Model\DeprecatedObject**](DeprecatedObject.md) | | [optional]
|
||||
**bars** | **string[]** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
14
samples/client/petstore/php/psr-18/docs/Model/Order.md
Normal file
14
samples/client/petstore/php/psr-18/docs/Model/Order.md
Normal file
@ -0,0 +1,14 @@
|
||||
# # Order
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**pet_id** | **int** | | [optional]
|
||||
**quantity** | **int** | | [optional]
|
||||
**ship_date** | **\DateTime** | | [optional]
|
||||
**status** | **string** | Order Status | [optional]
|
||||
**complete** | **bool** | | [optional] [default to false]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,11 @@
|
||||
# # OuterComposite
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**my_number** | **float** | | [optional]
|
||||
**my_string** | **string** | | [optional]
|
||||
**my_boolean** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,8 @@
|
||||
# # OuterEnum
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,8 @@
|
||||
# # OuterEnumDefaultValue
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,8 @@
|
||||
# # OuterEnumInteger
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,8 @@
|
||||
# # OuterEnumIntegerDefaultValue
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # OuterObjectWithEnumProperty
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**value** | [**\OpenAPI\Client\Model\OuterEnumInteger**](OuterEnumInteger.md) | |
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
14
samples/client/petstore/php/psr-18/docs/Model/Pet.md
Normal file
14
samples/client/petstore/php/psr-18/docs/Model/Pet.md
Normal file
@ -0,0 +1,14 @@
|
||||
# # Pet
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**category** | [**\OpenAPI\Client\Model\Category**](Category.md) | | [optional]
|
||||
**name** | **string** | |
|
||||
**photo_urls** | **string[]** | |
|
||||
**tags** | [**\OpenAPI\Client\Model\Tag[]**](Tag.md) | | [optional]
|
||||
**status** | **string** | pet status in the store | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,12 @@
|
||||
# # PropertyNameMapping
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**http_debug_operation** | **string** | | [optional]
|
||||
**underscore_type** | **string** | | [optional]
|
||||
**type** | **string** | | [optional]
|
||||
**type_with_underscore** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,10 @@
|
||||
# # ReadOnlyFirst
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**bar** | **string** | | [optional] [readonly]
|
||||
**baz** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,8 @@
|
||||
# # SingleRefType
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
@ -0,0 +1,9 @@
|
||||
# # SpecialModelName
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**special_property_name** | **int** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
10
samples/client/petstore/php/psr-18/docs/Model/Tag.md
Normal file
10
samples/client/petstore/php/psr-18/docs/Model/Tag.md
Normal file
@ -0,0 +1,10 @@
|
||||
# # Tag
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**name** | **string** | | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
16
samples/client/petstore/php/psr-18/docs/Model/User.md
Normal file
16
samples/client/petstore/php/psr-18/docs/Model/User.md
Normal file
@ -0,0 +1,16 @@
|
||||
# # User
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**username** | **string** | | [optional]
|
||||
**first_name** | **string** | | [optional]
|
||||
**last_name** | **string** | | [optional]
|
||||
**email** | **string** | | [optional]
|
||||
**password** | **string** | | [optional]
|
||||
**phone** | **string** | | [optional]
|
||||
**user_status** | **int** | User Status | [optional]
|
||||
|
||||
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
|
57
samples/client/petstore/php/psr-18/git_push.sh
Normal file
57
samples/client/petstore/php/psr-18/git_push.sh
Normal file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
498
samples/client/petstore/php/psr-18/lib/Api/AnotherFakeApi.php
Normal file
498
samples/client/petstore/php/psr-18/lib/Api/AnotherFakeApi.php
Normal file
@ -0,0 +1,498 @@
|
||||
<?php
|
||||
/**
|
||||
* AnotherFakeApi
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.0-SNAPSHOT
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace OpenAPI\Client\Api;
|
||||
|
||||
use GuzzleHttp\Psr7\MultipartStream;
|
||||
use GuzzleHttp\Psr7\Query;
|
||||
use Http\Client\Common\Plugin\ErrorPlugin;
|
||||
use Http\Client\Common\Plugin\RedirectPlugin;
|
||||
use Http\Client\Common\PluginClient;
|
||||
use Http\Client\Common\PluginClientFactory;
|
||||
use Http\Client\Exception\HttpException;
|
||||
use Http\Client\HttpAsyncClient;
|
||||
use Http\Discovery\HttpAsyncClientDiscovery;
|
||||
use Http\Discovery\Psr17FactoryDiscovery;
|
||||
use Http\Discovery\Psr18ClientDiscovery;
|
||||
use Http\Message\RequestFactory;
|
||||
use Http\Promise\Promise;
|
||||
use OpenAPI\Client\ApiException;
|
||||
use OpenAPI\Client\Configuration;
|
||||
use OpenAPI\Client\DebugPlugin;
|
||||
use OpenAPI\Client\HeaderSelector;
|
||||
use OpenAPI\Client\ObjectSerializer;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\UriFactoryInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* AnotherFakeApi Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class AnotherFakeApi
|
||||
{
|
||||
/**
|
||||
* @var PluginClient
|
||||
*/
|
||||
protected $httpClient;
|
||||
|
||||
/**
|
||||
* @var PluginClient
|
||||
*/
|
||||
protected $httpAsyncClient;
|
||||
|
||||
/**
|
||||
* @var UriFactoryInterface
|
||||
*/
|
||||
protected $uriFactory;
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var HeaderSelector
|
||||
*/
|
||||
protected $headerSelector;
|
||||
|
||||
/**
|
||||
* @var int Host index
|
||||
*/
|
||||
protected $hostIndex;
|
||||
|
||||
/**
|
||||
* @var RequestFactoryInterface
|
||||
*/
|
||||
protected $requestFactory;
|
||||
|
||||
/**
|
||||
* @var StreamFactoryInterface
|
||||
*/
|
||||
protected $streamFactory;
|
||||
|
||||
public function __construct(
|
||||
ClientInterface $httpClient = null,
|
||||
Configuration $config = null,
|
||||
HttpAsyncClient $httpAsyncClient = null,
|
||||
UriFactoryInterface $uriFactory = null,
|
||||
RequestFactoryInterface $requestFactory = null,
|
||||
StreamFactoryInterface $streamFactory = null,
|
||||
HeaderSelector $selector = null,
|
||||
?array $plugins = null,
|
||||
$hostIndex = 0
|
||||
) {
|
||||
$this->config = $config ?? (new Configuration())->setHost('http://petstore.swagger.io:80/v2');
|
||||
$this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
|
||||
$this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory();
|
||||
|
||||
$plugins = $plugins ?? [
|
||||
new RedirectPlugin(['strict' => true]),
|
||||
new ErrorPlugin(),
|
||||
];
|
||||
|
||||
if ($this->config->getDebug()) {
|
||||
$plugins[] = new DebugPlugin(fopen($this->config->getDebugFile(), 'ab'));
|
||||
}
|
||||
|
||||
$this->httpClient = (new PluginClientFactory())->createClient(
|
||||
$httpClient ?? Psr18ClientDiscovery::find(),
|
||||
$plugins
|
||||
);
|
||||
|
||||
$this->httpAsyncClient = (new PluginClientFactory())->createClient(
|
||||
$httpAsyncClient ?? HttpAsyncClientDiscovery::find(),
|
||||
$plugins
|
||||
);
|
||||
|
||||
$this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUriFactory();
|
||||
|
||||
$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 call123TestSpecialTags
|
||||
*
|
||||
* To test special tags
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \OpenAPI\Client\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return \OpenAPI\Client\Model\Client
|
||||
*/
|
||||
public function call123TestSpecialTags($client)
|
||||
{
|
||||
list($response) = $this->call123TestSpecialTagsWithHttpInfo($client);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation call123TestSpecialTagsWithHttpInfo
|
||||
*
|
||||
* To test special tags
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \OpenAPI\Client\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings)
|
||||
*/
|
||||
public function call123TestSpecialTagsWithHttpInfo($client)
|
||||
{
|
||||
$request = $this->call123TestSpecialTagsRequest($client);
|
||||
|
||||
try {
|
||||
try {
|
||||
$response = $this->httpClient->sendRequest($request);
|
||||
} catch (HttpException $e) {
|
||||
$response = $e->getResponse();
|
||||
throw new ApiException(
|
||||
sprintf(
|
||||
'[%d] Error connecting to the API (%s)',
|
||||
$response->getStatusCode(),
|
||||
(string) $request->getUri()
|
||||
),
|
||||
$request,
|
||||
$response,
|
||||
$e
|
||||
);
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
throw new ApiException(
|
||||
"[{$e->getCode()}] {$e->getMessage()}",
|
||||
$request,
|
||||
null,
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Client', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
}
|
||||
|
||||
$returnType = '\OpenAPI\Client\Model\Client';
|
||||
if ($returnType === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = ObjectSerializer::deserialize(
|
||||
$e->getResponseBody(),
|
||||
'\OpenAPI\Client\Model\Client',
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation call123TestSpecialTagsAsync
|
||||
*
|
||||
* To test special tags
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return Promise
|
||||
*/
|
||||
public function call123TestSpecialTagsAsync($client)
|
||||
{
|
||||
return $this->call123TestSpecialTagsAsyncWithHttpInfo($client)
|
||||
->then(
|
||||
function ($response) {
|
||||
return $response[0];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation call123TestSpecialTagsAsyncWithHttpInfo
|
||||
*
|
||||
* To test special tags
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return Promise
|
||||
*/
|
||||
public function call123TestSpecialTagsAsyncWithHttpInfo($client)
|
||||
{
|
||||
$returnType = '\OpenAPI\Client\Model\Client';
|
||||
$request = $this->call123TestSpecialTagsRequest($client);
|
||||
|
||||
return $this->httpAsyncClient->sendAsyncRequest($request)
|
||||
->then(
|
||||
function ($response) use ($returnType) {
|
||||
if ($returnType === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
},
|
||||
function (HttpException $exception) {
|
||||
$response = $exception->getResponse();
|
||||
$statusCode = $response->getStatusCode();
|
||||
throw new ApiException(
|
||||
sprintf(
|
||||
'[%d] Error connecting to the API (%s)',
|
||||
$statusCode,
|
||||
$exception->getRequest()->getUri()
|
||||
),
|
||||
$exception->getRequest(),
|
||||
$exception->getResponse(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create request for operation 'call123TestSpecialTags'
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function call123TestSpecialTagsRequest($client)
|
||||
{
|
||||
// verify the required parameter 'client' is set
|
||||
if ($client === null || (is_array($client) && count($client) === 0)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Missing the required parameter $client when calling call123TestSpecialTags'
|
||||
);
|
||||
}
|
||||
|
||||
$resourcePath = '/another-fake/dummy';
|
||||
$formParams = [];
|
||||
$queryParams = [];
|
||||
$headerParams = [];
|
||||
$httpBody = null;
|
||||
$multipart = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers = $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
['application/json']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($client)) {
|
||||
if ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($client));
|
||||
} else {
|
||||
$httpBody = $client;
|
||||
}
|
||||
} elseif (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 ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = json_encode($formParams);
|
||||
|
||||
} else {
|
||||
// for HTTP post (form)
|
||||
$httpBody = Query::build($formParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$defaultHeaders = [];
|
||||
if ($this->config->getUserAgent()) {
|
||||
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||||
}
|
||||
|
||||
$headers = array_merge(
|
||||
$defaultHeaders,
|
||||
$headerParams,
|
||||
$headers
|
||||
);
|
||||
|
||||
$operationHost = $this->config->getHost();
|
||||
|
||||
$uri = $this->createUri($operationHost, $resourcePath, $queryParams);
|
||||
|
||||
return $this->createRequest('PATCH', $uri, $headers, $httpBody);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string|UriInterface $uri
|
||||
* @param array $headers
|
||||
* @param string|StreamInterface|null $body
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
protected function createRequest(string $method, $uri, array $headers = [], $body = null): RequestInterface
|
||||
{
|
||||
if ($this->requestFactory instanceof RequestFactory) {
|
||||
return $this->requestFactory->createRequest(
|
||||
$method,
|
||||
$uri,
|
||||
$headers,
|
||||
$body
|
||||
);
|
||||
}
|
||||
|
||||
if (is_string($body) && '' !== $body && null === $this->streamFactory) {
|
||||
throw new \RuntimeException('Cannot create request: A stream factory is required to create a request with a non-empty string body.');
|
||||
}
|
||||
|
||||
$request = $this->requestFactory->createRequest($method, $uri);
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
$request = $request->withHeader($key, $value);
|
||||
}
|
||||
|
||||
if (null !== $body && '' !== $body) {
|
||||
$request = $request->withBody(
|
||||
is_string($body) ? $this->streamFactory->createStream($body) : $body
|
||||
);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
private function createUri(
|
||||
string $operationHost,
|
||||
string $resourcePath,
|
||||
array $queryParams
|
||||
): UriInterface {
|
||||
$parsedUrl = parse_url($operationHost);
|
||||
|
||||
$host = $parsedUrl['host'] ?? null;
|
||||
$scheme = $parsedUrl['scheme'] ?? null;
|
||||
$basePath = $parsedUrl['path'] ?? null;
|
||||
$port = $parsedUrl['port'] ?? null;
|
||||
$user = $parsedUrl['user'] ?? null;
|
||||
$password = $parsedUrl['pass'] ?? null;
|
||||
|
||||
$uri = $this->uriFactory->createUri($basePath . $resourcePath)
|
||||
->withHost($host)
|
||||
->withScheme($scheme)
|
||||
->withPort($port)
|
||||
->withQuery(Query::build($queryParams));
|
||||
|
||||
if ($user) {
|
||||
$uri = $uri->withUserInfo($user, $password);
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
}
|
473
samples/client/petstore/php/psr-18/lib/Api/DefaultApi.php
Normal file
473
samples/client/petstore/php/psr-18/lib/Api/DefaultApi.php
Normal file
@ -0,0 +1,473 @@
|
||||
<?php
|
||||
/**
|
||||
* DefaultApi
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.0-SNAPSHOT
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace OpenAPI\Client\Api;
|
||||
|
||||
use GuzzleHttp\Psr7\MultipartStream;
|
||||
use GuzzleHttp\Psr7\Query;
|
||||
use Http\Client\Common\Plugin\ErrorPlugin;
|
||||
use Http\Client\Common\Plugin\RedirectPlugin;
|
||||
use Http\Client\Common\PluginClient;
|
||||
use Http\Client\Common\PluginClientFactory;
|
||||
use Http\Client\Exception\HttpException;
|
||||
use Http\Client\HttpAsyncClient;
|
||||
use Http\Discovery\HttpAsyncClientDiscovery;
|
||||
use Http\Discovery\Psr17FactoryDiscovery;
|
||||
use Http\Discovery\Psr18ClientDiscovery;
|
||||
use Http\Message\RequestFactory;
|
||||
use Http\Promise\Promise;
|
||||
use OpenAPI\Client\ApiException;
|
||||
use OpenAPI\Client\Configuration;
|
||||
use OpenAPI\Client\DebugPlugin;
|
||||
use OpenAPI\Client\HeaderSelector;
|
||||
use OpenAPI\Client\ObjectSerializer;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\UriFactoryInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* DefaultApi Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class DefaultApi
|
||||
{
|
||||
/**
|
||||
* @var PluginClient
|
||||
*/
|
||||
protected $httpClient;
|
||||
|
||||
/**
|
||||
* @var PluginClient
|
||||
*/
|
||||
protected $httpAsyncClient;
|
||||
|
||||
/**
|
||||
* @var UriFactoryInterface
|
||||
*/
|
||||
protected $uriFactory;
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var HeaderSelector
|
||||
*/
|
||||
protected $headerSelector;
|
||||
|
||||
/**
|
||||
* @var int Host index
|
||||
*/
|
||||
protected $hostIndex;
|
||||
|
||||
/**
|
||||
* @var RequestFactoryInterface
|
||||
*/
|
||||
protected $requestFactory;
|
||||
|
||||
/**
|
||||
* @var StreamFactoryInterface
|
||||
*/
|
||||
protected $streamFactory;
|
||||
|
||||
public function __construct(
|
||||
ClientInterface $httpClient = null,
|
||||
Configuration $config = null,
|
||||
HttpAsyncClient $httpAsyncClient = null,
|
||||
UriFactoryInterface $uriFactory = null,
|
||||
RequestFactoryInterface $requestFactory = null,
|
||||
StreamFactoryInterface $streamFactory = null,
|
||||
HeaderSelector $selector = null,
|
||||
?array $plugins = null,
|
||||
$hostIndex = 0
|
||||
) {
|
||||
$this->config = $config ?? (new Configuration())->setHost('http://petstore.swagger.io:80/v2');
|
||||
$this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
|
||||
$this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory();
|
||||
|
||||
$plugins = $plugins ?? [
|
||||
new RedirectPlugin(['strict' => true]),
|
||||
new ErrorPlugin(),
|
||||
];
|
||||
|
||||
if ($this->config->getDebug()) {
|
||||
$plugins[] = new DebugPlugin(fopen($this->config->getDebugFile(), 'ab'));
|
||||
}
|
||||
|
||||
$this->httpClient = (new PluginClientFactory())->createClient(
|
||||
$httpClient ?? Psr18ClientDiscovery::find(),
|
||||
$plugins
|
||||
);
|
||||
|
||||
$this->httpAsyncClient = (new PluginClientFactory())->createClient(
|
||||
$httpAsyncClient ?? HttpAsyncClientDiscovery::find(),
|
||||
$plugins
|
||||
);
|
||||
|
||||
$this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUriFactory();
|
||||
|
||||
$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 fooGet
|
||||
*
|
||||
*
|
||||
* @throws \OpenAPI\Client\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return \OpenAPI\Client\Model\FooGetDefaultResponse
|
||||
*/
|
||||
public function fooGet()
|
||||
{
|
||||
list($response) = $this->fooGetWithHttpInfo();
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation fooGetWithHttpInfo
|
||||
*
|
||||
*
|
||||
* @throws \OpenAPI\Client\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return array of \OpenAPI\Client\Model\FooGetDefaultResponse, HTTP status code, HTTP response headers (array of strings)
|
||||
*/
|
||||
public function fooGetWithHttpInfo()
|
||||
{
|
||||
$request = $this->fooGetRequest();
|
||||
|
||||
try {
|
||||
try {
|
||||
$response = $this->httpClient->sendRequest($request);
|
||||
} catch (HttpException $e) {
|
||||
$response = $e->getResponse();
|
||||
throw new ApiException(
|
||||
sprintf(
|
||||
'[%d] Error connecting to the API (%s)',
|
||||
$response->getStatusCode(),
|
||||
(string) $request->getUri()
|
||||
),
|
||||
$request,
|
||||
$response,
|
||||
$e
|
||||
);
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
throw new ApiException(
|
||||
"[{$e->getCode()}] {$e->getMessage()}",
|
||||
$request,
|
||||
null,
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
switch($statusCode) {
|
||||
default:
|
||||
if ('\OpenAPI\Client\Model\FooGetDefaultResponse' === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\FooGetDefaultResponse', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
}
|
||||
|
||||
$returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse';
|
||||
if ($returnType === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
default:
|
||||
$data = ObjectSerializer::deserialize(
|
||||
$e->getResponseBody(),
|
||||
'\OpenAPI\Client\Model\FooGetDefaultResponse',
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation fooGetAsync
|
||||
*
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return Promise
|
||||
*/
|
||||
public function fooGetAsync()
|
||||
{
|
||||
return $this->fooGetAsyncWithHttpInfo()
|
||||
->then(
|
||||
function ($response) {
|
||||
return $response[0];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation fooGetAsyncWithHttpInfo
|
||||
*
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return Promise
|
||||
*/
|
||||
public function fooGetAsyncWithHttpInfo()
|
||||
{
|
||||
$returnType = '\OpenAPI\Client\Model\FooGetDefaultResponse';
|
||||
$request = $this->fooGetRequest();
|
||||
|
||||
return $this->httpAsyncClient->sendAsyncRequest($request)
|
||||
->then(
|
||||
function ($response) use ($returnType) {
|
||||
if ($returnType === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
},
|
||||
function (HttpException $exception) {
|
||||
$response = $exception->getResponse();
|
||||
$statusCode = $response->getStatusCode();
|
||||
throw new ApiException(
|
||||
sprintf(
|
||||
'[%d] Error connecting to the API (%s)',
|
||||
$statusCode,
|
||||
$exception->getRequest()->getUri()
|
||||
),
|
||||
$exception->getRequest(),
|
||||
$exception->getResponse(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create request for operation 'fooGet'
|
||||
*
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function fooGetRequest()
|
||||
{
|
||||
|
||||
$resourcePath = '/foo';
|
||||
$formParams = [];
|
||||
$queryParams = [];
|
||||
$headerParams = [];
|
||||
$httpBody = null;
|
||||
$multipart = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers = $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
// 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 ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = json_encode($formParams);
|
||||
|
||||
} else {
|
||||
// for HTTP post (form)
|
||||
$httpBody = Query::build($formParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$defaultHeaders = [];
|
||||
if ($this->config->getUserAgent()) {
|
||||
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||||
}
|
||||
|
||||
$headers = array_merge(
|
||||
$defaultHeaders,
|
||||
$headerParams,
|
||||
$headers
|
||||
);
|
||||
|
||||
$operationHost = $this->config->getHost();
|
||||
|
||||
$uri = $this->createUri($operationHost, $resourcePath, $queryParams);
|
||||
|
||||
return $this->createRequest('GET', $uri, $headers, $httpBody);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string|UriInterface $uri
|
||||
* @param array $headers
|
||||
* @param string|StreamInterface|null $body
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
protected function createRequest(string $method, $uri, array $headers = [], $body = null): RequestInterface
|
||||
{
|
||||
if ($this->requestFactory instanceof RequestFactory) {
|
||||
return $this->requestFactory->createRequest(
|
||||
$method,
|
||||
$uri,
|
||||
$headers,
|
||||
$body
|
||||
);
|
||||
}
|
||||
|
||||
if (is_string($body) && '' !== $body && null === $this->streamFactory) {
|
||||
throw new \RuntimeException('Cannot create request: A stream factory is required to create a request with a non-empty string body.');
|
||||
}
|
||||
|
||||
$request = $this->requestFactory->createRequest($method, $uri);
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
$request = $request->withHeader($key, $value);
|
||||
}
|
||||
|
||||
if (null !== $body && '' !== $body) {
|
||||
$request = $request->withBody(
|
||||
is_string($body) ? $this->streamFactory->createStream($body) : $body
|
||||
);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
private function createUri(
|
||||
string $operationHost,
|
||||
string $resourcePath,
|
||||
array $queryParams
|
||||
): UriInterface {
|
||||
$parsedUrl = parse_url($operationHost);
|
||||
|
||||
$host = $parsedUrl['host'] ?? null;
|
||||
$scheme = $parsedUrl['scheme'] ?? null;
|
||||
$basePath = $parsedUrl['path'] ?? null;
|
||||
$port = $parsedUrl['port'] ?? null;
|
||||
$user = $parsedUrl['user'] ?? null;
|
||||
$password = $parsedUrl['pass'] ?? null;
|
||||
|
||||
$uri = $this->uriFactory->createUri($basePath . $resourcePath)
|
||||
->withHost($host)
|
||||
->withScheme($scheme)
|
||||
->withPort($port)
|
||||
->withQuery(Query::build($queryParams));
|
||||
|
||||
if ($user) {
|
||||
$uri = $uri->withUserInfo($user, $password);
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
}
|
5137
samples/client/petstore/php/psr-18/lib/Api/FakeApi.php
Normal file
5137
samples/client/petstore/php/psr-18/lib/Api/FakeApi.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,503 @@
|
||||
<?php
|
||||
/**
|
||||
* FakeClassnameTags123Api
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.0-SNAPSHOT
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace OpenAPI\Client\Api;
|
||||
|
||||
use GuzzleHttp\Psr7\MultipartStream;
|
||||
use GuzzleHttp\Psr7\Query;
|
||||
use Http\Client\Common\Plugin\ErrorPlugin;
|
||||
use Http\Client\Common\Plugin\RedirectPlugin;
|
||||
use Http\Client\Common\PluginClient;
|
||||
use Http\Client\Common\PluginClientFactory;
|
||||
use Http\Client\Exception\HttpException;
|
||||
use Http\Client\HttpAsyncClient;
|
||||
use Http\Discovery\HttpAsyncClientDiscovery;
|
||||
use Http\Discovery\Psr17FactoryDiscovery;
|
||||
use Http\Discovery\Psr18ClientDiscovery;
|
||||
use Http\Message\RequestFactory;
|
||||
use Http\Promise\Promise;
|
||||
use OpenAPI\Client\ApiException;
|
||||
use OpenAPI\Client\Configuration;
|
||||
use OpenAPI\Client\DebugPlugin;
|
||||
use OpenAPI\Client\HeaderSelector;
|
||||
use OpenAPI\Client\ObjectSerializer;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\UriFactoryInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* FakeClassnameTags123Api Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class FakeClassnameTags123Api
|
||||
{
|
||||
/**
|
||||
* @var PluginClient
|
||||
*/
|
||||
protected $httpClient;
|
||||
|
||||
/**
|
||||
* @var PluginClient
|
||||
*/
|
||||
protected $httpAsyncClient;
|
||||
|
||||
/**
|
||||
* @var UriFactoryInterface
|
||||
*/
|
||||
protected $uriFactory;
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var HeaderSelector
|
||||
*/
|
||||
protected $headerSelector;
|
||||
|
||||
/**
|
||||
* @var int Host index
|
||||
*/
|
||||
protected $hostIndex;
|
||||
|
||||
/**
|
||||
* @var RequestFactoryInterface
|
||||
*/
|
||||
protected $requestFactory;
|
||||
|
||||
/**
|
||||
* @var StreamFactoryInterface
|
||||
*/
|
||||
protected $streamFactory;
|
||||
|
||||
public function __construct(
|
||||
ClientInterface $httpClient = null,
|
||||
Configuration $config = null,
|
||||
HttpAsyncClient $httpAsyncClient = null,
|
||||
UriFactoryInterface $uriFactory = null,
|
||||
RequestFactoryInterface $requestFactory = null,
|
||||
StreamFactoryInterface $streamFactory = null,
|
||||
HeaderSelector $selector = null,
|
||||
?array $plugins = null,
|
||||
$hostIndex = 0
|
||||
) {
|
||||
$this->config = $config ?? (new Configuration())->setHost('http://petstore.swagger.io:80/v2');
|
||||
$this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
|
||||
$this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory();
|
||||
|
||||
$plugins = $plugins ?? [
|
||||
new RedirectPlugin(['strict' => true]),
|
||||
new ErrorPlugin(),
|
||||
];
|
||||
|
||||
if ($this->config->getDebug()) {
|
||||
$plugins[] = new DebugPlugin(fopen($this->config->getDebugFile(), 'ab'));
|
||||
}
|
||||
|
||||
$this->httpClient = (new PluginClientFactory())->createClient(
|
||||
$httpClient ?? Psr18ClientDiscovery::find(),
|
||||
$plugins
|
||||
);
|
||||
|
||||
$this->httpAsyncClient = (new PluginClientFactory())->createClient(
|
||||
$httpAsyncClient ?? HttpAsyncClientDiscovery::find(),
|
||||
$plugins
|
||||
);
|
||||
|
||||
$this->uriFactory = $uriFactory ?? Psr17FactoryDiscovery::findUriFactory();
|
||||
|
||||
$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 testClassname
|
||||
*
|
||||
* To test class name in snake case
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \OpenAPI\Client\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return \OpenAPI\Client\Model\Client
|
||||
*/
|
||||
public function testClassname($client)
|
||||
{
|
||||
list($response) = $this->testClassnameWithHttpInfo($client);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation testClassnameWithHttpInfo
|
||||
*
|
||||
* To test class name in snake case
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \OpenAPI\Client\ApiException on non-2xx response
|
||||
* @throws \InvalidArgumentException
|
||||
* @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings)
|
||||
*/
|
||||
public function testClassnameWithHttpInfo($client)
|
||||
{
|
||||
$request = $this->testClassnameRequest($client);
|
||||
|
||||
try {
|
||||
try {
|
||||
$response = $this->httpClient->sendRequest($request);
|
||||
} catch (HttpException $e) {
|
||||
$response = $e->getResponse();
|
||||
throw new ApiException(
|
||||
sprintf(
|
||||
'[%d] Error connecting to the API (%s)',
|
||||
$response->getStatusCode(),
|
||||
(string) $request->getUri()
|
||||
),
|
||||
$request,
|
||||
$response,
|
||||
$e
|
||||
);
|
||||
} catch (ClientExceptionInterface $e) {
|
||||
throw new ApiException(
|
||||
"[{$e->getCode()}] {$e->getMessage()}",
|
||||
$request,
|
||||
null,
|
||||
$e
|
||||
);
|
||||
}
|
||||
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
switch($statusCode) {
|
||||
case 200:
|
||||
if ('\OpenAPI\Client\Model\Client' === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\Client', []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
}
|
||||
|
||||
$returnType = '\OpenAPI\Client\Model\Client';
|
||||
if ($returnType === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = ObjectSerializer::deserialize(
|
||||
$e->getResponseBody(),
|
||||
'\OpenAPI\Client\Model\Client',
|
||||
$e->getResponseHeaders()
|
||||
);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation testClassnameAsync
|
||||
*
|
||||
* To test class name in snake case
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return Promise
|
||||
*/
|
||||
public function testClassnameAsync($client)
|
||||
{
|
||||
return $this->testClassnameAsyncWithHttpInfo($client)
|
||||
->then(
|
||||
function ($response) {
|
||||
return $response[0];
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operation testClassnameAsyncWithHttpInfo
|
||||
*
|
||||
* To test class name in snake case
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return Promise
|
||||
*/
|
||||
public function testClassnameAsyncWithHttpInfo($client)
|
||||
{
|
||||
$returnType = '\OpenAPI\Client\Model\Client';
|
||||
$request = $this->testClassnameRequest($client);
|
||||
|
||||
return $this->httpAsyncClient->sendAsyncRequest($request)
|
||||
->then(
|
||||
function ($response) use ($returnType) {
|
||||
if ($returnType === '\SplFileObject') {
|
||||
$content = $response->getBody(); //stream goes to serializer
|
||||
} else {
|
||||
$content = (string) $response->getBody();
|
||||
}
|
||||
|
||||
return [
|
||||
ObjectSerializer::deserialize($content, $returnType, []),
|
||||
$response->getStatusCode(),
|
||||
$response->getHeaders()
|
||||
];
|
||||
},
|
||||
function (HttpException $exception) {
|
||||
$response = $exception->getResponse();
|
||||
$statusCode = $response->getStatusCode();
|
||||
throw new ApiException(
|
||||
sprintf(
|
||||
'[%d] Error connecting to the API (%s)',
|
||||
$statusCode,
|
||||
$exception->getRequest()->getUri()
|
||||
),
|
||||
$exception->getRequest(),
|
||||
$exception->getResponse(),
|
||||
$exception
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create request for operation 'testClassname'
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\Client $client client model (required)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function testClassnameRequest($client)
|
||||
{
|
||||
// verify the required parameter 'client' is set
|
||||
if ($client === null || (is_array($client) && count($client) === 0)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Missing the required parameter $client when calling testClassname'
|
||||
);
|
||||
}
|
||||
|
||||
$resourcePath = '/fake_classname_test';
|
||||
$formParams = [];
|
||||
$queryParams = [];
|
||||
$headerParams = [];
|
||||
$httpBody = null;
|
||||
$multipart = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($multipart) {
|
||||
$headers = $this->headerSelector->selectHeadersForMultipart(
|
||||
['application/json']
|
||||
);
|
||||
} else {
|
||||
$headers = $this->headerSelector->selectHeaders(
|
||||
['application/json'],
|
||||
['application/json']
|
||||
);
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
if (isset($client)) {
|
||||
if ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($client));
|
||||
} else {
|
||||
$httpBody = $client;
|
||||
}
|
||||
} elseif (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 ($headers['Content-Type'] === 'application/json') {
|
||||
$httpBody = json_encode($formParams);
|
||||
|
||||
} else {
|
||||
// for HTTP post (form)
|
||||
$httpBody = Query::build($formParams);
|
||||
}
|
||||
}
|
||||
|
||||
// this endpoint requires API key authentication
|
||||
$apiKey = $this->config->getApiKeyWithPrefix('api_key_query');
|
||||
if ($apiKey !== null) {
|
||||
$queryParams['api_key_query'] = $apiKey;
|
||||
}
|
||||
|
||||
$defaultHeaders = [];
|
||||
if ($this->config->getUserAgent()) {
|
||||
$defaultHeaders['User-Agent'] = $this->config->getUserAgent();
|
||||
}
|
||||
|
||||
$headers = array_merge(
|
||||
$defaultHeaders,
|
||||
$headerParams,
|
||||
$headers
|
||||
);
|
||||
|
||||
$operationHost = $this->config->getHost();
|
||||
|
||||
$uri = $this->createUri($operationHost, $resourcePath, $queryParams);
|
||||
|
||||
return $this->createRequest('PATCH', $uri, $headers, $httpBody);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string|UriInterface $uri
|
||||
* @param array $headers
|
||||
* @param string|StreamInterface|null $body
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
protected function createRequest(string $method, $uri, array $headers = [], $body = null): RequestInterface
|
||||
{
|
||||
if ($this->requestFactory instanceof RequestFactory) {
|
||||
return $this->requestFactory->createRequest(
|
||||
$method,
|
||||
$uri,
|
||||
$headers,
|
||||
$body
|
||||
);
|
||||
}
|
||||
|
||||
if (is_string($body) && '' !== $body && null === $this->streamFactory) {
|
||||
throw new \RuntimeException('Cannot create request: A stream factory is required to create a request with a non-empty string body.');
|
||||
}
|
||||
|
||||
$request = $this->requestFactory->createRequest($method, $uri);
|
||||
|
||||
foreach ($headers as $key => $value) {
|
||||
$request = $request->withHeader($key, $value);
|
||||
}
|
||||
|
||||
if (null !== $body && '' !== $body) {
|
||||
$request = $request->withBody(
|
||||
is_string($body) ? $this->streamFactory->createStream($body) : $body
|
||||
);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
private function createUri(
|
||||
string $operationHost,
|
||||
string $resourcePath,
|
||||
array $queryParams
|
||||
): UriInterface {
|
||||
$parsedUrl = parse_url($operationHost);
|
||||
|
||||
$host = $parsedUrl['host'] ?? null;
|
||||
$scheme = $parsedUrl['scheme'] ?? null;
|
||||
$basePath = $parsedUrl['path'] ?? null;
|
||||
$port = $parsedUrl['port'] ?? null;
|
||||
$user = $parsedUrl['user'] ?? null;
|
||||
$password = $parsedUrl['pass'] ?? null;
|
||||
|
||||
$uri = $this->uriFactory->createUri($basePath . $resourcePath)
|
||||
->withHost($host)
|
||||
->withScheme($scheme)
|
||||
->withPort($port)
|
||||
->withQuery(Query::build($queryParams));
|
||||
|
||||
if ($user) {
|
||||
$uri = $uri->withUserInfo($user, $password);
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
}
|
2567
samples/client/petstore/php/psr-18/lib/Api/PetApi.php
Normal file
2567
samples/client/petstore/php/psr-18/lib/Api/PetApi.php
Normal file
File diff suppressed because it is too large
Load Diff
1223
samples/client/petstore/php/psr-18/lib/Api/StoreApi.php
Normal file
1223
samples/client/petstore/php/psr-18/lib/Api/StoreApi.php
Normal file
File diff suppressed because it is too large
Load Diff
2060
samples/client/petstore/php/psr-18/lib/Api/UserApi.php
Normal file
2060
samples/client/petstore/php/psr-18/lib/Api/UserApi.php
Normal file
File diff suppressed because it is too large
Load Diff
122
samples/client/petstore/php/psr-18/lib/ApiException.php
Normal file
122
samples/client/petstore/php/psr-18/lib/ApiException.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* ApiException
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.0-SNAPSHOT
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace OpenAPI\Client;
|
||||
|
||||
use Exception;
|
||||
use Http\Client\Exception\RequestException;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* ApiException Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class ApiException extends RequestException
|
||||
{
|
||||
|
||||
/**
|
||||
* The HTTP body of the server response either as Json or string.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $responseBody;
|
||||
|
||||
/**
|
||||
* The HTTP header of the server response.
|
||||
*
|
||||
* @var string[]|null
|
||||
*/
|
||||
protected $responseHeaders;
|
||||
|
||||
/**
|
||||
* The deserialized response object
|
||||
*
|
||||
* @var \stdClass|string|null
|
||||
*/
|
||||
protected $responseObject;
|
||||
|
||||
public function __construct(
|
||||
$message,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response = null,
|
||||
Exception $previous = null
|
||||
) {
|
||||
parent::__construct($message, $request, $previous);
|
||||
if ($response) {
|
||||
$this->responseHeaders = $response->getHeaders();
|
||||
$this->responseBody = (string) $response->getBody();
|
||||
$this->code = $response->getStatusCode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTTP response header
|
||||
*
|
||||
* @return string[]|null HTTP response header
|
||||
*/
|
||||
public function getResponseHeaders()
|
||||
{
|
||||
return $this->responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTTP body of the server response either as Json or string
|
||||
*
|
||||
* @return \stdClass|string|null HTTP body of the server response either as \stdClass or string
|
||||
*/
|
||||
public function getResponseBody()
|
||||
{
|
||||
return $this->responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the deseralized response object (during deserialization)
|
||||
*
|
||||
* @param mixed $obj Deserialized response object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setResponseObject($obj)
|
||||
{
|
||||
$this->responseObject = $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the deseralized response object (during deserialization)
|
||||
*
|
||||
* @return mixed the deserialized response object
|
||||
*/
|
||||
public function getResponseObject()
|
||||
{
|
||||
return $this->responseObject;
|
||||
}
|
||||
}
|
568
samples/client/petstore/php/psr-18/lib/Configuration.php
Normal file
568
samples/client/petstore/php/psr-18/lib/Configuration.php
Normal file
@ -0,0 +1,568 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuration
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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;
|
||||
|
||||
/**
|
||||
* Configuration Class Doc Comment
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class Configuration
|
||||
{
|
||||
public const BOOLEAN_FORMAT_INT = 'int';
|
||||
public const BOOLEAN_FORMAT_STRING = 'string';
|
||||
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private static $defaultConfiguration;
|
||||
|
||||
/**
|
||||
* Associate array to store API key(s)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $apiKeys = [];
|
||||
|
||||
/**
|
||||
* Associate array to store API prefix (e.g. Bearer)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $apiKeyPrefixes = [];
|
||||
|
||||
/**
|
||||
* Access token for OAuth/Bearer authentication
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $accessToken = '';
|
||||
|
||||
/**
|
||||
* Boolean format for query string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $booleanFormatForQueryString = self::BOOLEAN_FORMAT_INT;
|
||||
|
||||
/**
|
||||
* Username for HTTP basic authentication
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $username = '';
|
||||
|
||||
/**
|
||||
* Password for HTTP basic authentication
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $password = '';
|
||||
|
||||
/**
|
||||
* The host
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $host = 'http://petstore.swagger.io:80/v2';
|
||||
|
||||
/**
|
||||
* User agent of the HTTP request, set to "OpenAPI-Generator/{version}/PHP" by default
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $userAgent = 'OpenAPI-Generator/1.0.0/PHP';
|
||||
|
||||
/**
|
||||
* Debug switch (default set to false)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $debug = false;
|
||||
|
||||
/**
|
||||
* Debug file location (log to STDOUT by default)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $debugFile = 'php://output';
|
||||
|
||||
/**
|
||||
* Debug file location (log to STDOUT by default)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tempFolderPath;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->tempFolderPath = sys_get_temp_dir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets API key
|
||||
*
|
||||
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
||||
* @param string $key API key or token
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setApiKey($apiKeyIdentifier, $key)
|
||||
{
|
||||
$this->apiKeys[$apiKeyIdentifier] = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets API key
|
||||
*
|
||||
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
||||
*
|
||||
* @return null|string API key or token
|
||||
*/
|
||||
public function getApiKey($apiKeyIdentifier)
|
||||
{
|
||||
return isset($this->apiKeys[$apiKeyIdentifier]) ? $this->apiKeys[$apiKeyIdentifier] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the prefix for API key (e.g. Bearer)
|
||||
*
|
||||
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
||||
* @param string $prefix API key prefix, e.g. Bearer
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setApiKeyPrefix($apiKeyIdentifier, $prefix)
|
||||
{
|
||||
$this->apiKeyPrefixes[$apiKeyIdentifier] = $prefix;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets API key prefix
|
||||
*
|
||||
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getApiKeyPrefix($apiKeyIdentifier)
|
||||
{
|
||||
return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the access token for OAuth
|
||||
*
|
||||
* @param string $accessToken Token for OAuth
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccessToken($accessToken)
|
||||
{
|
||||
$this->accessToken = $accessToken;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the access token for OAuth
|
||||
*
|
||||
* @return string Access token for OAuth
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
return $this->accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets boolean format for query string.
|
||||
*
|
||||
* @param string $booleanFormatForQueryString Boolean format for query string
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBooleanFormatForQueryString(string $booleanFormat)
|
||||
{
|
||||
$this->booleanFormatForQueryString = $booleanFormat;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets boolean format for query string.
|
||||
*
|
||||
* @return string Boolean format for query string
|
||||
*/
|
||||
public function getBooleanFormatForQueryString(): string
|
||||
{
|
||||
return $this->booleanFormatForQueryString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username for HTTP basic authentication
|
||||
*
|
||||
* @param string $username Username for HTTP basic authentication
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
$this->username = $username;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username for HTTP basic authentication
|
||||
*
|
||||
* @return string Username for HTTP basic authentication
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password for HTTP basic authentication
|
||||
*
|
||||
* @param string $password Password for HTTP basic authentication
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the password for HTTP basic authentication
|
||||
*
|
||||
* @return string Password for HTTP basic authentication
|
||||
*/
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the host
|
||||
*
|
||||
* @param string $host Host
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHost($host)
|
||||
{
|
||||
$this->host = $host;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the host
|
||||
*
|
||||
* @return string Host
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user agent of the api client
|
||||
*
|
||||
* @param string $userAgent the user agent of the api client
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function setUserAgent($userAgent)
|
||||
{
|
||||
if (!is_string($userAgent)) {
|
||||
throw new \InvalidArgumentException('User-agent must be a string.');
|
||||
}
|
||||
|
||||
$this->userAgent = $userAgent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user agent of the api client
|
||||
*
|
||||
* @return string user agent
|
||||
*/
|
||||
public function getUserAgent()
|
||||
{
|
||||
return $this->userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets debug flag
|
||||
*
|
||||
* @param bool $debug Debug flag
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDebug($debug)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the debug flag
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getDebug()
|
||||
{
|
||||
return $this->debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug file
|
||||
*
|
||||
* @param string $debugFile Debug file
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDebugFile($debugFile)
|
||||
{
|
||||
$this->debugFile = $debugFile;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the debug file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDebugFile()
|
||||
{
|
||||
return $this->debugFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temp folder path
|
||||
*
|
||||
* @param string $tempFolderPath Temp folder path
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTempFolderPath($tempFolderPath)
|
||||
{
|
||||
$this->tempFolderPath = $tempFolderPath;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the temp folder path
|
||||
*
|
||||
* @return string Temp folder path
|
||||
*/
|
||||
public function getTempFolderPath()
|
||||
{
|
||||
return $this->tempFolderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default configuration instance
|
||||
*
|
||||
* @return Configuration
|
||||
*/
|
||||
public static function getDefaultConfiguration()
|
||||
{
|
||||
if (self::$defaultConfiguration === null) {
|
||||
self::$defaultConfiguration = new Configuration();
|
||||
}
|
||||
|
||||
return self::$defaultConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default configuration instance
|
||||
*
|
||||
* @param Configuration $config An instance of the Configuration Object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setDefaultConfiguration(Configuration $config)
|
||||
{
|
||||
self::$defaultConfiguration = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the essential information for debugging
|
||||
*
|
||||
* @return string The report for debugging
|
||||
*/
|
||||
public static function toDebugReport()
|
||||
{
|
||||
$report = 'PHP SDK (OpenAPI\Client) Debug Report:' . PHP_EOL;
|
||||
$report .= ' OS: ' . php_uname() . PHP_EOL;
|
||||
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
|
||||
$report .= ' The version of the OpenAPI document: 1.0.0' . PHP_EOL;
|
||||
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
|
||||
|
||||
return $report;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get API key (with prefix if set)
|
||||
*
|
||||
* @param string $apiKeyIdentifier name of apikey
|
||||
*
|
||||
* @return null|string API key with the prefix
|
||||
*/
|
||||
public function getApiKeyWithPrefix($apiKeyIdentifier)
|
||||
{
|
||||
$prefix = $this->getApiKeyPrefix($apiKeyIdentifier);
|
||||
$apiKey = $this->getApiKey($apiKeyIdentifier);
|
||||
|
||||
if ($apiKey === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($prefix === null) {
|
||||
$keyWithPrefix = $apiKey;
|
||||
} else {
|
||||
$keyWithPrefix = $prefix . ' ' . $apiKey;
|
||||
}
|
||||
|
||||
return $keyWithPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of host settings
|
||||
*
|
||||
* @return array an array of host settings
|
||||
*/
|
||||
public function getHostSettings()
|
||||
{
|
||||
return [
|
||||
[
|
||||
"url" => "http://{server}.swagger.io:{port}/v2",
|
||||
"description" => "petstore server",
|
||||
"variables" => [
|
||||
"server" => [
|
||||
"description" => "No description provided",
|
||||
"default_value" => "petstore",
|
||||
"enum_values" => [
|
||||
"petstore",
|
||||
"qa-petstore",
|
||||
"dev-petstore"
|
||||
]
|
||||
],
|
||||
"port" => [
|
||||
"description" => "No description provided",
|
||||
"default_value" => "80",
|
||||
"enum_values" => [
|
||||
"80",
|
||||
"8080"
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
"url" => "https://localhost:8080/{version}",
|
||||
"description" => "The local server",
|
||||
"variables" => [
|
||||
"version" => [
|
||||
"description" => "No description provided",
|
||||
"default_value" => "v2",
|
||||
"enum_values" => [
|
||||
"v1",
|
||||
"v2"
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
[
|
||||
"url" => "https://127.0.0.1/no_varaible",
|
||||
"description" => "The local server without variables",
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns URL based on host settings, index and variables
|
||||
*
|
||||
* @param array $hostSettings array of host settings, generated from getHostSettings() or equivalent from the API clients
|
||||
* @param int $hostIndex index of the host settings
|
||||
* @param array|null $variables hash of variable and the corresponding value (optional)
|
||||
* @return string URL based on host settings
|
||||
*/
|
||||
public static function getHostString(array $hostsSettings, $hostIndex, array $variables = null)
|
||||
{
|
||||
if (null === $variables) {
|
||||
$variables = [];
|
||||
}
|
||||
|
||||
// check array index out of bound
|
||||
if ($hostIndex < 0 || $hostIndex >= count($hostsSettings)) {
|
||||
throw new \InvalidArgumentException("Invalid index $hostIndex when selecting the host. Must be less than ".count($hostsSettings));
|
||||
}
|
||||
|
||||
$host = $hostsSettings[$hostIndex];
|
||||
$url = $host["url"];
|
||||
|
||||
// go through variable and assign a value
|
||||
foreach ($host["variables"] ?? [] as $name => $variable) {
|
||||
if (array_key_exists($name, $variables)) { // check to see if it's in the variables provided by the user
|
||||
if (!isset($variable['enum_values']) || in_array($variables[$name], $variable["enum_values"], true)) { // check to see if the value is in the enum
|
||||
$url = str_replace("{".$name."}", $variables[$name], $url);
|
||||
} else {
|
||||
throw new \InvalidArgumentException("The variable `$name` in the host URL has invalid value ".$variables[$name].". Must be ".join(',', $variable["enum_values"]).".");
|
||||
}
|
||||
} else {
|
||||
// use default value
|
||||
$url = str_replace("{".$name."}", $variable["default_value"], $url);
|
||||
}
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns URL based on the index and variables
|
||||
*
|
||||
* @param int $index index of the host settings
|
||||
* @param array|null $variables hash of variable and the corresponding value (optional)
|
||||
* @return string URL based on host settings
|
||||
*/
|
||||
public function getHostFromSettings($index, $variables = null)
|
||||
{
|
||||
return self::getHostString($this->getHostSettings(), $index, $variables);
|
||||
}
|
||||
}
|
101
samples/client/petstore/php/psr-18/lib/DebugPlugin.php
Normal file
101
samples/client/petstore/php/psr-18/lib/DebugPlugin.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* Configuration
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.0-SNAPSHOT
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace OpenAPI\Client;
|
||||
|
||||
use Http\Client\Common\Plugin;
|
||||
use Http\Promise\Promise;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use function is_resource;
|
||||
|
||||
/**
|
||||
* Configuration Class Doc Comment
|
||||
* PHP version 7.2
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class DebugPlugin implements Plugin
|
||||
{
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
*/
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* DebuggingPlugin constructor.
|
||||
*
|
||||
* @param resource $output
|
||||
*/
|
||||
public function __construct($output)
|
||||
{
|
||||
if (!is_resource($output)) {
|
||||
throw new \InvalidArgumentException('debugging resource is not valid');
|
||||
}
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise
|
||||
{
|
||||
return $next($request)->then(
|
||||
function (ResponseInterface $response) use ($request) {
|
||||
$this->logSuccess($request, $response);
|
||||
|
||||
return $response;
|
||||
},
|
||||
function (ClientExceptionInterface $exception) use ($request) {
|
||||
$this->logError($request, $exception);
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function logSuccess(RequestInterface $request, ResponseInterface $response): void
|
||||
{
|
||||
$methodAndPath = $request->getMethod() . ' ' . $request->getUri()->getPath();
|
||||
$protocol = $response->getProtocolVersion();
|
||||
$responseCode = $response->getStatusCode();
|
||||
\fprintf($this->output, '<%s HTTP/%s> %s', $methodAndPath, $protocol, $responseCode);
|
||||
\fwrite($this->output, "\n");
|
||||
}
|
||||
|
||||
private function logError(RequestInterface $request, ClientExceptionInterface $exception): void
|
||||
{
|
||||
$methodAndPath = $request->getMethod() . ' ' . $request->getUri()->getPath();
|
||||
$protocol = $request->getProtocolVersion();
|
||||
$error = $exception->getMessage();
|
||||
$responseCode = $exception->getCode();
|
||||
\fprintf($this->output, '<%s HTTP/%s> %s %s', $methodAndPath, $responseCode, $error, $protocol);
|
||||
\fwrite($this->output, "\n");
|
||||
}
|
||||
}
|
245
samples/client/petstore/php/psr-18/lib/HeaderSelector.php
Normal file
245
samples/client/petstore/php/psr-18/lib/HeaderSelector.php
Normal file
@ -0,0 +1,245 @@
|
||||
<?php
|
||||
/**
|
||||
* HeaderSelector
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.0-SNAPSHOT
|
||||
*/
|
||||
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
namespace OpenAPI\Client;
|
||||
|
||||
/**
|
||||
* HeaderSelector Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
*/
|
||||
class HeaderSelector
|
||||
{
|
||||
/**
|
||||
* @param string[] $accept
|
||||
* @param string $contentType
|
||||
* @param bool $isMultipart
|
||||
* @return string[]
|
||||
*/
|
||||
public function selectHeaders(array $accept, string $contentType, bool $isMultipart): array
|
||||
{
|
||||
$headers = [];
|
||||
|
||||
$accept = $this->selectAcceptHeader($accept);
|
||||
if ($accept !== null) {
|
||||
$headers['Accept'] = $accept;
|
||||
}
|
||||
|
||||
if (!$isMultipart) {
|
||||
if($contentType === '') {
|
||||
$contentType = 'application/json';
|
||||
}
|
||||
|
||||
$headers['Content-Type'] = $contentType;
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the header 'Accept' based on an array of Accept provided.
|
||||
*
|
||||
* @param string[] $accept Array of header
|
||||
*
|
||||
* @return null|string Accept (e.g. application/json)
|
||||
*/
|
||||
private function selectAcceptHeader(array $accept): ?string
|
||||
{
|
||||
# filter out empty entries
|
||||
$accept = array_filter($accept);
|
||||
|
||||
if (count($accept) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
# If there's only one Accept header, just use it
|
||||
if (count($accept) === 1) {
|
||||
return reset($accept);
|
||||
}
|
||||
|
||||
# If none of the available Accept headers is of type "json", then just use all them
|
||||
$headersWithJson = preg_grep('~(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$~', $accept);
|
||||
if (count($headersWithJson) === 0) {
|
||||
return implode(',', $accept);
|
||||
}
|
||||
|
||||
# If we got here, then we need add quality values (weight), as described in IETF RFC 9110, Items 12.4.2/12.5.1,
|
||||
# to give the highest priority to json-like headers - recalculating the existing ones, if needed
|
||||
return $this->getAcceptHeaderWithAdjustedWeight($accept, $headersWithJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Accept header string from the given "Accept" headers array, recalculating all weights
|
||||
*
|
||||
* @param string[] $accept Array of Accept Headers
|
||||
* @param string[] $headersWithJson Array of Accept Headers of type "json"
|
||||
*
|
||||
* @return string "Accept" Header (e.g. "application/json, text/html; q=0.9")
|
||||
*/
|
||||
private function getAcceptHeaderWithAdjustedWeight(array $accept, array $headersWithJson): string
|
||||
{
|
||||
$processedHeaders = [
|
||||
'withApplicationJson' => [],
|
||||
'withJson' => [],
|
||||
'withoutJson' => [],
|
||||
];
|
||||
|
||||
foreach ($accept as $header) {
|
||||
|
||||
$headerData = $this->getHeaderAndWeight($header);
|
||||
|
||||
if (stripos($headerData['header'], 'application/json') === 0) {
|
||||
$processedHeaders['withApplicationJson'][] = $headerData;
|
||||
} elseif (in_array($header, $headersWithJson, true)) {
|
||||
$processedHeaders['withJson'][] = $headerData;
|
||||
} else {
|
||||
$processedHeaders['withoutJson'][] = $headerData;
|
||||
}
|
||||
}
|
||||
|
||||
$acceptHeaders = [];
|
||||
$currentWeight = 1000;
|
||||
|
||||
$hasMoreThan28Headers = count($accept) > 28;
|
||||
|
||||
foreach($processedHeaders as $headers) {
|
||||
if (count($headers) > 0) {
|
||||
$acceptHeaders[] = $this->adjustWeight($headers, $currentWeight, $hasMoreThan28Headers);
|
||||
}
|
||||
}
|
||||
|
||||
$acceptHeaders = array_merge(...$acceptHeaders);
|
||||
|
||||
return implode(',', $acceptHeaders);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an Accept header, returns an associative array splitting the header and its weight
|
||||
*
|
||||
* @param string $header "Accept" Header
|
||||
*
|
||||
* @return array with the header and its weight
|
||||
*/
|
||||
private function getHeaderAndWeight(string $header): array
|
||||
{
|
||||
# matches headers with weight, splitting the header and the weight in $outputArray
|
||||
if (preg_match('/(.*);\s*q=(1(?:\.0+)?|0\.\d+)$/', $header, $outputArray) === 1) {
|
||||
$headerData = [
|
||||
'header' => $outputArray[1],
|
||||
'weight' => (int)($outputArray[2] * 1000),
|
||||
];
|
||||
} else {
|
||||
$headerData = [
|
||||
'header' => trim($header),
|
||||
'weight' => 1000,
|
||||
];
|
||||
}
|
||||
|
||||
return $headerData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array[] $headers
|
||||
* @param float $currentWeight
|
||||
* @param bool $hasMoreThan28Headers
|
||||
* @return string[] array of adjusted "Accept" headers
|
||||
*/
|
||||
private function adjustWeight(array $headers, float &$currentWeight, bool $hasMoreThan28Headers): array
|
||||
{
|
||||
usort($headers, function (array $a, array $b) {
|
||||
return $b['weight'] - $a['weight'];
|
||||
});
|
||||
|
||||
$acceptHeaders = [];
|
||||
foreach ($headers as $index => $header) {
|
||||
if($index > 0 && $headers[$index - 1]['weight'] > $header['weight'])
|
||||
{
|
||||
$currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers);
|
||||
}
|
||||
|
||||
$weight = $currentWeight;
|
||||
|
||||
$acceptHeaders[] = $this->buildAcceptHeader($header['header'], $weight);
|
||||
}
|
||||
|
||||
$currentWeight = $this->getNextWeight($currentWeight, $hasMoreThan28Headers);
|
||||
|
||||
return $acceptHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $header
|
||||
* @param int $weight
|
||||
* @return string
|
||||
*/
|
||||
private function buildAcceptHeader(string $header, int $weight): string
|
||||
{
|
||||
if($weight === 1000) {
|
||||
return $header;
|
||||
}
|
||||
|
||||
return trim($header, '; ') . ';q=' . rtrim(sprintf('%0.3f', $weight / 1000), '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the next weight, based on the current one.
|
||||
*
|
||||
* If there are less than 28 "Accept" headers, the weights will be decreased by 1 on its highest significant digit, using the
|
||||
* following formula:
|
||||
*
|
||||
* next weight = current weight - 10 ^ (floor(log(current weight - 1)))
|
||||
*
|
||||
* ( current weight minus ( 10 raised to the power of ( floor of (log to the base 10 of ( current weight minus 1 ) ) ) ) )
|
||||
*
|
||||
* Starting from 1000, this generates the following series:
|
||||
*
|
||||
* 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
|
||||
*
|
||||
* The resulting quality codes are closer to the average "normal" usage of them (like "q=0.9", "q=0.8" and so on), but it only works
|
||||
* if there is a maximum of 28 "Accept" headers. If we have more than that (which is extremely unlikely), then we fall back to a 1-by-1
|
||||
* decrement rule, which will result in quality codes like "q=0.999", "q=0.998" etc.
|
||||
*
|
||||
* @param int $currentWeight varying from 1 to 1000 (will be divided by 1000 to build the quality value)
|
||||
* @param bool $hasMoreThan28Headers
|
||||
* @return int
|
||||
*/
|
||||
public function getNextWeight(int $currentWeight, bool $hasMoreThan28Headers): int
|
||||
{
|
||||
if ($currentWeight <= 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ($hasMoreThan28Headers) {
|
||||
return $currentWeight - 1;
|
||||
}
|
||||
|
||||
return $currentWeight - 10 ** floor( log10($currentWeight - 1) );
|
||||
}
|
||||
}
|
@ -0,0 +1,443 @@
|
||||
<?php
|
||||
/**
|
||||
* AdditionalPropertiesClass
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* AdditionalPropertiesClass Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class AdditionalPropertiesClass implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'AdditionalPropertiesClass';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'map_property' => 'array<string,string>',
|
||||
'map_of_map_property' => 'array<string,array<string,string>>'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'map_property' => null,
|
||||
'map_of_map_property' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'map_property' => false,
|
||||
'map_of_map_property' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'map_property' => 'map_property',
|
||||
'map_of_map_property' => 'map_of_map_property'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'map_property' => 'setMapProperty',
|
||||
'map_of_map_property' => 'setMapOfMapProperty'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'map_property' => 'getMapProperty',
|
||||
'map_of_map_property' => 'getMapOfMapProperty'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('map_property', $data ?? [], null);
|
||||
$this->setIfExists('map_of_map_property', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets map_property
|
||||
*
|
||||
* @return array<string,string>|null
|
||||
*/
|
||||
public function getMapProperty()
|
||||
{
|
||||
return $this->container['map_property'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets map_property
|
||||
*
|
||||
* @param array<string,string>|null $map_property map_property
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMapProperty($map_property)
|
||||
{
|
||||
if (is_null($map_property)) {
|
||||
throw new \InvalidArgumentException('non-nullable map_property cannot be null');
|
||||
}
|
||||
$this->container['map_property'] = $map_property;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets map_of_map_property
|
||||
*
|
||||
* @return array<string,array<string,string>>|null
|
||||
*/
|
||||
public function getMapOfMapProperty()
|
||||
{
|
||||
return $this->container['map_of_map_property'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets map_of_map_property
|
||||
*
|
||||
* @param array<string,array<string,string>>|null $map_of_map_property map_of_map_property
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMapOfMapProperty($map_of_map_property)
|
||||
{
|
||||
if (is_null($map_of_map_property)) {
|
||||
throw new \InvalidArgumentException('non-nullable map_of_map_property cannot be null');
|
||||
}
|
||||
$this->container['map_of_map_property'] = $map_of_map_property;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,443 @@
|
||||
<?php
|
||||
/**
|
||||
* AllOfWithSingleRef
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* AllOfWithSingleRef Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class AllOfWithSingleRef implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'AllOfWithSingleRef';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'username' => 'string',
|
||||
'single_ref_type' => '\OpenAPI\Client\Model\SingleRefType'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'username' => null,
|
||||
'single_ref_type' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'username' => false,
|
||||
'single_ref_type' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'username' => 'username',
|
||||
'single_ref_type' => 'SingleRefType'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'username' => 'setUsername',
|
||||
'single_ref_type' => 'setSingleRefType'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'username' => 'getUsername',
|
||||
'single_ref_type' => 'getSingleRefType'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('username', $data ?? [], null);
|
||||
$this->setIfExists('single_ref_type', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets username
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUsername()
|
||||
{
|
||||
return $this->container['username'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets username
|
||||
*
|
||||
* @param string|null $username username
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
if (is_null($username)) {
|
||||
throw new \InvalidArgumentException('non-nullable username cannot be null');
|
||||
}
|
||||
$this->container['username'] = $username;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets single_ref_type
|
||||
*
|
||||
* @return \OpenAPI\Client\Model\SingleRefType|null
|
||||
*/
|
||||
public function getSingleRefType()
|
||||
{
|
||||
return $this->container['single_ref_type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets single_ref_type
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\SingleRefType|null $single_ref_type single_ref_type
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSingleRefType($single_ref_type)
|
||||
{
|
||||
if (is_null($single_ref_type)) {
|
||||
throw new \InvalidArgumentException('non-nullable single_ref_type cannot be null');
|
||||
}
|
||||
$this->container['single_ref_type'] = $single_ref_type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
449
samples/client/petstore/php/psr-18/lib/Model/Animal.php
Normal file
449
samples/client/petstore/php/psr-18/lib/Model/Animal.php
Normal file
@ -0,0 +1,449 @@
|
||||
<?php
|
||||
/**
|
||||
* Animal
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* Animal Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class Animal implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = 'class_name';
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'Animal';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'class_name' => 'string',
|
||||
'color' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'class_name' => null,
|
||||
'color' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'class_name' => false,
|
||||
'color' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'class_name' => 'className',
|
||||
'color' => 'color'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'class_name' => 'setClassName',
|
||||
'color' => 'setColor'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'class_name' => 'getClassName',
|
||||
'color' => 'getColor'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('class_name', $data ?? [], null);
|
||||
$this->setIfExists('color', $data ?? [], 'red');
|
||||
|
||||
// Initialize discriminator property with the model name.
|
||||
$this->container['class_name'] = static::$openAPIModelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
if ($this->container['class_name'] === null) {
|
||||
$invalidProperties[] = "'class_name' 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()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets class_name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName()
|
||||
{
|
||||
return $this->container['class_name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets class_name
|
||||
*
|
||||
* @param string $class_name class_name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setClassName($class_name)
|
||||
{
|
||||
if (is_null($class_name)) {
|
||||
throw new \InvalidArgumentException('non-nullable class_name cannot be null');
|
||||
}
|
||||
$this->container['class_name'] = $class_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets color
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getColor()
|
||||
{
|
||||
return $this->container['color'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets color
|
||||
*
|
||||
* @param string|null $color color
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setColor($color)
|
||||
{
|
||||
if (is_null($color)) {
|
||||
throw new \InvalidArgumentException('non-nullable color cannot be null');
|
||||
}
|
||||
$this->container['color'] = $color;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
477
samples/client/petstore/php/psr-18/lib/Model/ApiResponse.php
Normal file
477
samples/client/petstore/php/psr-18/lib/Model/ApiResponse.php
Normal file
@ -0,0 +1,477 @@
|
||||
<?php
|
||||
/**
|
||||
* ApiResponse
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* ApiResponse Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class ApiResponse implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'ApiResponse';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'code' => 'int',
|
||||
'type' => 'string',
|
||||
'message' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'code' => 'int32',
|
||||
'type' => null,
|
||||
'message' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'code' => false,
|
||||
'type' => false,
|
||||
'message' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'code' => 'code',
|
||||
'type' => 'type',
|
||||
'message' => 'message'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'code' => 'setCode',
|
||||
'type' => 'setType',
|
||||
'message' => 'setMessage'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'code' => 'getCode',
|
||||
'type' => 'getType',
|
||||
'message' => 'getMessage'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('code', $data ?? [], null);
|
||||
$this->setIfExists('type', $data ?? [], null);
|
||||
$this->setIfExists('message', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets code
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->container['code'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets code
|
||||
*
|
||||
* @param int|null $code code
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
if (is_null($code)) {
|
||||
throw new \InvalidArgumentException('non-nullable code cannot be null');
|
||||
}
|
||||
$this->container['code'] = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets type
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->container['type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets type
|
||||
*
|
||||
* @param string|null $type type
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
if (is_null($type)) {
|
||||
throw new \InvalidArgumentException('non-nullable type cannot be null');
|
||||
}
|
||||
$this->container['type'] = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets message
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
return $this->container['message'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets message
|
||||
*
|
||||
* @param string|null $message message
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMessage($message)
|
||||
{
|
||||
if (is_null($message)) {
|
||||
throw new \InvalidArgumentException('non-nullable message cannot be null');
|
||||
}
|
||||
$this->container['message'] = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,409 @@
|
||||
<?php
|
||||
/**
|
||||
* ArrayOfArrayOfNumberOnly
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* ArrayOfArrayOfNumberOnly Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class ArrayOfArrayOfNumberOnly implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'ArrayOfArrayOfNumberOnly';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'array_array_number' => 'float[][]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'array_array_number' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'array_array_number' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'array_array_number' => 'ArrayArrayNumber'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'array_array_number' => 'setArrayArrayNumber'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'array_array_number' => 'getArrayArrayNumber'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('array_array_number', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets array_array_number
|
||||
*
|
||||
* @return float[][]|null
|
||||
*/
|
||||
public function getArrayArrayNumber()
|
||||
{
|
||||
return $this->container['array_array_number'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets array_array_number
|
||||
*
|
||||
* @param float[][]|null $array_array_number array_array_number
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setArrayArrayNumber($array_array_number)
|
||||
{
|
||||
if (is_null($array_array_number)) {
|
||||
throw new \InvalidArgumentException('non-nullable array_array_number cannot be null');
|
||||
}
|
||||
$this->container['array_array_number'] = $array_array_number;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,409 @@
|
||||
<?php
|
||||
/**
|
||||
* ArrayOfNumberOnly
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* ArrayOfNumberOnly Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class ArrayOfNumberOnly implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'ArrayOfNumberOnly';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'array_number' => 'float[]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'array_number' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'array_number' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'array_number' => 'ArrayNumber'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'array_number' => 'setArrayNumber'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'array_number' => 'getArrayNumber'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('array_number', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets array_number
|
||||
*
|
||||
* @return float[]|null
|
||||
*/
|
||||
public function getArrayNumber()
|
||||
{
|
||||
return $this->container['array_number'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets array_number
|
||||
*
|
||||
* @param float[]|null $array_number array_number
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setArrayNumber($array_number)
|
||||
{
|
||||
if (is_null($array_number)) {
|
||||
throw new \InvalidArgumentException('non-nullable array_number cannot be null');
|
||||
}
|
||||
$this->container['array_number'] = $array_number;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
492
samples/client/petstore/php/psr-18/lib/Model/ArrayTest.php
Normal file
492
samples/client/petstore/php/psr-18/lib/Model/ArrayTest.php
Normal file
@ -0,0 +1,492 @@
|
||||
<?php
|
||||
/**
|
||||
* ArrayTest
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* ArrayTest Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class ArrayTest implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'ArrayTest';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'array_of_string' => 'string[]',
|
||||
'array_array_of_integer' => 'int[][]',
|
||||
'array_array_of_model' => '\OpenAPI\Client\Model\ReadOnlyFirst[][]'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'array_of_string' => null,
|
||||
'array_array_of_integer' => 'int64',
|
||||
'array_array_of_model' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'array_of_string' => false,
|
||||
'array_array_of_integer' => false,
|
||||
'array_array_of_model' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'array_of_string' => 'array_of_string',
|
||||
'array_array_of_integer' => 'array_array_of_integer',
|
||||
'array_array_of_model' => 'array_array_of_model'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'array_of_string' => 'setArrayOfString',
|
||||
'array_array_of_integer' => 'setArrayArrayOfInteger',
|
||||
'array_array_of_model' => 'setArrayArrayOfModel'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'array_of_string' => 'getArrayOfString',
|
||||
'array_array_of_integer' => 'getArrayArrayOfInteger',
|
||||
'array_array_of_model' => 'getArrayArrayOfModel'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('array_of_string', $data ?? [], null);
|
||||
$this->setIfExists('array_array_of_integer', $data ?? [], null);
|
||||
$this->setIfExists('array_array_of_model', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
if (!is_null($this->container['array_of_string']) && (count($this->container['array_of_string']) > 3)) {
|
||||
$invalidProperties[] = "invalid value for 'array_of_string', number of items must be less than or equal to 3.";
|
||||
}
|
||||
|
||||
if (!is_null($this->container['array_of_string']) && (count($this->container['array_of_string']) < 0)) {
|
||||
$invalidProperties[] = "invalid value for 'array_of_string', number of items must be greater than or equal to 0.";
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets array_of_string
|
||||
*
|
||||
* @return string[]|null
|
||||
*/
|
||||
public function getArrayOfString()
|
||||
{
|
||||
return $this->container['array_of_string'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets array_of_string
|
||||
*
|
||||
* @param string[]|null $array_of_string array_of_string
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setArrayOfString($array_of_string)
|
||||
{
|
||||
if (is_null($array_of_string)) {
|
||||
throw new \InvalidArgumentException('non-nullable array_of_string cannot be null');
|
||||
}
|
||||
|
||||
if ((count($array_of_string) > 3)) {
|
||||
throw new \InvalidArgumentException('invalid value for $array_of_string when calling ArrayTest., number of items must be less than or equal to 3.');
|
||||
}
|
||||
if ((count($array_of_string) < 0)) {
|
||||
throw new \InvalidArgumentException('invalid length for $array_of_string when calling ArrayTest., number of items must be greater than or equal to 0.');
|
||||
}
|
||||
$this->container['array_of_string'] = $array_of_string;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets array_array_of_integer
|
||||
*
|
||||
* @return int[][]|null
|
||||
*/
|
||||
public function getArrayArrayOfInteger()
|
||||
{
|
||||
return $this->container['array_array_of_integer'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets array_array_of_integer
|
||||
*
|
||||
* @param int[][]|null $array_array_of_integer array_array_of_integer
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setArrayArrayOfInteger($array_array_of_integer)
|
||||
{
|
||||
if (is_null($array_array_of_integer)) {
|
||||
throw new \InvalidArgumentException('non-nullable array_array_of_integer cannot be null');
|
||||
}
|
||||
$this->container['array_array_of_integer'] = $array_array_of_integer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets array_array_of_model
|
||||
*
|
||||
* @return \OpenAPI\Client\Model\ReadOnlyFirst[][]|null
|
||||
*/
|
||||
public function getArrayArrayOfModel()
|
||||
{
|
||||
return $this->container['array_array_of_model'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets array_array_of_model
|
||||
*
|
||||
* @param \OpenAPI\Client\Model\ReadOnlyFirst[][]|null $array_array_of_model array_array_of_model
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setArrayArrayOfModel($array_array_of_model)
|
||||
{
|
||||
if (is_null($array_array_of_model)) {
|
||||
throw new \InvalidArgumentException('non-nullable array_array_of_model cannot be null');
|
||||
}
|
||||
$this->container['array_array_of_model'] = $array_array_of_model;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
579
samples/client/petstore/php/psr-18/lib/Model/Capitalization.php
Normal file
579
samples/client/petstore/php/psr-18/lib/Model/Capitalization.php
Normal file
@ -0,0 +1,579 @@
|
||||
<?php
|
||||
/**
|
||||
* Capitalization
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* Capitalization Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class Capitalization implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'Capitalization';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'small_camel' => 'string',
|
||||
'capital_camel' => 'string',
|
||||
'small_snake' => 'string',
|
||||
'capital_snake' => 'string',
|
||||
'sca_eth_flow_points' => 'string',
|
||||
'att_name' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'small_camel' => null,
|
||||
'capital_camel' => null,
|
||||
'small_snake' => null,
|
||||
'capital_snake' => null,
|
||||
'sca_eth_flow_points' => null,
|
||||
'att_name' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'small_camel' => false,
|
||||
'capital_camel' => false,
|
||||
'small_snake' => false,
|
||||
'capital_snake' => false,
|
||||
'sca_eth_flow_points' => false,
|
||||
'att_name' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'small_camel' => 'smallCamel',
|
||||
'capital_camel' => 'CapitalCamel',
|
||||
'small_snake' => 'small_Snake',
|
||||
'capital_snake' => 'Capital_Snake',
|
||||
'sca_eth_flow_points' => 'SCA_ETH_Flow_Points',
|
||||
'att_name' => 'ATT_NAME'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'small_camel' => 'setSmallCamel',
|
||||
'capital_camel' => 'setCapitalCamel',
|
||||
'small_snake' => 'setSmallSnake',
|
||||
'capital_snake' => 'setCapitalSnake',
|
||||
'sca_eth_flow_points' => 'setScaEthFlowPoints',
|
||||
'att_name' => 'setAttName'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'small_camel' => 'getSmallCamel',
|
||||
'capital_camel' => 'getCapitalCamel',
|
||||
'small_snake' => 'getSmallSnake',
|
||||
'capital_snake' => 'getCapitalSnake',
|
||||
'sca_eth_flow_points' => 'getScaEthFlowPoints',
|
||||
'att_name' => 'getAttName'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('small_camel', $data ?? [], null);
|
||||
$this->setIfExists('capital_camel', $data ?? [], null);
|
||||
$this->setIfExists('small_snake', $data ?? [], null);
|
||||
$this->setIfExists('capital_snake', $data ?? [], null);
|
||||
$this->setIfExists('sca_eth_flow_points', $data ?? [], null);
|
||||
$this->setIfExists('att_name', $data ?? [], null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
|
||||
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
|
||||
* $this->openAPINullablesSetToNull array
|
||||
*
|
||||
* @param string $variableName
|
||||
* @param array $fields
|
||||
* @param mixed $defaultValue
|
||||
*/
|
||||
private function setIfExists(string $variableName, array $fields, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets small_camel
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSmallCamel()
|
||||
{
|
||||
return $this->container['small_camel'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets small_camel
|
||||
*
|
||||
* @param string|null $small_camel small_camel
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSmallCamel($small_camel)
|
||||
{
|
||||
if (is_null($small_camel)) {
|
||||
throw new \InvalidArgumentException('non-nullable small_camel cannot be null');
|
||||
}
|
||||
$this->container['small_camel'] = $small_camel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets capital_camel
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCapitalCamel()
|
||||
{
|
||||
return $this->container['capital_camel'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets capital_camel
|
||||
*
|
||||
* @param string|null $capital_camel capital_camel
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setCapitalCamel($capital_camel)
|
||||
{
|
||||
if (is_null($capital_camel)) {
|
||||
throw new \InvalidArgumentException('non-nullable capital_camel cannot be null');
|
||||
}
|
||||
$this->container['capital_camel'] = $capital_camel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets small_snake
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSmallSnake()
|
||||
{
|
||||
return $this->container['small_snake'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets small_snake
|
||||
*
|
||||
* @param string|null $small_snake small_snake
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSmallSnake($small_snake)
|
||||
{
|
||||
if (is_null($small_snake)) {
|
||||
throw new \InvalidArgumentException('non-nullable small_snake cannot be null');
|
||||
}
|
||||
$this->container['small_snake'] = $small_snake;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets capital_snake
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCapitalSnake()
|
||||
{
|
||||
return $this->container['capital_snake'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets capital_snake
|
||||
*
|
||||
* @param string|null $capital_snake capital_snake
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setCapitalSnake($capital_snake)
|
||||
{
|
||||
if (is_null($capital_snake)) {
|
||||
throw new \InvalidArgumentException('non-nullable capital_snake cannot be null');
|
||||
}
|
||||
$this->container['capital_snake'] = $capital_snake;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets sca_eth_flow_points
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getScaEthFlowPoints()
|
||||
{
|
||||
return $this->container['sca_eth_flow_points'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets sca_eth_flow_points
|
||||
*
|
||||
* @param string|null $sca_eth_flow_points sca_eth_flow_points
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setScaEthFlowPoints($sca_eth_flow_points)
|
||||
{
|
||||
if (is_null($sca_eth_flow_points)) {
|
||||
throw new \InvalidArgumentException('non-nullable sca_eth_flow_points cannot be null');
|
||||
}
|
||||
$this->container['sca_eth_flow_points'] = $sca_eth_flow_points;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets att_name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAttName()
|
||||
{
|
||||
return $this->container['att_name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets att_name
|
||||
*
|
||||
* @param string|null $att_name Name of the pet
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setAttName($att_name)
|
||||
{
|
||||
if (is_null($att_name)) {
|
||||
throw new \InvalidArgumentException('non-nullable att_name cannot be null');
|
||||
}
|
||||
$this->container['att_name'] = $att_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
403
samples/client/petstore/php/psr-18/lib/Model/Cat.php
Normal file
403
samples/client/petstore/php/psr-18/lib/Model/Cat.php
Normal file
@ -0,0 +1,403 @@
|
||||
<?php
|
||||
/**
|
||||
* Cat
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* Cat Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class Cat extends Animal
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'Cat';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'declawed' => 'bool'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'declawed' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'declawed' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes + parent::openAPITypes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats + parent::openAPIFormats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables + parent::openAPINullables();
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'declawed' => 'declawed'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'declawed' => 'setDeclawed'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'declawed' => 'getDeclawed'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return parent::attributeMap() + self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return parent::setters() + self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return parent::getters() + self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
$this->setIfExists('declawed', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = parent::listInvalidProperties();
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets declawed
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public function getDeclawed()
|
||||
{
|
||||
return $this->container['declawed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets declawed
|
||||
*
|
||||
* @param bool|null $declawed declawed
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setDeclawed($declawed)
|
||||
{
|
||||
if (is_null($declawed)) {
|
||||
throw new \InvalidArgumentException('non-nullable declawed cannot be null');
|
||||
}
|
||||
$this->container['declawed'] = $declawed;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
446
samples/client/petstore/php/psr-18/lib/Model/Category.php
Normal file
446
samples/client/petstore/php/psr-18/lib/Model/Category.php
Normal file
@ -0,0 +1,446 @@
|
||||
<?php
|
||||
/**
|
||||
* Category
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* Category Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class Category implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'Category';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'id' => 'int',
|
||||
'name' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'id' => 'int64',
|
||||
'name' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'id' => false,
|
||||
'name' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'id' => 'setId',
|
||||
'name' => 'setName'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'id' => 'getId',
|
||||
'name' => 'getName'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('id', $data ?? [], null);
|
||||
$this->setIfExists('name', $data ?? [], 'default-name');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
if ($this->container['name'] === null) {
|
||||
$invalidProperties[] = "'name' 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()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets id
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->container['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets id
|
||||
*
|
||||
* @param int|null $id id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
if (is_null($id)) {
|
||||
throw new \InvalidArgumentException('non-nullable id cannot be null');
|
||||
}
|
||||
$this->container['id'] = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->container['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets name
|
||||
*
|
||||
* @param string $name name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
throw new \InvalidArgumentException('non-nullable name cannot be null');
|
||||
}
|
||||
$this->container['name'] = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
410
samples/client/petstore/php/psr-18/lib/Model/ClassModel.php
Normal file
410
samples/client/petstore/php/psr-18/lib/Model/ClassModel.php
Normal file
@ -0,0 +1,410 @@
|
||||
<?php
|
||||
/**
|
||||
* ClassModel
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* ClassModel Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @description Model for testing model with \"_class\" property
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class ClassModel implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'ClassModel';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'_class' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'_class' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'_class' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'_class' => '_class'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'_class' => 'setClass'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'_class' => 'getClass'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('_class', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets _class
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
return $this->container['_class'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets _class
|
||||
*
|
||||
* @param string|null $_class _class
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setClass($_class)
|
||||
{
|
||||
if (is_null($_class)) {
|
||||
throw new \InvalidArgumentException('non-nullable _class cannot be null');
|
||||
}
|
||||
$this->container['_class'] = $_class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
409
samples/client/petstore/php/psr-18/lib/Model/Client.php
Normal file
409
samples/client/petstore/php/psr-18/lib/Model/Client.php
Normal file
@ -0,0 +1,409 @@
|
||||
<?php
|
||||
/**
|
||||
* Client
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* Client Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class Client implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'Client';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'client' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'client' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'client' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'client' => 'client'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'client' => 'setClient'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'client' => 'getClient'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('client', $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, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets client
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getClient()
|
||||
{
|
||||
return $this->container['client'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets client
|
||||
*
|
||||
* @param string|null $client client
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setClient($client)
|
||||
{
|
||||
if (is_null($client)) {
|
||||
throw new \InvalidArgumentException('non-nullable client cannot be null');
|
||||
}
|
||||
$this->container['client'] = $client;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,409 @@
|
||||
<?php
|
||||
/**
|
||||
* DeprecatedObject
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Class
|
||||
* @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 by: https://openapi-generator.tech
|
||||
* OpenAPI Generator version: 7.0.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 \OpenAPI\Client\ObjectSerializer;
|
||||
|
||||
/**
|
||||
* DeprecatedObject Class Doc Comment
|
||||
*
|
||||
* @category Class
|
||||
* @package OpenAPI\Client
|
||||
* @author OpenAPI Generator team
|
||||
* @link https://openapi-generator.tech
|
||||
* @implements \ArrayAccess<string, mixed>
|
||||
*/
|
||||
class DeprecatedObject implements ModelInterface, ArrayAccess, \JsonSerializable
|
||||
{
|
||||
public const DISCRIMINATOR = null;
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $openAPIModelName = 'DeprecatedObject';
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $openAPITypes = [
|
||||
'name' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string|null>
|
||||
* @psalm-var array<string, string|null>
|
||||
*/
|
||||
protected static $openAPIFormats = [
|
||||
'name' => null
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of nullable properties. Used for (de)serialization
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected static array $openAPINullables = [
|
||||
'name' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* If a nullable field gets set to null, insert it here
|
||||
*
|
||||
* @var boolean[]
|
||||
*/
|
||||
protected array $openAPINullablesSetToNull = [];
|
||||
|
||||
/**
|
||||
* Array of property to type mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPITypes()
|
||||
{
|
||||
return self::$openAPITypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of property to format mappings. Used for (de)serialization
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function openAPIFormats()
|
||||
{
|
||||
return self::$openAPIFormats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable properties
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function openAPINullables(): array
|
||||
{
|
||||
return self::$openAPINullables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @return boolean[]
|
||||
*/
|
||||
private function getOpenAPINullablesSetToNull(): array
|
||||
{
|
||||
return $this->openAPINullablesSetToNull;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter - Array of nullable field names deliberately set to null
|
||||
*
|
||||
* @param boolean[] $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 string[]
|
||||
*/
|
||||
protected static $attributeMap = [
|
||||
'name' => 'name'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $setters = [
|
||||
'name' => 'setName'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $getters = [
|
||||
'name' => 'getName'
|
||||
];
|
||||
|
||||
/**
|
||||
* Array of attributes where the key is the local name,
|
||||
* and the value is the original name
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function attributeMap()
|
||||
{
|
||||
return self::$attributeMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to setter functions (for deserialization of responses)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function setters()
|
||||
{
|
||||
return self::$setters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Array of attributes to getter functions (for serialization of requests)
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getters()
|
||||
{
|
||||
return self::$getters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original name of the model.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModelName()
|
||||
{
|
||||
return self::$openAPIModelName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Associative array for storing property values
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $container = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed[] $data Associated array of property values
|
||||
* initializing the model
|
||||
*/
|
||||
public function __construct(array $data = null)
|
||||
{
|
||||
$this->setIfExists('name', $data ?? [], null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
|
||||
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
|
||||
* $this->openAPINullablesSetToNull array
|
||||
*
|
||||
* @param string $variableName
|
||||
* @param array $fields
|
||||
* @param mixed $defaultValue
|
||||
*/
|
||||
private function setIfExists(string $variableName, array $fields, $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 array invalid properties with reasons
|
||||
*/
|
||||
public function listInvalidProperties()
|
||||
{
|
||||
$invalidProperties = [];
|
||||
|
||||
return $invalidProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate all the properties in the model
|
||||
* return true if all passed
|
||||
*
|
||||
* @return bool True if all properties are valid
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return count($this->listInvalidProperties()) === 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets name
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->container['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets name
|
||||
*
|
||||
* @param string|null $name name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
if (is_null($name)) {
|
||||
throw new \InvalidArgumentException('non-nullable name cannot be null');
|
||||
}
|
||||
$this->container['name'] = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Returns true if offset exists. False otherwise.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
return isset($this->container[$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets offset.
|
||||
*
|
||||
* @param integer $offset Offset
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
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($offset, $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($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()
|
||||
{
|
||||
return ObjectSerializer::sanitizeForSerialization($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return json_encode(
|
||||
ObjectSerializer::sanitizeForSerialization($this),
|
||||
JSON_PRETTY_PRINT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a header-safe presentation of the object
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHeaderValue()
|
||||
{
|
||||
return json_encode(ObjectSerializer::sanitizeForSerialization($this));
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user