mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-03-10 08:31:23 +00:00
[PHP] update dependencies for php-dt generated code (#17796)
* php-dt update: - bump minimal required PHP version to 7.4 (8.1 for modern mode) - bump minimal required DataTransfer version to 0.6 - support for date / date-time string lists and maps - support for request and response bodies with date / date-time string schema - minimal file string support * docs update
This commit is contained in:
@@ -32,7 +32,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|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|
|
||||
|licenseName|The name of the license| |null|
|
||||
|modelPackage|package for generated models| |null|
|
||||
|modern|use modern language features (generated code will require PHP 8.0)| |false|
|
||||
|modern|use modern language features (generated code will require PHP 8.1)| |false|
|
||||
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|
||||
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|
||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||
|
||||
@@ -99,6 +99,12 @@ public class PhpDataTransferClientCodegen extends AbstractPhpCodegen {
|
||||
// remove these from primitive types to make the output works
|
||||
languageSpecificPrimitives.remove("\\DateTime");
|
||||
languageSpecificPrimitives.remove("\\SplFileObject");
|
||||
// fix date and date-time mapping to support both DateTime and DateTimeImmutable
|
||||
typeMapping.put("date", "\\DateTimeInterface");
|
||||
typeMapping.put("Date", "\\DateTimeInterface");
|
||||
typeMapping.put("DateTime", "\\DateTimeInterface");
|
||||
// TODO provide proper support for "file" string format
|
||||
typeMapping.put("file", "string");
|
||||
|
||||
apiTemplateFiles.clear();
|
||||
apiTestTemplateFiles.clear();
|
||||
@@ -108,7 +114,7 @@ public class PhpDataTransferClientCodegen extends AbstractPhpCodegen {
|
||||
|
||||
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, "1.0.0");
|
||||
//Register custom CLI options
|
||||
addSwitch(OPT_MODERN, "use modern language features (generated code will require PHP 8.0)", useModernSyntax);
|
||||
addSwitch(OPT_MODERN, "use modern language features (generated code will require PHP 8.1)", useModernSyntax);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,13 +159,26 @@ public class PhpDataTransferClientCodegen extends AbstractPhpCodegen {
|
||||
return super.toApiName(toModelName(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toRegularExpression(String pattern) {
|
||||
String result = super.toRegularExpression(pattern);
|
||||
if ((result != null) && (!useModernSyntax)) {
|
||||
//Doctrine Annotations have different string escape rules compared to PHP code
|
||||
result = result
|
||||
.replace("\\\\", "\\")
|
||||
.replace("\\\"", "\"\"")
|
||||
;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeDeclaration(Schema p) {
|
||||
String result;
|
||||
Map<String, Object> extensions = p.getExtensions();
|
||||
if ((extensions != null) && extensions.containsKey(VEN_CONTAINER_DATA_TYPE)) {
|
||||
result = (String) extensions.get(VEN_CONTAINER_DATA_TYPE);
|
||||
} else if (useModernSyntax && (ModelUtils.isArraySchema(p) || ModelUtils.isMapSchema(p))) {
|
||||
} else if (ModelUtils.isArraySchema(p) || ModelUtils.isMapSchema(p)) {
|
||||
result = "array";
|
||||
} else {
|
||||
result = super.getTypeDeclaration(p);
|
||||
|
||||
@@ -44,7 +44,17 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
$request = $this->addCookies($request, $parameters);
|
||||
{{/cookieParams.0}}
|
||||
{{#bodyParam}}
|
||||
{{#isDate}}
|
||||
$request = $this->addBody($request, $requestMediaType, $requestContent, ($this->contentStrategies)('Date', []));
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
$request = $this->addBody($request, $requestMediaType, $requestContent, ($this->contentStrategies)('DateTime', []));
|
||||
{{/isDateTime}}
|
||||
{{^isDate}}
|
||||
{{^isDateTime}}
|
||||
$request = $this->addBody($request, $requestMediaType, $requestContent);
|
||||
{{/isDateTime}}
|
||||
{{/isDate}}
|
||||
{{/bodyParam}}
|
||||
{{#hasProduces}}
|
||||
$request = $this->addAcceptHeader($request, $responseMediaType);
|
||||
@@ -68,6 +78,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->{{operationId}}Raw({{>api_arg_call}});
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
{{#responses}}
|
||||
@@ -75,25 +87,35 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{{#message}}
|
||||
/* {{&message}} */
|
||||
{{/message}}
|
||||
{{#isModel}}
|
||||
$responseContent = new {{dataType}}();
|
||||
{{/isModel}}
|
||||
{{^isModel}}
|
||||
{{#isArray}}
|
||||
$responseContent = new {{dataType}}();
|
||||
{{/isArray}}
|
||||
{{/isModel}}
|
||||
{{^isModel}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
$responseContent = new {{dataType}}();
|
||||
{{/isMap}}
|
||||
{{/isArray}}
|
||||
{{#isDate}}
|
||||
$contentStrategy = ($this->contentStrategies)('Date', []);
|
||||
$contentValidator = ($this->contentValidators)('Date', []);
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
$contentStrategy = ($this->contentStrategies)('DateTime', []);
|
||||
$contentValidator = ($this->contentValidators)('DateTime', []);
|
||||
{{/isDateTime}}
|
||||
{{^isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isArray}}
|
||||
{{^isMap}}
|
||||
{{#isModel}}
|
||||
$responseContent = new {{dataType}}();
|
||||
{{/isModel}}
|
||||
{{/isMap}}
|
||||
{{/isArray}}
|
||||
{{/isDateTime}}
|
||||
{{/isDate}}
|
||||
break;
|
||||
{{/responses}}
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace {{invokerPackage}};
|
||||
|
||||
use Articus\DataTransfer as DT;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Articus\PluginManager as PM;
|
||||
use OpenAPIGenerator\APIClient as OAGAC;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class ApiClientFactory extends DT\ConfigAwareFactory
|
||||
class ApiClientFactory implements PM\ServiceFactoryInterface
|
||||
{
|
||||
use PM\ConfigAwareFactoryTrait;
|
||||
|
||||
public function __construct(string $configKey = ApiClient::class)
|
||||
{
|
||||
parent::__construct($configKey);
|
||||
$this->configKey = $configKey;
|
||||
}
|
||||
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): ApiClient
|
||||
{
|
||||
$config = new OAGAC\ApiClientOptions(\array_merge($this->getServiceConfig($container), $options ?? []));
|
||||
return new ApiClient(
|
||||
@@ -24,7 +26,9 @@ class ApiClientFactory extends DT\ConfigAwareFactory
|
||||
$container->get($config->httpClientServiceName),
|
||||
$container->get($config->securityProviderFactoryServiceName),
|
||||
$container->get($config->bodyCoderFactoryServiceName),
|
||||
$container->get($config->bodyCoderFactoryServiceName)
|
||||
$container->get($config->bodyCoderFactoryServiceName),
|
||||
$container->get($config->contentStrategyFactoryServiceName),
|
||||
$container->get($config->contentValidatorFactoryServiceName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
## Overview
|
||||
This lightweight extensible client library is [PSR-7](https://www.php-fig.org/psr/psr-7), [PSR-11](https://www.php-fig.org/psr/psr-11), [PSR-17](https://www.php-fig.org/psr/psr-17) and [PSR-18](https://www.php-fig.org/psr/psr-18) complaint and relies on:
|
||||
|
||||
- PHP: >=8.0
|
||||
- [Data Transfer](https://github.com/Articus/DataTransfer): >=0.5
|
||||
- PHP: >=8.1
|
||||
- [Data Transfer](https://github.com/Articus/DataTransfer): >=0.6
|
||||
|
||||
|
||||
## How to use
|
||||
@@ -21,7 +21,7 @@ Then check content types for API requests you intend to send and API responses y
|
||||
|
||||
After that review security requirements for API operations you intend to use. For each unique security scheme you will need an implementation of [OpenAPIGenerator\APIClient\SecurityProviderInterface](https://github.com/Articus/OpenAPIGeneratorAPIClient-PHP/blob/master/src/OpenAPIGenerator/APIClient/SecurityProviderInterface.php). Currently, only [HTTP Bearer authentication](https://github.com/Articus/OpenAPIGeneratorAPIClient-PHP/blob/master/src/OpenAPIGenerator/APIClient/SecurityProvider/HttpBearer.php) is supported out-of-the-box.
|
||||
|
||||
The last step is to configure and wire all services together. It is highly advisable to use [PSR-11 container](https://packagist.org/packages/psr/container) for that. If you have not selected one for your project yet, https://packagist.org/providers/psr/container-implementation may help to find some suitable options. Here is a sample wiring configuration for `"laminas/laminas-servicemanager"`, `"laminas/laminas-diactoros"` and `"symfony/http-client"` (consult generated `composer.json` for the exact versions of used packages):
|
||||
The last step is to configure and wire all services together. It is highly advisable to use [PSR-11 container](https://packagist.org/packages/psr/container) for that. If you have not selected one for your project yet, https://packagist.org/providers/psr/container-implementation may help to find some suitable options. Here is a sample wiring configuration for `"laminas/laminas-servicemanager"`, `"nyholm/psr7"` and `"symfony/http-client"` (consult generated `composer.json` for the exact versions of used packages):
|
||||
|
||||
```PHP
|
||||
<?php
|
||||
@@ -31,21 +31,24 @@ require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$dependencies = [
|
||||
'invokables' => [
|
||||
Psr\Http\Message\RequestFactoryInterface::class => Laminas\Diactoros\RequestFactory::class,
|
||||
Psr\Http\Message\ResponseFactoryInterface::class => Laminas\Diactoros\ResponseFactory::class,
|
||||
Psr\Http\Message\StreamFactoryInterface::class => Laminas\Diactoros\StreamFactory::class,
|
||||
Psr\Http\Message\RequestFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
Psr\Http\Message\ResponseFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
Psr\Http\Message\StreamFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
],
|
||||
'factories' => [
|
||||
{{invokerPackage}}\ApiClient::class => {{invokerPackage}}\ApiClientFactory::class,
|
||||
|
||||
Articus\DataTransfer\Service::class => Articus\DataTransfer\Factory::class,
|
||||
Articus\DataTransfer\MetadataProvider\PhpAttribute::class => Articus\DataTransfer\MetadataProvider\Factory\PhpAttribute::class,
|
||||
Articus\DataTransfer\Strategy\PluginManager::class => Articus\DataTransfer\Strategy\Factory\PluginManager::class,
|
||||
Articus\DataTransfer\Validator\PluginManager::class => Articus\DataTransfer\Validator\Factory\PluginManager::class,
|
||||
Laminas\Validator\ValidatorPluginManager::class => Laminas\Validator\ValidatorPluginManagerFactory::class,
|
||||
Articus\DataTransfer\Options::DEFAULT_STRATEGY_PLUGIN_MANAGER => [Articus\PluginManager\Factory\Chain::class, 'app_dt_strategy_manager_chain'],
|
||||
'oas_dt_strategy_manager' => OpenAPIGenerator\Common\Strategy\Factory\PluginManager::class,
|
||||
'app_dt_strategy_manager' => Articus\DataTransfer\Strategy\Factory\SimplePluginManager::class,
|
||||
Articus\DataTransfer\Options::DEFAULT_VALIDATOR_PLUGIN_MANAGER => [Articus\PluginManager\Factory\Chain::class, 'app_dt_validator_manager_chain'],
|
||||
'oas_dt_validator_manager' => OpenAPIGenerator\Common\Validator\Factory\PluginManager::class,
|
||||
'app_dt_validator_manager' => Articus\DataTransfer\Validator\Factory\SimplePluginManager::class,
|
||||
|
||||
OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class => OpenAPIGenerator\APIClient\SecurityProvider\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\BodyCoder\PluginManager::class => OpenAPIGenerator\APIClient\BodyCoder\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_BODY_CODER_PLUGIN_MANAGER => OpenAPIGenerator\APIClient\BodyCoder\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER => OpenAPIGenerator\APIClient\SecurityProvider\Factory\PluginManager::class,
|
||||
|
||||
Psr\Http\Client\ClientInterface::class => function (Psr\Container\ContainerInterface $container)
|
||||
{
|
||||
@@ -64,34 +67,17 @@ $dependencies = [
|
||||
$config = [
|
||||
'dependencies' => $dependencies,
|
||||
|
||||
//Configure DataTransfer library
|
||||
Articus\DataTransfer\Strategy\PluginManager::class => [
|
||||
'invokables' => [
|
||||
'QueryStringScalar' => OpenAPIGenerator\Common\Strategy\QueryStringScalar::class,
|
||||
'QueryStringScalarArray' => OpenAPIGenerator\Common\Strategy\QueryStringScalarArray::class,
|
||||
],
|
||||
'factories' => [
|
||||
'Date' => OpenAPIGenerator\Common\Strategy\Factory\ImmutableDate::class,
|
||||
'DateTime' => OpenAPIGenerator\Common\Strategy\Factory\ImmutableDateTime::class,
|
||||
'ObjectList' => OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectList::class,
|
||||
'ObjectMap' => OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectMap::class,
|
||||
'ScalarList' => OpenAPIGenerator\Common\Strategy\Factory\ScalarList::class,
|
||||
'ScalarMap' => OpenAPIGenerator\Common\Strategy\Factory\ScalarMap::class,
|
||||
]
|
||||
],
|
||||
Articus\DataTransfer\Validator\PluginManager::class => [
|
||||
'invokables' => [
|
||||
'Scalar' => OpenAPIGenerator\Common\Validator\Scalar::class,
|
||||
'QueryStringScalar' => OpenAPIGenerator\Common\Validator\QueryStringScalar::class,
|
||||
'QueryStringScalarArray' => OpenAPIGenerator\Common\Validator\QueryStringScalarArray::class,
|
||||
],
|
||||
'abstract_factories' => [
|
||||
Articus\DataTransfer\Validator\Factory\Laminas::class,
|
||||
//Configure DataTransfer library: add pack of extra strategies and pack of extra validators
|
||||
'app_dt_strategy_manager_chain' => [
|
||||
'managers' => [
|
||||
'oas_dt_strategy_manager',
|
||||
'app_dt_strategy_manager',
|
||||
],
|
||||
],
|
||||
'validators' => [
|
||||
'invokables' => [
|
||||
'Count' => Laminas\Validator\IsCountable::class,
|
||||
'app_dt_validator_manager_chain' => [
|
||||
'managers' => [
|
||||
'oas_dt_validator_manager',
|
||||
'app_dt_validator_manager',
|
||||
],
|
||||
],
|
||||
|
||||
@@ -101,19 +87,19 @@ $config = [
|
||||
],
|
||||
|
||||
//Register body coders for used content types here
|
||||
OpenAPIGenerator\APIClient\BodyCoder\PluginManager::class => [
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_BODY_CODER_PLUGIN_MANAGER => [
|
||||
'factories' => [
|
||||
//'another/mime-type' => AnotherMimeTypeBodyCoder::class
|
||||
],
|
||||
],
|
||||
|
||||
//Register security providers for used security schemes here
|
||||
OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class => [
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER => [
|
||||
'factories' => [
|
||||
//'another-security-scheme' => AnotherSecuritySchemeProvider::class,
|
||||
],
|
||||
'aliases' => [
|
||||
//'custom-name-for-htt-bearer' => OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class,
|
||||
//'custom-name-for-http-bearer' => OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -126,10 +112,10 @@ $client = $container->get({{invokerPackage}}\ApiClient::class);
|
||||
//... and now you can use client methods to call API operations :)
|
||||
|
||||
//And one more sample: how to set token for HTTP Bearer authentication
|
||||
/** @var OpenAPIGenerator\APIClient\SecurityProvider\PluginManager $securityProviders */
|
||||
$securityProviders = $container->get(OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class);
|
||||
/** @var Articus\PluginManager\PluginManagerInterface $securityProviders */
|
||||
$securityProviders = $container->get(OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER);
|
||||
/** @var OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer $httpBearer */
|
||||
$httpBearer = $securityProviders->get(OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class);
|
||||
$httpBearer = $securityProviders(OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class, []);
|
||||
$httpBearer->setToken('some-token');
|
||||
|
||||
```
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* @param {{dataType}} $requestContent
|
||||
{{/bodyParam}}
|
||||
{{#hasAuthMethods}}
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
{{/hasAuthMethods}}
|
||||
{{#hasConsumes}}
|
||||
* @param string $requestMediaType
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
{
|
||||
"name": "{{#lambda.lowercase}}{{gitUserId}}/{{gitRepoId}}{{/lambda.lowercase}}",
|
||||
"description": "{{description}}",
|
||||
"version": "{{artifactVersion}}",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"openapi",
|
||||
"php",
|
||||
@@ -17,14 +15,15 @@
|
||||
"homepage": "{{{developerOrganizationUrl}}}"
|
||||
}
|
||||
],
|
||||
"version": "{{artifactVersion}}",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"articus/data-transfer": "^0.5",
|
||||
"articus/openapi-generator-common": "^0.2",
|
||||
"articus/openapi-generator-apiclient": "^0.1",
|
||||
"php": "^8.1",
|
||||
"articus/data-transfer": "^0.6",
|
||||
"articus/openapi-generator-common": "^0.3",
|
||||
"articus/openapi-generator-apiclient": "^0.2",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"laminas/laminas-stdlib": "^3.2",
|
||||
"laminas/laminas-validator": "^2.13"
|
||||
"laminas/laminas-stdlib": "^3.18"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -32,8 +31,8 @@
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"laminas/laminas-servicemanager": "^3.6",
|
||||
"laminas/laminas-diactoros": "^2.6",
|
||||
"symfony/http-client": "^5.3"
|
||||
"laminas/laminas-servicemanager": "^3.22",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"symfony/http-client": "^6.4 || ^7.0"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,18 @@
|
||||
{{#vars
|
||||
}}{{#isArray
|
||||
}}#[DTA\Strategy("{{#isPrimitiveType}}ScalarList{{/isPrimitiveType}}{{^isPrimitiveType}}ObjectList{{/isPrimitiveType}}", ["type" => {{>list_item_type}}])]
|
||||
{{#minItems}}{{^maxItems
|
||||
}}{{#isPrimitiveType
|
||||
}}#[DTA\Strategy("ScalarList", ["type" => {{>list_item_type}}])]
|
||||
{{/isPrimitiveType
|
||||
}}{{#items.isDate
|
||||
}}#[DTA\Strategy("DateList")]
|
||||
{{/items.isDate
|
||||
}}{{#items.isDateTime
|
||||
}}#[DTA\Strategy("DateTimeList")]
|
||||
{{/items.isDateTime
|
||||
}}{{^isPrimitiveType}}{{^items.isDate}}{{^items.isDateTime
|
||||
}}#[DTA\Strategy("ObjectList", ["type" => {{>list_item_type}}])]
|
||||
{{/items.isDateTime}}{{/items.isDate}}{{/isPrimitiveType
|
||||
}}{{#minItems}}{{^maxItems
|
||||
}}#[DTA\Validator("Count", ["min" => {{minItems}}], blocker: true)]
|
||||
{{/maxItems}}{{/minItems
|
||||
}}{{^minItems}}{{#maxItems
|
||||
@@ -14,20 +25,31 @@
|
||||
{{#isPrimitiveType
|
||||
}} ["name" => "Scalar", "options" => ["type" => {{>list_item_type}}]]
|
||||
{{/isPrimitiveType
|
||||
}}{{#isDate
|
||||
}}{{#items.isDate
|
||||
}} ["name" => "Date"]
|
||||
{{/isDate
|
||||
}}{{#isDateTime
|
||||
}} ["name" => "Date", "options" => ["format" => \DateTime::RFC3339]]
|
||||
{{/isDateTime
|
||||
}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime
|
||||
{{/items.isDate
|
||||
}}{{#items.isDateTime
|
||||
}} ["name" => "DateTime"]
|
||||
{{/items.isDateTime
|
||||
}}{{^isPrimitiveType}}{{^items.isDate}}{{^items.isDateTime
|
||||
}} ["name" => "TypeCompliant", "options" => ["type" => {{>list_item_type}}]]
|
||||
{{/isDateTime}}{{/isDate}}{{/isPrimitiveType
|
||||
{{/items.isDateTime}}{{/items.isDate}}{{/isPrimitiveType
|
||||
}}]])]
|
||||
{{/isArray
|
||||
}}{{#isMap
|
||||
}}#[DTA\Strategy("{{#isPrimitiveType}}ScalarMap{{/isPrimitiveType}}{{^isPrimitiveType}}ObjectMap{{/isPrimitiveType}}", ["type" => {{>map_item_type}}])]
|
||||
{{#minProperties}}{{^maxProperties
|
||||
}}{{#isPrimitiveType
|
||||
}}#[DTA\Strategy("ScalarMap", ["type" => {{>map_item_type}}])]
|
||||
{{/isPrimitiveType
|
||||
}}{{#additionalProperties.isDate
|
||||
}}#[DTA\Strategy("DateMap")]
|
||||
{{/additionalProperties.isDate
|
||||
}}{{#additionalProperties.isDateTime
|
||||
}}#[DTA\Strategy("DateTimeMap")]
|
||||
{{/additionalProperties.isDateTime
|
||||
}}{{^isPrimitiveType}}{{^additionalProperties.isDate}}{{^additionalProperties.isDateTime
|
||||
}}#[DTA\Strategy("ObjectMap", ["type" => {{>map_item_type}}])]
|
||||
{{/additionalProperties.isDateTime}}{{/additionalProperties.isDate}}{{/isPrimitiveType
|
||||
}}{{#minProperties}}{{^maxProperties
|
||||
}}#[DTA\Validator("Count", ["min" => {{minProperties}}], blocker: true)]
|
||||
{{/maxProperties}}{{/minProperties
|
||||
}}{{^minProperties}}{{#maxProperties
|
||||
@@ -40,15 +62,15 @@
|
||||
{{#isPrimitiveType
|
||||
}} ["name" => "Scalar", "options" => ["type" => {{>map_item_type}}]]
|
||||
{{/isPrimitiveType
|
||||
}}{{#isDate
|
||||
}}{{#additionalProperties.isDate
|
||||
}} ["name" => "Date"]
|
||||
{{/isDate
|
||||
}}{{#isDateTime
|
||||
}} ["name" => "Date", "options" => ["format" => \DateTime::RFC3339]]
|
||||
{{/isDateTime
|
||||
}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime
|
||||
{{/additionalProperties.isDate
|
||||
}}{{#additionalProperties.isDateTime
|
||||
}} ["name" => "DateTime"]
|
||||
{{/additionalProperties.isDateTime
|
||||
}}{{^isPrimitiveType}}{{^additionalProperties.isDate}}{{^additionalProperties.isDateTime
|
||||
}} ["name" => "TypeCompliant", "options" => ["type" => {{>map_item_type}}]]
|
||||
{{/isDateTime}}{{/isDate}}{{/isPrimitiveType
|
||||
{{/additionalProperties.isDateTime}}{{/additionalProperties.isDate}}{{/isPrimitiveType
|
||||
}}]])]
|
||||
{{/isMap
|
||||
}}{{/vars
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{{/isDate
|
||||
}}{{#isDateTime
|
||||
}} #[DTA\Strategy("DateTime")]
|
||||
#[DTA\Validator("Date", ["format" => \DateTime::RFC3339])]
|
||||
#[DTA\Validator("DateTime")]
|
||||
{{/isDateTime
|
||||
}}{{^isPrimitiveType
|
||||
}}{{^isDate
|
||||
@@ -25,21 +25,24 @@
|
||||
}}{{/isContainer
|
||||
}}{{#hasValidation
|
||||
}}{{#minLength}}{{#maxLength
|
||||
}} #[DTA\Validator("StringLength", ["min" => {{minLength}}, "max" => {{maxLength}}])]
|
||||
}} #[DTA\Validator("Length", ["min" => {{minLength}}, "max" => {{maxLength}}])]
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{^minLength}}{{#maxLength
|
||||
}} #[DTA\Validator("StringLength", ["max" => {{maxLength}}])]
|
||||
}} #[DTA\Validator("Length", ["max" => {{maxLength}}])]
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{#minLength}}{{^maxLength
|
||||
}} #[DTA\Validator("StringLength", ["min" => {{minLength}}])]
|
||||
}} #[DTA\Validator("Length", ["min" => {{minLength}}])]
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{#minimum
|
||||
}} #[DTA\Validator("GreaterThan", ["min" => {{minimum}}{{^exclusiveMinimum}}, "inclusive" => true{{/exclusiveMinimum}}])]
|
||||
{{/minimum
|
||||
}}{{#maximum
|
||||
}} #[DTA\Validator("LessThan", ["max" => {{maximum}}{{^exclusiveMaximum}}, "inclusive" => true{{/exclusiveMaximum}}])]
|
||||
{{/maximum
|
||||
}}{{#minimum}}{{#maximum
|
||||
}} #[DTA\Validator("Range", ["min" => {{minimum}}, "max" => {{maximum}}{{#exclusiveMinimum}}, "exclude_min" => true{{/exclusiveMinimum}}{{#exclusiveMaximum}}, "exclude_max" => true{{/exclusiveMaximum}}])]
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{^minimum}}{{#maximum
|
||||
}} #[DTA\Validator("Range", ["max" => {{maximum}}{{#exclusiveMaximum}}, "exclude_max" => true{{/exclusiveMaximum}}])]
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{#minimum}}{{^maximum
|
||||
}} #[DTA\Validator("Range", ["min" => {{minimum}}{{#exclusiveMinimum}}, "exclude_min" => true{{/exclusiveMinimum}}])]
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{#pattern
|
||||
}} #[DTA\Validator("Regex", ["pattern" => "{{{pattern}}}"])]
|
||||
}} #[DTA\Validator("Match", ["pattern" => "{{{pattern}}}"])]
|
||||
{{/pattern
|
||||
}}{{/hasValidation}}
|
||||
@@ -21,7 +21,7 @@
|
||||
{{/isDate
|
||||
}}{{#isDateTime
|
||||
}} #[DTA\Strategy("DateTime", subset: "{{internal.parameterLocation}}")]
|
||||
#[DTA\Validator("Date", ["format" => \DateTime::RFC3339], subset: "{{internal.parameterLocation}}")]
|
||||
#[DTA\Validator("DateTime", subset: "{{internal.parameterLocation}}")]
|
||||
{{/isDateTime
|
||||
}}{{^isPrimitiveType
|
||||
}}{{^isDate}}{{^isDateTime
|
||||
@@ -31,21 +31,24 @@
|
||||
}}{{/isContainer
|
||||
}}{{#hasValidation
|
||||
}}{{#minLength}}{{#maxLength
|
||||
}} #[DTA\Validator("StringLength", ["min" => {{minLength}}, "max" => {{maxLength}}], subset: "{{internal.parameterLocation}}")]
|
||||
}} #[DTA\Validator("Length", ["min" => {{minLength}}, "max" => {{maxLength}}], subset: "{{internal.parameterLocation}}")]
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{^minLength}}{{#maxLength
|
||||
}} #[DTA\Validator("StringLength", ["max" => {{maxLength}}], subset: "{{internal.parameterLocation}}")]
|
||||
}} #[DTA\Validator("Length", ["max" => {{maxLength}}], subset: "{{internal.parameterLocation}}")]
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{#minLength}}{{^maxLength
|
||||
}} #[DTA\Validator("StringLength", ["min" => {{minLength}}], subset: "{{internal.parameterLocation}}")]
|
||||
}} #[DTA\Validator("Length", ["min" => {{minLength}}], subset: "{{internal.parameterLocation}}")]
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{#minimum
|
||||
}} #[DTA\Validator("GreaterThan", ["min" => {{minimum}}{{^exclusiveMinimum}}, "inclusive" => true{{/exclusiveMinimum}}], subset: "{{internal.parameterLocation}}")]
|
||||
{{/minimum
|
||||
}}{{#maximum
|
||||
}} #[DTA\Validator("LessThan", ["max" => {{maximum}}{{^exclusiveMaximum}}, "inclusive" => true{{/exclusiveMaximum}}], subset: "{{internal.parameterLocation}}")]
|
||||
{{/maximum
|
||||
}}{{#minimum}}{{#maximum
|
||||
}} #[DTA\Validator("Range", ["min" => {{minimum}}, "max" => {{maximum}}{{#exclusiveMinimum}}, "exclude_min" => true{{/exclusiveMinimum}}{{#exclusiveMaximum}}, "exclude_max" => true{{/exclusiveMaximum}}], subset: "{{internal.parameterLocation}}")]
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{^minimum}}{{#maximum
|
||||
}} #[DTA\Validator("Range", ["max" => {{maximum}}{{#exclusiveMaximum}}, "exclude_max" => true{{/exclusiveMaximum}}], subset: "{{internal.parameterLocation}}")]
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{#minimum}}{{^maximum
|
||||
}} #[DTA\Validator("Range", ["min" => {{minimum}}{{#exclusiveMinimum}}, "exclude_min" => true{{/exclusiveMinimum}}], subset: "{{internal.parameterLocation}}")]
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{#pattern
|
||||
}} #[DTA\Validator("Regex", ["pattern" => "{{{pattern}}}"], subset: "{{internal.parameterLocation}}")]
|
||||
}} #[DTA\Validator("Match", ["pattern" => "{{{pattern}}}"], subset: "{{internal.parameterLocation}}")]
|
||||
{{/pattern
|
||||
}}{{/hasValidation}}
|
||||
@@ -44,7 +44,17 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
$request = $this->addCookies($request, $parameters);
|
||||
{{/cookieParams.0}}
|
||||
{{#bodyParam}}
|
||||
{{#isDate}}
|
||||
$request = $this->addBody($request, $requestMediaType, $requestContent, ($this->contentStrategies)('Date', []));
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
$request = $this->addBody($request, $requestMediaType, $requestContent, ($this->contentStrategies)('DateTime', []));
|
||||
{{/isDateTime}}
|
||||
{{^isDate}}
|
||||
{{^isDateTime}}
|
||||
$request = $this->addBody($request, $requestMediaType, $requestContent);
|
||||
{{/isDateTime}}
|
||||
{{/isDate}}
|
||||
{{/bodyParam}}
|
||||
{{#hasProduces}}
|
||||
$request = $this->addAcceptHeader($request, $responseMediaType);
|
||||
@@ -68,6 +78,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->{{operationId}}Raw({{>api_arg_call}});
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
{{#responses}}
|
||||
@@ -75,25 +87,35 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{{#message}}
|
||||
/* {{&message}} */
|
||||
{{/message}}
|
||||
{{#isModel}}
|
||||
$responseContent = new {{dataType}}();
|
||||
{{/isModel}}
|
||||
{{^isModel}}
|
||||
{{#isArray}}
|
||||
$responseContent = new {{dataType}}();
|
||||
{{/isArray}}
|
||||
{{/isModel}}
|
||||
{{^isModel}}
|
||||
{{^isArray}}
|
||||
{{#isMap}}
|
||||
$responseContent = new {{dataType}}();
|
||||
{{/isMap}}
|
||||
{{/isArray}}
|
||||
{{#isDate}}
|
||||
$contentStrategy = ($this->contentStrategies)('Date', []);
|
||||
$contentValidator = ($this->contentValidators)('Date', []);
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
$contentStrategy = ($this->contentStrategies)('DateTime', []);
|
||||
$contentValidator = ($this->contentValidators)('DateTime', []);
|
||||
{{/isDateTime}}
|
||||
{{^isDate}}
|
||||
{{^isDateTime}}
|
||||
{{^isArray}}
|
||||
{{^isMap}}
|
||||
{{#isModel}}
|
||||
$responseContent = new {{dataType}}();
|
||||
{{/isModel}}
|
||||
{{/isMap}}
|
||||
{{/isArray}}
|
||||
{{/isDateTime}}
|
||||
{{/isDate}}
|
||||
break;
|
||||
{{/responses}}
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace {{invokerPackage}};
|
||||
|
||||
use Articus\DataTransfer as DT;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Articus\PluginManager as PM;
|
||||
use OpenAPIGenerator\APIClient as OAGAC;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class ApiClientFactory extends DT\ConfigAwareFactory
|
||||
class ApiClientFactory implements PM\ServiceFactoryInterface
|
||||
{
|
||||
use PM\ConfigAwareFactoryTrait;
|
||||
|
||||
public function __construct(string $configKey = ApiClient::class)
|
||||
{
|
||||
parent::__construct($configKey);
|
||||
$this->configKey = $configKey;
|
||||
}
|
||||
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): ApiClient
|
||||
{
|
||||
$config = new OAGAC\ApiClientOptions(\array_merge($this->getServiceConfig($container), $options ?? []));
|
||||
return new ApiClient(
|
||||
@@ -24,7 +26,9 @@ class ApiClientFactory extends DT\ConfigAwareFactory
|
||||
$container->get($config->httpClientServiceName),
|
||||
$container->get($config->securityProviderFactoryServiceName),
|
||||
$container->get($config->bodyCoderFactoryServiceName),
|
||||
$container->get($config->bodyCoderFactoryServiceName)
|
||||
$container->get($config->bodyCoderFactoryServiceName),
|
||||
$container->get($config->contentStrategyFactoryServiceName),
|
||||
$container->get($config->contentValidatorFactoryServiceName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
## Overview
|
||||
This lightweight extensible client library is [PSR-7](https://www.php-fig.org/psr/psr-7), [PSR-11](https://www.php-fig.org/psr/psr-11), [PSR-17](https://www.php-fig.org/psr/psr-17) and [PSR-18](https://www.php-fig.org/psr/psr-18) complaint and relies on:
|
||||
|
||||
- PHP: >=7.3
|
||||
- [Data Transfer](https://github.com/Articus/DataTransfer): >=0.5
|
||||
- PHP: >=7.4
|
||||
- [Data Transfer](https://github.com/Articus/DataTransfer): >=0.6
|
||||
|
||||
|
||||
## How to use
|
||||
@@ -21,7 +21,7 @@ Then check content types for API requests you intend to send and API responses y
|
||||
|
||||
After that review security requirements for API operations you intend to use. For each unique security scheme you will need an implementation of [OpenAPIGenerator\APIClient\SecurityProviderInterface](https://github.com/Articus/OpenAPIGeneratorAPIClient-PHP/blob/master/src/OpenAPIGenerator/APIClient/SecurityProviderInterface.php). Currently, only [HTTP Bearer authentication](https://github.com/Articus/OpenAPIGeneratorAPIClient-PHP/blob/master/src/OpenAPIGenerator/APIClient/SecurityProvider/HttpBearer.php) is supported out-of-the-box.
|
||||
|
||||
The last step is to configure and wire all services together. It is highly advisable to use [PSR-11 container](https://packagist.org/packages/psr/container) for that. If you have not selected one for your project yet, https://packagist.org/providers/psr/container-implementation may help to find some suitable options. Here is a sample wiring configuration for `"laminas/laminas-servicemanager"`, `"laminas/laminas-diactoros"` and `"symfony/http-client"` (consult generated `composer.json` for the exact versions of used packages):
|
||||
The last step is to configure and wire all services together. It is highly advisable to use [PSR-11 container](https://packagist.org/packages/psr/container) for that. If you have not selected one for your project yet, https://packagist.org/providers/psr/container-implementation may help to find some suitable options. Here is a sample wiring configuration for `"laminas/laminas-servicemanager"`, `"nyholm/psr7"` and `"symfony/http-client"` (consult generated `composer.json` for the exact versions of used packages):
|
||||
|
||||
```PHP
|
||||
<?php
|
||||
@@ -31,21 +31,24 @@ require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$dependencies = [
|
||||
'invokables' => [
|
||||
Psr\Http\Message\RequestFactoryInterface::class => Laminas\Diactoros\RequestFactory::class,
|
||||
Psr\Http\Message\ResponseFactoryInterface::class => Laminas\Diactoros\ResponseFactory::class,
|
||||
Psr\Http\Message\StreamFactoryInterface::class => Laminas\Diactoros\StreamFactory::class,
|
||||
Psr\Http\Message\RequestFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
Psr\Http\Message\ResponseFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
Psr\Http\Message\StreamFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
],
|
||||
'factories' => [
|
||||
{{invokerPackage}}\ApiClient::class => {{invokerPackage}}\ApiClientFactory::class,
|
||||
|
||||
Articus\DataTransfer\Service::class => Articus\DataTransfer\Factory::class,
|
||||
Articus\DataTransfer\MetadataProvider\Annotation::class => Articus\DataTransfer\MetadataProvider\Factory\Annotation::class,
|
||||
Articus\DataTransfer\Strategy\PluginManager::class => Articus\DataTransfer\Strategy\Factory\PluginManager::class,
|
||||
Articus\DataTransfer\Validator\PluginManager::class => Articus\DataTransfer\Validator\Factory\PluginManager::class,
|
||||
Laminas\Validator\ValidatorPluginManager::class => Laminas\Validator\ValidatorPluginManagerFactory::class,
|
||||
Articus\DataTransfer\Options::DEFAULT_STRATEGY_PLUGIN_MANAGER => [Articus\PluginManager\Factory\Chain::class, 'app_dt_strategy_manager_chain'],
|
||||
'oas_dt_strategy_manager' => OpenAPIGenerator\Common\Strategy\Factory\PluginManager::class,
|
||||
'app_dt_strategy_manager' => Articus\DataTransfer\Strategy\Factory\SimplePluginManager::class,
|
||||
Articus\DataTransfer\Options::DEFAULT_VALIDATOR_PLUGIN_MANAGER => [Articus\PluginManager\Factory\Chain::class, 'app_dt_validator_manager_chain'],
|
||||
'oas_dt_validator_manager' => OpenAPIGenerator\Common\Validator\Factory\PluginManager::class,
|
||||
'app_dt_validator_manager' => Articus\DataTransfer\Validator\Factory\SimplePluginManager::class,
|
||||
|
||||
OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class => OpenAPIGenerator\APIClient\SecurityProvider\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\BodyCoder\PluginManager::class => OpenAPIGenerator\APIClient\BodyCoder\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_BODY_CODER_PLUGIN_MANAGER => OpenAPIGenerator\APIClient\BodyCoder\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER => OpenAPIGenerator\APIClient\SecurityProvider\Factory\PluginManager::class,
|
||||
|
||||
Psr\Http\Client\ClientInterface::class => function (Psr\Container\ContainerInterface $container)
|
||||
{
|
||||
@@ -64,34 +67,17 @@ $dependencies = [
|
||||
$config = [
|
||||
'dependencies' => $dependencies,
|
||||
|
||||
//Configure DataTransfer library
|
||||
Articus\DataTransfer\Strategy\PluginManager::class => [
|
||||
'invokables' => [
|
||||
'QueryStringScalar' => OpenAPIGenerator\Common\Strategy\QueryStringScalar::class,
|
||||
'QueryStringScalarArray' => OpenAPIGenerator\Common\Strategy\QueryStringScalarArray::class,
|
||||
],
|
||||
'factories' => [
|
||||
'Date' => OpenAPIGenerator\Common\Strategy\Factory\ImmutableDate::class,
|
||||
'DateTime' => OpenAPIGenerator\Common\Strategy\Factory\ImmutableDateTime::class,
|
||||
'ObjectList' => OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectList::class,
|
||||
'ObjectMap' => OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectMap::class,
|
||||
'ScalarList' => OpenAPIGenerator\Common\Strategy\Factory\ScalarList::class,
|
||||
'ScalarMap' => OpenAPIGenerator\Common\Strategy\Factory\ScalarMap::class,
|
||||
]
|
||||
],
|
||||
Articus\DataTransfer\Validator\PluginManager::class => [
|
||||
'invokables' => [
|
||||
'Scalar' => OpenAPIGenerator\Common\Validator\Scalar::class,
|
||||
'QueryStringScalar' => OpenAPIGenerator\Common\Validator\QueryStringScalar::class,
|
||||
'QueryStringScalarArray' => OpenAPIGenerator\Common\Validator\QueryStringScalarArray::class,
|
||||
],
|
||||
'abstract_factories' => [
|
||||
Articus\DataTransfer\Validator\Factory\Laminas::class,
|
||||
//Configure DataTransfer library: add pack of extra strategies and pack of extra validators
|
||||
'app_dt_strategy_manager_chain' => [
|
||||
'managers' => [
|
||||
'oas_dt_strategy_manager',
|
||||
'app_dt_strategy_manager',
|
||||
],
|
||||
],
|
||||
'validators' => [
|
||||
'invokables' => [
|
||||
'Count' => Laminas\Validator\IsCountable::class,
|
||||
'app_dt_validator_manager_chain' => [
|
||||
'managers' => [
|
||||
'oas_dt_validator_manager',
|
||||
'app_dt_validator_manager',
|
||||
],
|
||||
],
|
||||
|
||||
@@ -101,19 +87,19 @@ $config = [
|
||||
],
|
||||
|
||||
//Register body coders for used content types here
|
||||
OpenAPIGenerator\APIClient\BodyCoder\PluginManager::class => [
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_BODY_CODER_PLUGIN_MANAGER => [
|
||||
'factories' => [
|
||||
//'another/mime-type' => AnotherMimeTypeBodyCoder::class
|
||||
],
|
||||
],
|
||||
|
||||
//Register security providers for used security schemes here
|
||||
OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class => [
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER => [
|
||||
'factories' => [
|
||||
//'another-security-scheme' => AnotherSecuritySchemeProvider::class,
|
||||
],
|
||||
'aliases' => [
|
||||
//'custom-name-for-htt-bearer' => OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class,
|
||||
//'custom-name-for-http-bearer' => OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -126,10 +112,10 @@ $client = $container->get({{invokerPackage}}\ApiClient::class);
|
||||
//... and now you can use client methods to call API operations :)
|
||||
|
||||
//And one more sample: how to set token for HTTP Bearer authentication
|
||||
/** @var OpenAPIGenerator\APIClient\SecurityProvider\PluginManager $securityProviders */
|
||||
$securityProviders = $container->get(OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class);
|
||||
/** @var Articus\PluginManager\PluginManagerInterface $securityProviders */
|
||||
$securityProviders = $container->get(OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER);
|
||||
/** @var OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer $httpBearer */
|
||||
$httpBearer = $securityProviders->get(OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class);
|
||||
$httpBearer = $securityProviders(OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class, []);
|
||||
$httpBearer->setToken('some-token');
|
||||
|
||||
```
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* @param {{dataType}} $requestContent
|
||||
{{/bodyParam}}
|
||||
{{#hasAuthMethods}}
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
{{/hasAuthMethods}}
|
||||
{{#hasConsumes}}
|
||||
* @param string $requestMediaType
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
"version": "{{artifactVersion}}",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": "^7.3 || ^8.0",
|
||||
"articus/data-transfer": "^0.5",
|
||||
"articus/openapi-generator-common": "^0.2",
|
||||
"articus/openapi-generator-apiclient": "^0.1",
|
||||
"doctrine/annotations": "^1.10",
|
||||
"php": "^7.4 || ^8.0",
|
||||
"articus/data-transfer": "^0.6",
|
||||
"articus/openapi-generator-common": "^0.3",
|
||||
"articus/openapi-generator-apiclient": "^0.2",
|
||||
"doctrine/annotations": "^2.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"laminas/laminas-stdlib": "^3.2",
|
||||
"laminas/laminas-validator": "^2.13"
|
||||
"laminas/laminas-stdlib": "^3.13"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -33,8 +32,8 @@
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"laminas/laminas-servicemanager": "^3.6",
|
||||
"laminas/laminas-diactoros": "^2.6",
|
||||
"symfony/http-client": "^5.3"
|
||||
"laminas/laminas-servicemanager": "^3.17",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"symfony/http-client": "^5.4"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,19 @@
|
||||
/**
|
||||
{{#vars
|
||||
}}{{#isArray
|
||||
}} * @DTA\Strategy(name="{{#isPrimitiveType}}ScalarList{{/isPrimitiveType}}{{^isPrimitiveType}}ObjectList{{/isPrimitiveType}}", options={"type":{{>list_item_type}}})
|
||||
{{#minItems}}{{^maxItems
|
||||
}}{{#isPrimitiveType
|
||||
}} * @DTA\Strategy(name="ScalarList", options={"type":{{>list_item_type}}})
|
||||
{{/isPrimitiveType
|
||||
}}{{#items.isDate
|
||||
}} * @DTA\Strategy(name="DateList")
|
||||
{{/items.isDate
|
||||
}}{{#items.isDateTime
|
||||
}} * @DTA\Strategy(name="DateTimeList")
|
||||
{{/items.isDateTime
|
||||
}}{{^isPrimitiveType}}{{^items.isDate}}{{^items.isDateTime
|
||||
}} * @DTA\Strategy(name="ObjectList", options={"type":{{>list_item_type}}})
|
||||
{{/items.isDateTime}}{{/items.isDate}}{{/isPrimitiveType
|
||||
}}{{#minItems}}{{^maxItems
|
||||
}} * @DTA\Validator(name="Count", options={"min":{{minItems}}}, blocker=true)
|
||||
{{/maxItems}}{{/minItems
|
||||
}}{{^minItems}}{{#maxItems
|
||||
@@ -15,20 +26,31 @@
|
||||
{{#isPrimitiveType
|
||||
}} * {"name":"Scalar", "options":{"type":{{>list_item_type}}}}
|
||||
{{/isPrimitiveType
|
||||
}}{{#isDate
|
||||
}}{{#items.isDate
|
||||
}} * {"name":"Date"}
|
||||
{{/isDate
|
||||
}}{{#isDateTime
|
||||
}} * {"name":"Date", "options":{"format": \DateTime::RFC3339}}
|
||||
{{/isDateTime
|
||||
}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime
|
||||
{{/items.isDate
|
||||
}}{{#items.isDateTime
|
||||
}} * {"name":"DateTime"}
|
||||
{{/items.isDateTime
|
||||
}}{{^isPrimitiveType}}{{^items.isDate}}{{^items.isDateTime
|
||||
}} * {"name":"TypeCompliant", "options":{"type":{{>list_item_type}}}}
|
||||
{{/isDateTime}}{{/isDate}}{{/isPrimitiveType
|
||||
{{/items.isDateTime}}{{/items.isDate}}{{/isPrimitiveType
|
||||
}} * }})
|
||||
{{/isArray
|
||||
}}{{#isMap
|
||||
}} * @DTA\Strategy(name="{{#isPrimitiveType}}ScalarMap{{/isPrimitiveType}}{{^isPrimitiveType}}ObjectMap{{/isPrimitiveType}}", options={"type":{{>map_item_type}}})
|
||||
{{#minProperties}}{{^maxProperties
|
||||
}}{{#isPrimitiveType
|
||||
}} * @DTA\Strategy(name="ScalarMap", options={"type":{{>map_item_type}}})
|
||||
{{/isPrimitiveType
|
||||
}}{{#additionalProperties.isDate
|
||||
}} * @DTA\Strategy(name="DateMap")
|
||||
{{/additionalProperties.isDate
|
||||
}}{{#additionalProperties.isDateTime
|
||||
}} * @DTA\Strategy(name="DateTimeMap")
|
||||
{{/additionalProperties.isDateTime
|
||||
}}{{^isPrimitiveType}}{{^additionalProperties.isDate}}{{^additionalProperties.isDateTime
|
||||
}} * @DTA\Strategy(name="ObjectMap", options={"type":{{>map_item_type}}})
|
||||
{{/additionalProperties.isDateTime}}{{/additionalProperties.isDate}}{{/isPrimitiveType
|
||||
}}{{#minProperties}}{{^maxProperties
|
||||
}} * @DTA\Validator(name="Count", options={"min":{{minProperties}}}, blocker=true)
|
||||
{{/maxProperties}}{{/minProperties
|
||||
}}{{^minProperties}}{{#maxProperties
|
||||
@@ -41,15 +63,15 @@
|
||||
{{#isPrimitiveType
|
||||
}} * {"name":"Scalar", "options":{"type":{{>map_item_type}}}}
|
||||
{{/isPrimitiveType
|
||||
}}{{#isDate
|
||||
}}{{#additionalProperties.isDate
|
||||
}} * {"name":"Date"}
|
||||
{{/isDate
|
||||
}}{{#isDateTime
|
||||
}} * {"name":"Date", "options":{"format": \DateTime::RFC3339}}
|
||||
{{/isDateTime
|
||||
}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime
|
||||
{{/additionalProperties.isDate
|
||||
}}{{#additionalProperties.isDateTime
|
||||
}} * {"name":"DateTime"}
|
||||
{{/additionalProperties.isDateTime
|
||||
}}{{^isPrimitiveType}}{{^additionalProperties.isDate}}{{^additionalProperties.isDateTime
|
||||
}} * {"name":"TypeCompliant", "options":{"type":{{>map_item_type}}}}
|
||||
{{/isDateTime}}{{/isDate}}{{/isPrimitiveType
|
||||
{{/additionalProperties.isDateTime}}{{/additionalProperties.isDate}}{{/isPrimitiveType
|
||||
}} * }})
|
||||
{{/isMap
|
||||
}}{{/vars
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
{{/isDate
|
||||
}}{{#isDateTime
|
||||
}} * @DTA\Strategy(name="DateTime")
|
||||
* @DTA\Validator(name="Date", options={"format": \DateTime::RFC3339})
|
||||
* @DTA\Validator(name="DateTime")
|
||||
{{/isDateTime
|
||||
}}{{^isPrimitiveType
|
||||
}}{{^isDate
|
||||
@@ -25,21 +25,24 @@
|
||||
}}{{/isContainer
|
||||
}}{{#hasValidation
|
||||
}}{{#minLength}}{{#maxLength
|
||||
}} * @DTA\Validator(name="StringLength", options={"min":{{minLength}}, "max":{{maxLength}}})
|
||||
}} * @DTA\Validator(name="Length", options={"min":{{minLength}}, "max":{{maxLength}}})
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{^minLength}}{{#maxLength
|
||||
}} * @DTA\Validator(name="StringLength", options={"max":{{maxLength}}})
|
||||
}} * @DTA\Validator(name="Length", options={"max":{{maxLength}}})
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{#minLength}}{{^maxLength
|
||||
}} * @DTA\Validator(name="StringLength", options={"min":{{minLength}}})
|
||||
}} * @DTA\Validator(name="Length", options={"min":{{minLength}}})
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{#minimum
|
||||
}} * @DTA\Validator(name="GreaterThan", options={"min":{{minimum}}{{^exclusiveMinimum}}, "inclusive":true{{/exclusiveMinimum}}})
|
||||
{{/minimum
|
||||
}}{{#maximum
|
||||
}} * @DTA\Validator(name="LessThan", options={"max":{{maximum}}{{^exclusiveMaximum}}, "inclusive":true{{/exclusiveMaximum}}})
|
||||
{{/maximum
|
||||
}}{{#minimum}}{{#maximum
|
||||
}} * @DTA\Validator(name="Range", options={"min":{{minimum}}, "max":{{maximum}}{{#exclusiveMinimum}}, "exclude_min":true{{/exclusiveMinimum}}{{#exclusiveMaximum}}, "exclude_max":true{{/exclusiveMaximum}}})
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{^minimum}}{{#maximum
|
||||
}} * @DTA\Validator(name="Range", options={"max":{{maximum}}{{#exclusiveMaximum}}, "exclude_max":true{{/exclusiveMaximum}}})
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{#minimum}}{{^maximum
|
||||
}} * @DTA\Validator(name="Range", options={"min":{{minimum}}{{#exclusiveMinimum}}, "exclude_min":true{{/exclusiveMinimum}}})
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{#pattern
|
||||
}} * @DTA\Validator(name="Regex", options={"pattern":"{{{pattern}}}"})
|
||||
}} * @DTA\Validator(name="Match", options={"pattern":"{{{pattern}}}"})
|
||||
{{/pattern
|
||||
}}{{/hasValidation}}
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
{{#description
|
||||
}} * {{description}}
|
||||
}}/**
|
||||
* {{description}}
|
||||
*/
|
||||
{{/description
|
||||
}} */
|
||||
class {{classname}}
|
||||
}}class {{classname}}
|
||||
{
|
||||
{{#vars
|
||||
}} /**
|
||||
@@ -16,9 +16,8 @@ class {{classname}}
|
||||
}}{{^internal.fromParameters}}{{>model_normal_var}}{{/internal.fromParameters
|
||||
}}{{/vendorExtensions
|
||||
}}{{^vendorExtensions}}{{>model_normal_var}}{{/vendorExtensions
|
||||
}} * @var {{dataType}}|null
|
||||
*/
|
||||
public ${{name}};
|
||||
}} */
|
||||
public ?{{dataType}} ${{name}} = null;
|
||||
|
||||
{{/vars
|
||||
}}}
|
||||
@@ -21,7 +21,7 @@
|
||||
{{/isDate
|
||||
}}{{#isDateTime
|
||||
}} * @DTA\Strategy(subset="{{internal.parameterLocation}}", name="DateTime")
|
||||
* @DTA\Validator(subset="{{internal.parameterLocation}}", name="Date", options={"format": \DateTime::RFC3339})
|
||||
* @DTA\Validator(subset="{{internal.parameterLocation}}", name="DateTime")
|
||||
{{/isDateTime
|
||||
}}{{^isPrimitiveType
|
||||
}}{{^isDate}}{{^isDateTime
|
||||
@@ -31,21 +31,24 @@
|
||||
}}{{/isContainer
|
||||
}}{{#hasValidation
|
||||
}}{{#minLength}}{{#maxLength
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="StringLength", options={"min":{{minLength}}, "max":{{maxLength}}})
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="Length", options={"min":{{minLength}}, "max":{{maxLength}}})
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{^minLength}}{{#maxLength
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="StringLength", options={"max":{{maxLength}}})
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="Length", options={"max":{{maxLength}}})
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{#minLength}}{{^maxLength
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="StringLength", options={"min":{{minLength}}})
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="Length", options={"min":{{minLength}}})
|
||||
{{/maxLength}}{{/minLength
|
||||
}}{{#minimum
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="GreaterThan", options={"min":{{minimum}}{{^exclusiveMinimum}}, "inclusive":true{{/exclusiveMinimum}}})
|
||||
{{/minimum
|
||||
}}{{#maximum
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="LessThan", options={"max":{{maximum}}{{^exclusiveMaximum}}, "inclusive":true{{/exclusiveMaximum}}})
|
||||
{{/maximum
|
||||
}}{{#minimum}}{{#maximum
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="Range", options={"min":{{minimum}}, "max":{{maximum}}{{#exclusiveMinimum}}, "exclude_min":true{{/exclusiveMinimum}}{{#exclusiveMaximum}}, "exclude_max":true{{/exclusiveMaximum}}})
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{^minimum}}{{#maximum
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="Range", options={"max":{{maximum}}{{#exclusiveMaximum}}, "exclude_max":true{{/exclusiveMaximum}}})
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{#minimum}}{{^maximum
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="Range", options={"min":{{minimum}}{{#exclusiveMinimum}}, "exclude_min":true{{/exclusiveMinimum}}})
|
||||
{{/maximum}}{{/minimum
|
||||
}}{{#pattern
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="Regex", options={"pattern":"{{{pattern}}}"})
|
||||
}} * @DTA\Validator(subset="{{internal.parameterLocation}}", name="Match", options={"pattern":"{{{pattern}}}"})
|
||||
{{/pattern
|
||||
}}{{/hasValidation}}
|
||||
@@ -5,8 +5,8 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
## Overview
|
||||
This lightweight extensible client library is [PSR-7](https://www.php-fig.org/psr/psr-7), [PSR-11](https://www.php-fig.org/psr/psr-11), [PSR-17](https://www.php-fig.org/psr/psr-17) and [PSR-18](https://www.php-fig.org/psr/psr-18) complaint and relies on:
|
||||
|
||||
- PHP: >=8.0
|
||||
- [Data Transfer](https://github.com/Articus/DataTransfer): >=0.5
|
||||
- PHP: >=8.1
|
||||
- [Data Transfer](https://github.com/Articus/DataTransfer): >=0.6
|
||||
|
||||
|
||||
## How to use
|
||||
@@ -21,7 +21,7 @@ Then check content types for API requests you intend to send and API responses y
|
||||
|
||||
After that review security requirements for API operations you intend to use. For each unique security scheme you will need an implementation of [OpenAPIGenerator\APIClient\SecurityProviderInterface](https://github.com/Articus/OpenAPIGeneratorAPIClient-PHP/blob/master/src/OpenAPIGenerator/APIClient/SecurityProviderInterface.php). Currently, only [HTTP Bearer authentication](https://github.com/Articus/OpenAPIGeneratorAPIClient-PHP/blob/master/src/OpenAPIGenerator/APIClient/SecurityProvider/HttpBearer.php) is supported out-of-the-box.
|
||||
|
||||
The last step is to configure and wire all services together. It is highly advisable to use [PSR-11 container](https://packagist.org/packages/psr/container) for that. If you have not selected one for your project yet, https://packagist.org/providers/psr/container-implementation may help to find some suitable options. Here is a sample wiring configuration for `"laminas/laminas-servicemanager"`, `"laminas/laminas-diactoros"` and `"symfony/http-client"` (consult generated `composer.json` for the exact versions of used packages):
|
||||
The last step is to configure and wire all services together. It is highly advisable to use [PSR-11 container](https://packagist.org/packages/psr/container) for that. If you have not selected one for your project yet, https://packagist.org/providers/psr/container-implementation may help to find some suitable options. Here is a sample wiring configuration for `"laminas/laminas-servicemanager"`, `"nyholm/psr7"` and `"symfony/http-client"` (consult generated `composer.json` for the exact versions of used packages):
|
||||
|
||||
```PHP
|
||||
<?php
|
||||
@@ -31,21 +31,24 @@ require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$dependencies = [
|
||||
'invokables' => [
|
||||
Psr\Http\Message\RequestFactoryInterface::class => Laminas\Diactoros\RequestFactory::class,
|
||||
Psr\Http\Message\ResponseFactoryInterface::class => Laminas\Diactoros\ResponseFactory::class,
|
||||
Psr\Http\Message\StreamFactoryInterface::class => Laminas\Diactoros\StreamFactory::class,
|
||||
Psr\Http\Message\RequestFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
Psr\Http\Message\ResponseFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
Psr\Http\Message\StreamFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
],
|
||||
'factories' => [
|
||||
App\ApiClient::class => App\ApiClientFactory::class,
|
||||
|
||||
Articus\DataTransfer\Service::class => Articus\DataTransfer\Factory::class,
|
||||
Articus\DataTransfer\MetadataProvider\PhpAttribute::class => Articus\DataTransfer\MetadataProvider\Factory\PhpAttribute::class,
|
||||
Articus\DataTransfer\Strategy\PluginManager::class => Articus\DataTransfer\Strategy\Factory\PluginManager::class,
|
||||
Articus\DataTransfer\Validator\PluginManager::class => Articus\DataTransfer\Validator\Factory\PluginManager::class,
|
||||
Laminas\Validator\ValidatorPluginManager::class => Laminas\Validator\ValidatorPluginManagerFactory::class,
|
||||
Articus\DataTransfer\Options::DEFAULT_STRATEGY_PLUGIN_MANAGER => [Articus\PluginManager\Factory\Chain::class, 'app_dt_strategy_manager_chain'],
|
||||
'oas_dt_strategy_manager' => OpenAPIGenerator\Common\Strategy\Factory\PluginManager::class,
|
||||
'app_dt_strategy_manager' => Articus\DataTransfer\Strategy\Factory\SimplePluginManager::class,
|
||||
Articus\DataTransfer\Options::DEFAULT_VALIDATOR_PLUGIN_MANAGER => [Articus\PluginManager\Factory\Chain::class, 'app_dt_validator_manager_chain'],
|
||||
'oas_dt_validator_manager' => OpenAPIGenerator\Common\Validator\Factory\PluginManager::class,
|
||||
'app_dt_validator_manager' => Articus\DataTransfer\Validator\Factory\SimplePluginManager::class,
|
||||
|
||||
OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class => OpenAPIGenerator\APIClient\SecurityProvider\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\BodyCoder\PluginManager::class => OpenAPIGenerator\APIClient\BodyCoder\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_BODY_CODER_PLUGIN_MANAGER => OpenAPIGenerator\APIClient\BodyCoder\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER => OpenAPIGenerator\APIClient\SecurityProvider\Factory\PluginManager::class,
|
||||
|
||||
Psr\Http\Client\ClientInterface::class => function (Psr\Container\ContainerInterface $container)
|
||||
{
|
||||
@@ -64,34 +67,17 @@ $dependencies = [
|
||||
$config = [
|
||||
'dependencies' => $dependencies,
|
||||
|
||||
//Configure DataTransfer library
|
||||
Articus\DataTransfer\Strategy\PluginManager::class => [
|
||||
'invokables' => [
|
||||
'QueryStringScalar' => OpenAPIGenerator\Common\Strategy\QueryStringScalar::class,
|
||||
'QueryStringScalarArray' => OpenAPIGenerator\Common\Strategy\QueryStringScalarArray::class,
|
||||
],
|
||||
'factories' => [
|
||||
'Date' => OpenAPIGenerator\Common\Strategy\Factory\ImmutableDate::class,
|
||||
'DateTime' => OpenAPIGenerator\Common\Strategy\Factory\ImmutableDateTime::class,
|
||||
'ObjectList' => OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectList::class,
|
||||
'ObjectMap' => OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectMap::class,
|
||||
'ScalarList' => OpenAPIGenerator\Common\Strategy\Factory\ScalarList::class,
|
||||
'ScalarMap' => OpenAPIGenerator\Common\Strategy\Factory\ScalarMap::class,
|
||||
]
|
||||
],
|
||||
Articus\DataTransfer\Validator\PluginManager::class => [
|
||||
'invokables' => [
|
||||
'Scalar' => OpenAPIGenerator\Common\Validator\Scalar::class,
|
||||
'QueryStringScalar' => OpenAPIGenerator\Common\Validator\QueryStringScalar::class,
|
||||
'QueryStringScalarArray' => OpenAPIGenerator\Common\Validator\QueryStringScalarArray::class,
|
||||
],
|
||||
'abstract_factories' => [
|
||||
Articus\DataTransfer\Validator\Factory\Laminas::class,
|
||||
//Configure DataTransfer library: add pack of extra strategies and pack of extra validators
|
||||
'app_dt_strategy_manager_chain' => [
|
||||
'managers' => [
|
||||
'oas_dt_strategy_manager',
|
||||
'app_dt_strategy_manager',
|
||||
],
|
||||
],
|
||||
'validators' => [
|
||||
'invokables' => [
|
||||
'Count' => Laminas\Validator\IsCountable::class,
|
||||
'app_dt_validator_manager_chain' => [
|
||||
'managers' => [
|
||||
'oas_dt_validator_manager',
|
||||
'app_dt_validator_manager',
|
||||
],
|
||||
],
|
||||
|
||||
@@ -101,19 +87,19 @@ $config = [
|
||||
],
|
||||
|
||||
//Register body coders for used content types here
|
||||
OpenAPIGenerator\APIClient\BodyCoder\PluginManager::class => [
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_BODY_CODER_PLUGIN_MANAGER => [
|
||||
'factories' => [
|
||||
//'another/mime-type' => AnotherMimeTypeBodyCoder::class
|
||||
],
|
||||
],
|
||||
|
||||
//Register security providers for used security schemes here
|
||||
OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class => [
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER => [
|
||||
'factories' => [
|
||||
//'another-security-scheme' => AnotherSecuritySchemeProvider::class,
|
||||
],
|
||||
'aliases' => [
|
||||
//'custom-name-for-htt-bearer' => OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class,
|
||||
//'custom-name-for-http-bearer' => OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -126,10 +112,10 @@ $client = $container->get(App\ApiClient::class);
|
||||
//... and now you can use client methods to call API operations :)
|
||||
|
||||
//And one more sample: how to set token for HTTP Bearer authentication
|
||||
/** @var OpenAPIGenerator\APIClient\SecurityProvider\PluginManager $securityProviders */
|
||||
$securityProviders = $container->get(OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class);
|
||||
/** @var Articus\PluginManager\PluginManagerInterface $securityProviders */
|
||||
$securityProviders = $container->get(OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER);
|
||||
/** @var OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer $httpBearer */
|
||||
$httpBearer = $securityProviders->get(OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class);
|
||||
$httpBearer = $securityProviders(OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class, []);
|
||||
$httpBearer->setToken('some-token');
|
||||
|
||||
```
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
{
|
||||
"name": "git_user_id/git_repo_id",
|
||||
"description": "",
|
||||
"version": "1.0.0",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"openapi",
|
||||
"php",
|
||||
@@ -17,14 +15,15 @@
|
||||
"homepage": "https://openapi-generator.tech"
|
||||
}
|
||||
],
|
||||
"version": "1.0.0",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": "^8.0",
|
||||
"articus/data-transfer": "^0.5",
|
||||
"articus/openapi-generator-common": "^0.2",
|
||||
"articus/openapi-generator-apiclient": "^0.1",
|
||||
"php": "^8.1",
|
||||
"articus/data-transfer": "^0.6",
|
||||
"articus/openapi-generator-common": "^0.3",
|
||||
"articus/openapi-generator-apiclient": "^0.2",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"laminas/laminas-stdlib": "^3.2",
|
||||
"laminas/laminas-validator": "^2.13"
|
||||
"laminas/laminas-stdlib": "^3.18"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -32,8 +31,8 @@
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"laminas/laminas-servicemanager": "^3.6",
|
||||
"laminas/laminas-diactoros": "^2.6",
|
||||
"symfony/http-client": "^5.3"
|
||||
"laminas/laminas-servicemanager": "^3.22",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"symfony/http-client": "^6.4 || ^7.0"
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
@@ -43,7 +43,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
@@ -60,6 +60,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->addPetRaw($requestContent, $security, $requestMediaType, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -70,14 +72,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid input */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Pet
|
||||
@@ -101,7 +103,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Create user
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -122,7 +124,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Create user
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -137,20 +139,22 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->createUserRaw($requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
default:
|
||||
/* successful operation */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -172,7 +176,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -193,7 +197,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -208,20 +212,22 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->createUsersWithArrayInputRaw($requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
default:
|
||||
/* successful operation */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -243,7 +249,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -264,7 +270,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -279,20 +285,22 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->createUsersWithListInputRaw($requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
default:
|
||||
/* successful operation */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -340,6 +348,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->deleteOrderRaw($parameters);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 400:
|
||||
@@ -349,7 +359,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Order not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -374,7 +384,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param \App\DTO\DeletePetParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -393,7 +403,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param \App\DTO\DeletePetParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -406,20 +416,22 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->deletePetRaw($parameters, $security);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 400:
|
||||
/* Invalid pet value */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param \App\DTO\DeletePetParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -439,7 +451,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Delete user
|
||||
* @param \App\DTO\DeleteUserParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -457,7 +469,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Delete user
|
||||
* @param \App\DTO\DeleteUserParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -470,6 +482,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->deleteUserRaw($parameters, $security);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 400:
|
||||
@@ -479,14 +493,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* User not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
* @param \App\DTO\DeleteUserParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -506,7 +520,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* @param \App\DTO\FindPetsByStatusParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -527,7 +541,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* @param \App\DTO\FindPetsByStatusParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -542,6 +556,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->findPetsByStatusRaw($parameters, $security, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -552,14 +568,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid status value */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* @param \App\DTO\FindPetsByStatusParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Collection3
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -581,7 +597,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* @param \App\DTO\FindPetsByTagsParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -602,7 +618,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* @param \App\DTO\FindPetsByTagsParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -617,6 +633,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->findPetsByTagsRaw($parameters, $security, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -627,14 +645,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid tag value */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* @param \App\DTO\FindPetsByTagsParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Collection6
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -655,7 +673,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
//region getInventory
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -674,7 +692,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -688,6 +706,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->getInventoryRaw($security, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -695,13 +715,13 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
$responseContent = new \App\DTO\Collection8();
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Collection8
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -753,6 +773,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->getOrderByIdRaw($parameters, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -766,7 +788,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Order not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -793,7 +815,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Find pet by ID
|
||||
* @param \App\DTO\GetPetByIdParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -814,7 +836,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Find pet by ID
|
||||
* @param \App\DTO\GetPetByIdParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -829,6 +851,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->getPetByIdRaw($parameters, $security, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -842,14 +866,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Pet not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
* @param \App\DTO\GetPetByIdParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Pet
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -902,6 +926,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->getUserByNameRaw($parameters, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -915,7 +941,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* User not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -973,6 +999,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->loginUserRaw($parameters, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -982,7 +1010,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid username/password supplied */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1008,7 +1036,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
//region logoutUser
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -1024,7 +1052,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -1036,19 +1064,21 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->logoutUserRaw($security);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
default:
|
||||
/* successful operation */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -1103,6 +1133,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->placeOrderRaw($requestContent, $requestMediaType, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -1113,7 +1145,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid Order */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1142,7 +1174,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
@@ -1166,7 +1198,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
@@ -1183,6 +1215,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->updatePetRaw($requestContent, $security, $requestMediaType, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -1199,14 +1233,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Validation exception */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Pet
|
||||
@@ -1231,7 +1265,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updates a pet in the store with form data
|
||||
* @param \App\DTO\UpdatePetWithFormParameterData $parameters
|
||||
* @param \App\DTO\UpdatePetWithFormRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1254,7 +1288,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updates a pet in the store with form data
|
||||
* @param \App\DTO\UpdatePetWithFormParameterData $parameters
|
||||
* @param \App\DTO\UpdatePetWithFormRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1270,13 +1304,15 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->updatePetWithFormRaw($parameters, $requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 405:
|
||||
/* Invalid input */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1284,7 +1320,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updates a pet in the store with form data
|
||||
* @param \App\DTO\UpdatePetWithFormParameterData $parameters
|
||||
* @param \App\DTO\UpdatePetWithFormRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1308,7 +1344,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updated user
|
||||
* @param \App\DTO\UpdateUserParameterData $parameters
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1331,7 +1367,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updated user
|
||||
* @param \App\DTO\UpdateUserParameterData $parameters
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1347,6 +1383,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->updateUserRaw($parameters, $requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 400:
|
||||
@@ -1356,7 +1394,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* User not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1364,7 +1402,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updated user
|
||||
* @param \App\DTO\UpdateUserParameterData $parameters
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1388,7 +1426,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* uploads an image
|
||||
* @param \App\DTO\UploadFileParameterData $parameters
|
||||
* @param \App\DTO\UploadFileRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
@@ -1414,7 +1452,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* uploads an image
|
||||
* @param \App\DTO\UploadFileParameterData $parameters
|
||||
* @param \App\DTO\UploadFileRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
@@ -1432,6 +1470,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->uploadFileRaw($parameters, $requestContent, $security, $requestMediaType, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -1439,7 +1479,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
$responseContent = new \App\DTO\ApiResponse();
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1447,7 +1487,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* uploads an image
|
||||
* @param \App\DTO\UploadFileParameterData $parameters
|
||||
* @param \App\DTO\UploadFileRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\ApiResponse
|
||||
|
||||
@@ -3,18 +3,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace App;
|
||||
|
||||
use Articus\DataTransfer as DT;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Articus\PluginManager as PM;
|
||||
use OpenAPIGenerator\APIClient as OAGAC;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class ApiClientFactory extends DT\ConfigAwareFactory
|
||||
class ApiClientFactory implements PM\ServiceFactoryInterface
|
||||
{
|
||||
use PM\ConfigAwareFactoryTrait;
|
||||
|
||||
public function __construct(string $configKey = ApiClient::class)
|
||||
{
|
||||
parent::__construct($configKey);
|
||||
$this->configKey = $configKey;
|
||||
}
|
||||
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): ApiClient
|
||||
{
|
||||
$config = new OAGAC\ApiClientOptions(\array_merge($this->getServiceConfig($container), $options ?? []));
|
||||
return new ApiClient(
|
||||
@@ -24,7 +26,9 @@ class ApiClientFactory extends DT\ConfigAwareFactory
|
||||
$container->get($config->httpClientServiceName),
|
||||
$container->get($config->securityProviderFactoryServiceName),
|
||||
$container->get($config->bodyCoderFactoryServiceName),
|
||||
$container->get($config->bodyCoderFactoryServiceName)
|
||||
$container->get($config->bodyCoderFactoryServiceName),
|
||||
$container->get($config->contentStrategyFactoryServiceName),
|
||||
$container->get($config->contentValidatorFactoryServiceName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ class Category
|
||||
|
||||
#[DTA\Data(field: "name", nullable: true)]
|
||||
#[DTA\Validator("Scalar", ["type" => "string"])]
|
||||
#[DTA\Validator("Regex", ["pattern" => "/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"])]
|
||||
#[DTA\Validator("Match", ["pattern" => "/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"])]
|
||||
public string|null $name = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@ class GetOrderByIdParameterData
|
||||
#[DTA\Data(subset: "path", field: "orderId")]
|
||||
#[DTA\Strategy("QueryStringScalar", ["type" => "int"], "path")]
|
||||
#[DTA\Validator("QueryStringScalar", ["type" => "int"], subset: "path")]
|
||||
#[DTA\Validator("GreaterThan", ["min" => 1, "inclusive" => true], subset: "path")]
|
||||
#[DTA\Validator("LessThan", ["max" => 5, "inclusive" => true], subset: "path")]
|
||||
#[DTA\Validator("Range", ["min" => 1, "max" => 5], subset: "path")]
|
||||
public int|null $order_id = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class LoginUserParameterData
|
||||
#[DTA\Data(subset: "query", field: "username")]
|
||||
#[DTA\Strategy("QueryStringScalar", ["type" => "string"], "query")]
|
||||
#[DTA\Validator("QueryStringScalar", ["type" => "string"], subset: "query")]
|
||||
#[DTA\Validator("Regex", ["pattern" => "/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"], subset: "query")]
|
||||
#[DTA\Validator("Match", ["pattern" => "/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"], subset: "query")]
|
||||
public string|null $username = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ class Order
|
||||
|
||||
#[DTA\Data(field: "shipDate", nullable: true)]
|
||||
#[DTA\Strategy("DateTime")]
|
||||
#[DTA\Validator("Date", ["format" => \DateTime::RFC3339])]
|
||||
public \DateTime|null $ship_date = null;
|
||||
#[DTA\Validator("DateTime")]
|
||||
public \DateTimeInterface|null $ship_date = null;
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
|
||||
@@ -18,8 +18,7 @@ class UploadFileRequest
|
||||
* file to upload
|
||||
*/
|
||||
#[DTA\Data(field: "file", nullable: true)]
|
||||
#[DTA\Strategy("Object", ["type" => \SplFileObject::class])]
|
||||
#[DTA\Validator("TypeCompliant", ["type" => \SplFileObject::class])]
|
||||
public \SplFileObject|null $file = null;
|
||||
#[DTA\Validator("Scalar", ["type" => "string"])]
|
||||
public string|null $file = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
## Overview
|
||||
This lightweight extensible client library is [PSR-7](https://www.php-fig.org/psr/psr-7), [PSR-11](https://www.php-fig.org/psr/psr-11), [PSR-17](https://www.php-fig.org/psr/psr-17) and [PSR-18](https://www.php-fig.org/psr/psr-18) complaint and relies on:
|
||||
|
||||
- PHP: >=7.3
|
||||
- [Data Transfer](https://github.com/Articus/DataTransfer): >=0.5
|
||||
- PHP: >=7.4
|
||||
- [Data Transfer](https://github.com/Articus/DataTransfer): >=0.6
|
||||
|
||||
|
||||
## How to use
|
||||
@@ -21,7 +21,7 @@ Then check content types for API requests you intend to send and API responses y
|
||||
|
||||
After that review security requirements for API operations you intend to use. For each unique security scheme you will need an implementation of [OpenAPIGenerator\APIClient\SecurityProviderInterface](https://github.com/Articus/OpenAPIGeneratorAPIClient-PHP/blob/master/src/OpenAPIGenerator/APIClient/SecurityProviderInterface.php). Currently, only [HTTP Bearer authentication](https://github.com/Articus/OpenAPIGeneratorAPIClient-PHP/blob/master/src/OpenAPIGenerator/APIClient/SecurityProvider/HttpBearer.php) is supported out-of-the-box.
|
||||
|
||||
The last step is to configure and wire all services together. It is highly advisable to use [PSR-11 container](https://packagist.org/packages/psr/container) for that. If you have not selected one for your project yet, https://packagist.org/providers/psr/container-implementation may help to find some suitable options. Here is a sample wiring configuration for `"laminas/laminas-servicemanager"`, `"laminas/laminas-diactoros"` and `"symfony/http-client"` (consult generated `composer.json` for the exact versions of used packages):
|
||||
The last step is to configure and wire all services together. It is highly advisable to use [PSR-11 container](https://packagist.org/packages/psr/container) for that. If you have not selected one for your project yet, https://packagist.org/providers/psr/container-implementation may help to find some suitable options. Here is a sample wiring configuration for `"laminas/laminas-servicemanager"`, `"nyholm/psr7"` and `"symfony/http-client"` (consult generated `composer.json` for the exact versions of used packages):
|
||||
|
||||
```PHP
|
||||
<?php
|
||||
@@ -31,21 +31,24 @@ require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
$dependencies = [
|
||||
'invokables' => [
|
||||
Psr\Http\Message\RequestFactoryInterface::class => Laminas\Diactoros\RequestFactory::class,
|
||||
Psr\Http\Message\ResponseFactoryInterface::class => Laminas\Diactoros\ResponseFactory::class,
|
||||
Psr\Http\Message\StreamFactoryInterface::class => Laminas\Diactoros\StreamFactory::class,
|
||||
Psr\Http\Message\RequestFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
Psr\Http\Message\ResponseFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
Psr\Http\Message\StreamFactoryInterface::class => Nyholm\Psr7\Factory\Psr17Factory::class,
|
||||
],
|
||||
'factories' => [
|
||||
App\ApiClient::class => App\ApiClientFactory::class,
|
||||
|
||||
Articus\DataTransfer\Service::class => Articus\DataTransfer\Factory::class,
|
||||
Articus\DataTransfer\MetadataProvider\Annotation::class => Articus\DataTransfer\MetadataProvider\Factory\Annotation::class,
|
||||
Articus\DataTransfer\Strategy\PluginManager::class => Articus\DataTransfer\Strategy\Factory\PluginManager::class,
|
||||
Articus\DataTransfer\Validator\PluginManager::class => Articus\DataTransfer\Validator\Factory\PluginManager::class,
|
||||
Laminas\Validator\ValidatorPluginManager::class => Laminas\Validator\ValidatorPluginManagerFactory::class,
|
||||
Articus\DataTransfer\Options::DEFAULT_STRATEGY_PLUGIN_MANAGER => [Articus\PluginManager\Factory\Chain::class, 'app_dt_strategy_manager_chain'],
|
||||
'oas_dt_strategy_manager' => OpenAPIGenerator\Common\Strategy\Factory\PluginManager::class,
|
||||
'app_dt_strategy_manager' => Articus\DataTransfer\Strategy\Factory\SimplePluginManager::class,
|
||||
Articus\DataTransfer\Options::DEFAULT_VALIDATOR_PLUGIN_MANAGER => [Articus\PluginManager\Factory\Chain::class, 'app_dt_validator_manager_chain'],
|
||||
'oas_dt_validator_manager' => OpenAPIGenerator\Common\Validator\Factory\PluginManager::class,
|
||||
'app_dt_validator_manager' => Articus\DataTransfer\Validator\Factory\SimplePluginManager::class,
|
||||
|
||||
OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class => OpenAPIGenerator\APIClient\SecurityProvider\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\BodyCoder\PluginManager::class => OpenAPIGenerator\APIClient\BodyCoder\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_BODY_CODER_PLUGIN_MANAGER => OpenAPIGenerator\APIClient\BodyCoder\Factory\PluginManager::class,
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER => OpenAPIGenerator\APIClient\SecurityProvider\Factory\PluginManager::class,
|
||||
|
||||
Psr\Http\Client\ClientInterface::class => function (Psr\Container\ContainerInterface $container)
|
||||
{
|
||||
@@ -64,34 +67,17 @@ $dependencies = [
|
||||
$config = [
|
||||
'dependencies' => $dependencies,
|
||||
|
||||
//Configure DataTransfer library
|
||||
Articus\DataTransfer\Strategy\PluginManager::class => [
|
||||
'invokables' => [
|
||||
'QueryStringScalar' => OpenAPIGenerator\Common\Strategy\QueryStringScalar::class,
|
||||
'QueryStringScalarArray' => OpenAPIGenerator\Common\Strategy\QueryStringScalarArray::class,
|
||||
],
|
||||
'factories' => [
|
||||
'Date' => OpenAPIGenerator\Common\Strategy\Factory\ImmutableDate::class,
|
||||
'DateTime' => OpenAPIGenerator\Common\Strategy\Factory\ImmutableDateTime::class,
|
||||
'ObjectList' => OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectList::class,
|
||||
'ObjectMap' => OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectMap::class,
|
||||
'ScalarList' => OpenAPIGenerator\Common\Strategy\Factory\ScalarList::class,
|
||||
'ScalarMap' => OpenAPIGenerator\Common\Strategy\Factory\ScalarMap::class,
|
||||
]
|
||||
],
|
||||
Articus\DataTransfer\Validator\PluginManager::class => [
|
||||
'invokables' => [
|
||||
'Scalar' => OpenAPIGenerator\Common\Validator\Scalar::class,
|
||||
'QueryStringScalar' => OpenAPIGenerator\Common\Validator\QueryStringScalar::class,
|
||||
'QueryStringScalarArray' => OpenAPIGenerator\Common\Validator\QueryStringScalarArray::class,
|
||||
],
|
||||
'abstract_factories' => [
|
||||
Articus\DataTransfer\Validator\Factory\Laminas::class,
|
||||
//Configure DataTransfer library: add pack of extra strategies and pack of extra validators
|
||||
'app_dt_strategy_manager_chain' => [
|
||||
'managers' => [
|
||||
'oas_dt_strategy_manager',
|
||||
'app_dt_strategy_manager',
|
||||
],
|
||||
],
|
||||
'validators' => [
|
||||
'invokables' => [
|
||||
'Count' => Laminas\Validator\IsCountable::class,
|
||||
'app_dt_validator_manager_chain' => [
|
||||
'managers' => [
|
||||
'oas_dt_validator_manager',
|
||||
'app_dt_validator_manager',
|
||||
],
|
||||
],
|
||||
|
||||
@@ -101,19 +87,19 @@ $config = [
|
||||
],
|
||||
|
||||
//Register body coders for used content types here
|
||||
OpenAPIGenerator\APIClient\BodyCoder\PluginManager::class => [
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_BODY_CODER_PLUGIN_MANAGER => [
|
||||
'factories' => [
|
||||
//'another/mime-type' => AnotherMimeTypeBodyCoder::class
|
||||
],
|
||||
],
|
||||
|
||||
//Register security providers for used security schemes here
|
||||
OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class => [
|
||||
OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER => [
|
||||
'factories' => [
|
||||
//'another-security-scheme' => AnotherSecuritySchemeProvider::class,
|
||||
],
|
||||
'aliases' => [
|
||||
//'custom-name-for-htt-bearer' => OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class,
|
||||
//'custom-name-for-http-bearer' => OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -126,10 +112,10 @@ $client = $container->get(App\ApiClient::class);
|
||||
//... and now you can use client methods to call API operations :)
|
||||
|
||||
//And one more sample: how to set token for HTTP Bearer authentication
|
||||
/** @var OpenAPIGenerator\APIClient\SecurityProvider\PluginManager $securityProviders */
|
||||
$securityProviders = $container->get(OpenAPIGenerator\APIClient\SecurityProvider\PluginManager::class);
|
||||
/** @var Articus\PluginManager\PluginManagerInterface $securityProviders */
|
||||
$securityProviders = $container->get(OpenAPIGenerator\APIClient\ApiClientOptions::DEFAULT_SECURITY_PROVIDER_PLUGIN_MANAGER);
|
||||
/** @var OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer $httpBearer */
|
||||
$httpBearer = $securityProviders->get(OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class);
|
||||
$httpBearer = $securityProviders(OpenAPIGenerator\APIClient\SecurityProvider\HttpBearer::class, []);
|
||||
$httpBearer->setToken('some-token');
|
||||
|
||||
```
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
"version": "1.0.0",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": "^7.3 || ^8.0",
|
||||
"articus/data-transfer": "^0.5",
|
||||
"articus/openapi-generator-common": "^0.2",
|
||||
"articus/openapi-generator-apiclient": "^0.1",
|
||||
"doctrine/annotations": "^1.10",
|
||||
"php": "^7.4 || ^8.0",
|
||||
"articus/data-transfer": "^0.6",
|
||||
"articus/openapi-generator-common": "^0.3",
|
||||
"articus/openapi-generator-apiclient": "^0.2",
|
||||
"doctrine/annotations": "^2.0",
|
||||
"psr/simple-cache": "^1.0",
|
||||
"laminas/laminas-stdlib": "^3.2",
|
||||
"laminas/laminas-validator": "^2.13"
|
||||
"laminas/laminas-stdlib": "^3.13"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -33,8 +32,8 @@
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"laminas/laminas-servicemanager": "^3.6",
|
||||
"laminas/laminas-diactoros": "^2.6",
|
||||
"symfony/http-client": "^5.3"
|
||||
"laminas/laminas-servicemanager": "^3.17",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"symfony/http-client": "^5.4"
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
@@ -43,7 +43,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
@@ -60,6 +60,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->addPetRaw($requestContent, $security, $requestMediaType, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -70,14 +72,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid input */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Pet
|
||||
@@ -101,7 +103,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Create user
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -122,7 +124,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Create user
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -137,20 +139,22 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->createUserRaw($requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
default:
|
||||
/* successful operation */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -172,7 +176,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -193,7 +197,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -208,20 +212,22 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->createUsersWithArrayInputRaw($requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
default:
|
||||
/* successful operation */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -243,7 +249,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -264,7 +270,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -279,20 +285,22 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->createUsersWithListInputRaw($requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
default:
|
||||
/* successful operation */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param \App\DTO\Collection10 $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -340,6 +348,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->deleteOrderRaw($parameters);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 400:
|
||||
@@ -349,7 +359,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Order not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -374,7 +384,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param \App\DTO\DeletePetParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -393,7 +403,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param \App\DTO\DeletePetParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -406,20 +416,22 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->deletePetRaw($parameters, $security);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 400:
|
||||
/* Invalid pet value */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param \App\DTO\DeletePetParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -439,7 +451,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Delete user
|
||||
* @param \App\DTO\DeleteUserParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -457,7 +469,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Delete user
|
||||
* @param \App\DTO\DeleteUserParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -470,6 +482,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->deleteUserRaw($parameters, $security);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 400:
|
||||
@@ -479,14 +493,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* User not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
* @param \App\DTO\DeleteUserParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -506,7 +520,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* @param \App\DTO\FindPetsByStatusParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -527,7 +541,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* @param \App\DTO\FindPetsByStatusParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -542,6 +556,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->findPetsByStatusRaw($parameters, $security, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -552,14 +568,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid status value */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* @param \App\DTO\FindPetsByStatusParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Collection3
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -581,7 +597,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* @param \App\DTO\FindPetsByTagsParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -602,7 +618,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* @param \App\DTO\FindPetsByTagsParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -617,6 +633,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->findPetsByTagsRaw($parameters, $security, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -627,14 +645,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid tag value */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* @param \App\DTO\FindPetsByTagsParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Collection6
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -655,7 +673,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
//region getInventory
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -674,7 +692,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -688,6 +706,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->getInventoryRaw($security, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -695,13 +715,13 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
$responseContent = new \App\DTO\Collection8();
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Collection8
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -753,6 +773,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->getOrderByIdRaw($parameters, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -766,7 +788,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Order not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -793,7 +815,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Find pet by ID
|
||||
* @param \App\DTO\GetPetByIdParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -814,7 +836,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Find pet by ID
|
||||
* @param \App\DTO\GetPetByIdParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -829,6 +851,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->getPetByIdRaw($parameters, $security, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -842,14 +866,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Pet not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
* @param \App\DTO\GetPetByIdParameterData $parameters
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Pet
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -902,6 +926,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->getUserByNameRaw($parameters, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -915,7 +941,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* User not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -973,6 +999,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->loginUserRaw($parameters, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -982,7 +1010,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid username/password supplied */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1008,7 +1036,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
//region logoutUser
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -1024,7 +1052,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -1036,19 +1064,21 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->logoutUserRaw($security);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
default:
|
||||
/* successful operation */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws DT\Exception\InvalidData
|
||||
@@ -1103,6 +1133,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->placeOrderRaw($requestContent, $requestMediaType, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -1113,7 +1145,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Invalid Order */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1142,7 +1174,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
@@ -1166,7 +1198,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
@@ -1183,6 +1215,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->updatePetRaw($requestContent, $security, $requestMediaType, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -1199,14 +1233,14 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* Validation exception */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param \App\DTO\Pet $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\Pet
|
||||
@@ -1231,7 +1265,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updates a pet in the store with form data
|
||||
* @param \App\DTO\UpdatePetWithFormParameterData $parameters
|
||||
* @param \App\DTO\UpdatePetWithFormRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1254,7 +1288,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updates a pet in the store with form data
|
||||
* @param \App\DTO\UpdatePetWithFormParameterData $parameters
|
||||
* @param \App\DTO\UpdatePetWithFormRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1270,13 +1304,15 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->updatePetWithFormRaw($parameters, $requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 405:
|
||||
/* Invalid input */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1284,7 +1320,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updates a pet in the store with form data
|
||||
* @param \App\DTO\UpdatePetWithFormParameterData $parameters
|
||||
* @param \App\DTO\UpdatePetWithFormRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1308,7 +1344,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updated user
|
||||
* @param \App\DTO\UpdateUserParameterData $parameters
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1331,7 +1367,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updated user
|
||||
* @param \App\DTO\UpdateUserParameterData $parameters
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return array
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1347,6 +1383,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->updateUserRaw($parameters, $requestContent, $security, $requestMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 400:
|
||||
@@ -1356,7 +1394,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
/* User not found */
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1364,7 +1402,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* Updated user
|
||||
* @param \App\DTO\UpdateUserParameterData $parameters
|
||||
* @param \App\DTO\User $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @return mixed
|
||||
* @throws ClientExceptionInterface
|
||||
@@ -1388,7 +1426,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* uploads an image
|
||||
* @param \App\DTO\UploadFileParameterData $parameters
|
||||
* @param \App\DTO\UploadFileRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return ResponseInterface
|
||||
@@ -1414,7 +1452,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* uploads an image
|
||||
* @param \App\DTO\UploadFileParameterData $parameters
|
||||
* @param \App\DTO\UploadFileRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return array
|
||||
@@ -1432,6 +1470,8 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
{
|
||||
$response = $this->uploadFileRaw($parameters, $requestContent, $security, $requestMediaType, $responseMediaType);
|
||||
$responseContent = null;
|
||||
$contentStrategy = null;
|
||||
$contentValidator = null;
|
||||
switch ($response->getStatusCode())
|
||||
{
|
||||
case 200:
|
||||
@@ -1439,7 +1479,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
$responseContent = new \App\DTO\ApiResponse();
|
||||
break;
|
||||
}
|
||||
$this->parseBody($response, $responseContent);
|
||||
$this->parseBody($response, $responseContent, $contentStrategy, $contentValidator);
|
||||
return [$responseContent, $response->getHeaders(), $response->getStatusCode(), $response->getReasonPhrase()];
|
||||
}
|
||||
|
||||
@@ -1447,7 +1487,7 @@ class ApiClient extends OAGAC\AbstractApiClient
|
||||
* uploads an image
|
||||
* @param \App\DTO\UploadFileParameterData $parameters
|
||||
* @param \App\DTO\UploadFileRequest $requestContent
|
||||
* @param iterable|string[][] $security
|
||||
* @param iterable<string, string[]> $security
|
||||
* @param string $requestMediaType
|
||||
* @param string $responseMediaType
|
||||
* @return \App\DTO\ApiResponse
|
||||
|
||||
@@ -3,18 +3,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace App;
|
||||
|
||||
use Articus\DataTransfer as DT;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Articus\PluginManager as PM;
|
||||
use OpenAPIGenerator\APIClient as OAGAC;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
class ApiClientFactory extends DT\ConfigAwareFactory
|
||||
class ApiClientFactory implements PM\ServiceFactoryInterface
|
||||
{
|
||||
use PM\ConfigAwareFactoryTrait;
|
||||
|
||||
public function __construct(string $configKey = ApiClient::class)
|
||||
{
|
||||
parent::__construct($configKey);
|
||||
$this->configKey = $configKey;
|
||||
}
|
||||
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): ApiClient
|
||||
{
|
||||
$config = new OAGAC\ApiClientOptions(\array_merge($this->getServiceConfig($container), $options ?? []));
|
||||
return new ApiClient(
|
||||
@@ -24,7 +26,9 @@ class ApiClientFactory extends DT\ConfigAwareFactory
|
||||
$container->get($config->httpClientServiceName),
|
||||
$container->get($config->securityProviderFactoryServiceName),
|
||||
$container->get($config->bodyCoderFactoryServiceName),
|
||||
$container->get($config->bodyCoderFactoryServiceName)
|
||||
$container->get($config->bodyCoderFactoryServiceName),
|
||||
$container->get($config->contentStrategyFactoryServiceName),
|
||||
$container->get($config->contentValidatorFactoryServiceName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,22 +13,19 @@ class ApiResponse
|
||||
/**
|
||||
* @DTA\Data(field="code", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $code;
|
||||
public ?int $code = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="type", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $type;
|
||||
public ?string $type = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="message", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $message;
|
||||
public ?string $message = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,16 +13,14 @@ class Category
|
||||
/**
|
||||
* @DTA\Data(field="id", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $id;
|
||||
public ?int $id = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="name", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @DTA\Validator(name="Regex", options={"pattern":"/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"})
|
||||
* @var string|null
|
||||
* @DTA\Validator(name="Match", options={"pattern":"/^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$/"})
|
||||
*/
|
||||
public $name;
|
||||
public ?string $name = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class DeleteOrderParameterData
|
||||
* @DTA\Data(subset="path", field="orderId")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"string"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $order_id;
|
||||
public ?string $order_id = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,16 +15,14 @@ class DeletePetParameterData
|
||||
* @DTA\Data(subset="path", field="petId")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $pet_id;
|
||||
public ?int $pet_id = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(subset="header", field="api_key", nullable=true)
|
||||
* @DTA\Strategy(subset="header", name="QueryStringScalar", options={"type":"string"})
|
||||
* @DTA\Validator(subset="header", name="QueryStringScalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $api_key;
|
||||
public ?string $api_key = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class DeleteUserParameterData
|
||||
* @DTA\Data(subset="path", field="username")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"string"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $username;
|
||||
public ?string $username = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class FindPetsByStatusParameterData
|
||||
* @DTA\Data(subset="query", field="status")
|
||||
* @DTA\Strategy(subset="query", name="QueryStringScalarArray", options={"type":"string", "format":"csv"})
|
||||
* @DTA\Validator(subset="query", name="QueryStringScalarArray", options={"type":"string", "format":"csv"})
|
||||
* @var string[]|null
|
||||
*/
|
||||
public $status;
|
||||
public ?array $status = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class FindPetsByTagsParameterData
|
||||
* @DTA\Data(subset="query", field="tags")
|
||||
* @DTA\Strategy(subset="query", name="QueryStringScalarArray", options={"type":"string", "format":"csv"})
|
||||
* @DTA\Validator(subset="query", name="QueryStringScalarArray", options={"type":"string", "format":"csv"})
|
||||
* @var string[]|null
|
||||
*/
|
||||
public $tags;
|
||||
public ?array $tags = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,10 +15,8 @@ class GetOrderByIdParameterData
|
||||
* @DTA\Data(subset="path", field="orderId")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @DTA\Validator(subset="path", name="GreaterThan", options={"min":1, "inclusive":true})
|
||||
* @DTA\Validator(subset="path", name="LessThan", options={"max":5, "inclusive":true})
|
||||
* @var int|null
|
||||
* @DTA\Validator(subset="path", name="Range", options={"min":1, "max":5})
|
||||
*/
|
||||
public $order_id;
|
||||
public ?int $order_id = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class GetPetByIdParameterData
|
||||
* @DTA\Data(subset="path", field="petId")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $pet_id;
|
||||
public ?int $pet_id = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class GetUserByNameParameterData
|
||||
* @DTA\Data(subset="path", field="username")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"string"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $username;
|
||||
public ?string $username = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,18 +15,16 @@ class LoginUserParameterData
|
||||
* @DTA\Data(subset="query", field="password")
|
||||
* @DTA\Strategy(subset="query", name="QueryStringScalar", options={"type":"string"})
|
||||
* @DTA\Validator(subset="query", name="QueryStringScalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $password;
|
||||
public ?string $password = null;
|
||||
|
||||
/**
|
||||
* The user name for login
|
||||
* @DTA\Data(subset="query", field="username")
|
||||
* @DTA\Strategy(subset="query", name="QueryStringScalar", options={"type":"string"})
|
||||
* @DTA\Validator(subset="query", name="QueryStringScalar", options={"type":"string"})
|
||||
* @DTA\Validator(subset="query", name="Regex", options={"pattern":"/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"})
|
||||
* @var string|null
|
||||
* @DTA\Validator(subset="query", name="Match", options={"pattern":"/^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$/"})
|
||||
*/
|
||||
public $username;
|
||||
public ?string $username = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,45 +13,39 @@ class Order
|
||||
/**
|
||||
* @DTA\Data(field="id", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $id;
|
||||
public ?int $id = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="petId", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $pet_id;
|
||||
public ?int $pet_id = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="quantity", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $quantity;
|
||||
public ?int $quantity = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="shipDate", nullable=true)
|
||||
* @DTA\Strategy(name="DateTime")
|
||||
* @DTA\Validator(name="Date", options={"format": \DateTime::RFC3339})
|
||||
* @var \DateTime|null
|
||||
* @DTA\Validator(name="DateTime")
|
||||
*/
|
||||
public $ship_date;
|
||||
public ?\DateTimeInterface $ship_date = null;
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
* @DTA\Data(field="status", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $status;
|
||||
public ?string $status = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="complete", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"bool"})
|
||||
* @var bool|null
|
||||
*/
|
||||
public $complete;
|
||||
public ?bool $complete = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,47 +13,41 @@ class Pet
|
||||
/**
|
||||
* @DTA\Data(field="id", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $id;
|
||||
public ?int $id = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="category", nullable=true)
|
||||
* @DTA\Strategy(name="Object", options={"type":\App\DTO\Category::class})
|
||||
* @DTA\Validator(name="TypeCompliant", options={"type":\App\DTO\Category::class})
|
||||
* @var \App\DTO\Category|null
|
||||
*/
|
||||
public $category;
|
||||
public ?\App\DTO\Category $category = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="name")
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $name;
|
||||
public ?string $name = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="photoUrls")
|
||||
* @DTA\Strategy(name="Object", options={"type":\App\DTO\Collection::class})
|
||||
* @DTA\Validator(name="TypeCompliant", options={"type":\App\DTO\Collection::class})
|
||||
* @var \App\DTO\Collection|null
|
||||
*/
|
||||
public $photo_urls;
|
||||
public ?\App\DTO\Collection $photo_urls = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="tags", nullable=true)
|
||||
* @DTA\Strategy(name="Object", options={"type":\App\DTO\Collection1::class})
|
||||
* @DTA\Validator(name="TypeCompliant", options={"type":\App\DTO\Collection1::class})
|
||||
* @var \App\DTO\Collection1|null
|
||||
*/
|
||||
public $tags;
|
||||
public ?\App\DTO\Collection1 $tags = null;
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
* @DTA\Data(field="status", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $status;
|
||||
public ?string $status = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,15 +13,13 @@ class Tag
|
||||
/**
|
||||
* @DTA\Data(field="id", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $id;
|
||||
public ?int $id = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="name", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $name;
|
||||
public ?string $name = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class UpdatePetWithFormParameterData
|
||||
* @DTA\Data(subset="path", field="petId")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $pet_id;
|
||||
public ?int $pet_id = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,24 +5,20 @@ namespace App\DTO;
|
||||
|
||||
use Articus\DataTransfer\Annotation as DTA;
|
||||
|
||||
/**
|
||||
*/
|
||||
class UpdatePetWithFormRequest
|
||||
{
|
||||
/**
|
||||
* Updated name of the pet
|
||||
* @DTA\Data(field="name", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $name;
|
||||
public ?string $name = null;
|
||||
|
||||
/**
|
||||
* Updated status of the pet
|
||||
* @DTA\Data(field="status", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $status;
|
||||
public ?string $status = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class UpdateUserParameterData
|
||||
* @DTA\Data(subset="path", field="username")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"string"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $username;
|
||||
public ?string $username = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ class UploadFileParameterData
|
||||
* @DTA\Data(subset="path", field="petId")
|
||||
* @DTA\Strategy(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @DTA\Validator(subset="path", name="QueryStringScalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $pet_id;
|
||||
public ?int $pet_id = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,25 +5,20 @@ namespace App\DTO;
|
||||
|
||||
use Articus\DataTransfer\Annotation as DTA;
|
||||
|
||||
/**
|
||||
*/
|
||||
class UploadFileRequest
|
||||
{
|
||||
/**
|
||||
* Additional data to pass to server
|
||||
* @DTA\Data(field="additionalMetadata", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $additional_metadata;
|
||||
public ?string $additional_metadata = null;
|
||||
|
||||
/**
|
||||
* file to upload
|
||||
* @DTA\Data(field="file", nullable=true)
|
||||
* @DTA\Strategy(name="Object", options={"type":\SplFileObject::class})
|
||||
* @DTA\Validator(name="TypeCompliant", options={"type":\SplFileObject::class})
|
||||
* @var \SplFileObject|null
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
*/
|
||||
public $file;
|
||||
public ?string $file = null;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,58 +13,50 @@ class User
|
||||
/**
|
||||
* @DTA\Data(field="id", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $id;
|
||||
public ?int $id = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="username", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $username;
|
||||
public ?string $username = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="firstName", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $first_name;
|
||||
public ?string $first_name = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="lastName", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $last_name;
|
||||
public ?string $last_name = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="email", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $email;
|
||||
public ?string $email = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="password", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $password;
|
||||
public ?string $password = null;
|
||||
|
||||
/**
|
||||
* @DTA\Data(field="phone", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"string"})
|
||||
* @var string|null
|
||||
*/
|
||||
public $phone;
|
||||
public ?string $phone = null;
|
||||
|
||||
/**
|
||||
* User Status
|
||||
* @DTA\Data(field="userStatus", nullable=true)
|
||||
* @DTA\Validator(name="Scalar", options={"type":"int"})
|
||||
* @var int|null
|
||||
*/
|
||||
public $user_status;
|
||||
public ?int $user_status = null;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user