diff --git a/.github/.test/samples.json b/.github/.test/samples.json index 6a157556aae..1f753ac8fc3 100644 --- a/.github/.test/samples.json +++ b/.github/.test/samples.json @@ -807,7 +807,7 @@ ] }, { - "input": "php-ze-ph-petstore-server.sh", + "input": "php-mezzio-ph-petstore-server.sh", "matches": [ "Server: PHP" ] diff --git a/.gitignore b/.gitignore index 980aad7ded4..26c01a81696 100644 --- a/.gitignore +++ b/.gitignore @@ -176,12 +176,12 @@ samples/client/petstore/python-tornado/.venv/ # PHP samples/client/petstore/php/OpenAPIClient-php/composer.lock samples/openapi3/server/petstore/php-symfony/SymfonyBundle-php/composer.lock -samples/openapi3/server/petstore/php-ze-ph/composer.lock +samples/openapi3/server/petstore/php-mezzio-ph/composer.lock samples/server/petstore/php-laravel/lib/composer.lock samples/server/petstore/php-lumen/lib/composer.lock samples/server/petstore/php-slim4/composer.lock samples/server/petstore/php-symfony/SymfonyBundle-php/composer.lock -samples/server/petstore/php-ze-ph/composer.lock +samples/server/petstore/php-mezzio-ph/composer.lock # ts samples/client/petstore/typescript-angular2/npm/npm-debug.log diff --git a/bin/configs/php-mezzio-ph.yaml b/bin/configs/php-mezzio-ph.yaml new file mode 100644 index 00000000000..614be6ce9fb --- /dev/null +++ b/bin/configs/php-mezzio-ph.yaml @@ -0,0 +1,4 @@ +generatorName: php-mezzio-ph +outputDir: samples/server/petstore/php-mezzio-ph +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml +templateDir: modules/openapi-generator/src/main/resources/php-mezzio-ph diff --git a/bin/configs/php-ze-ph.yaml b/bin/configs/php-ze-ph.yaml deleted file mode 100644 index 009f17a0e43..00000000000 --- a/bin/configs/php-ze-ph.yaml +++ /dev/null @@ -1,4 +0,0 @@ -generatorName: php-ze-ph -outputDir: samples/server/petstore/php-ze-ph -inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml -templateDir: modules/openapi-generator/src/main/resources/php-ze-ph diff --git a/docs/generators.md b/docs/generators.md index 8608f738b7d..8a68e529532 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -107,11 +107,11 @@ The following generators are available: * [nodejs-express-server (beta)](generators/nodejs-express-server.md) * [php-laravel](generators/php-laravel.md) * [php-lumen](generators/php-lumen.md) +* [php-mezzio-ph](generators/php-mezzio-ph.md) * [php-silex-deprecated (deprecated)](generators/php-silex-deprecated.md) * [php-slim-deprecated (deprecated)](generators/php-slim-deprecated.md) * [php-slim4](generators/php-slim4.md) * [php-symfony](generators/php-symfony.md) -* [php-ze-ph](generators/php-ze-ph.md) * [python-aiohttp](generators/python-aiohttp.md) * [python-blueplanet](generators/python-blueplanet.md) * [python-flask](generators/python-flask.md) diff --git a/docs/generators/README.md b/docs/generators/README.md index c04a0ef2c3f..6510770e47a 100644 --- a/docs/generators/README.md +++ b/docs/generators/README.md @@ -96,9 +96,9 @@ The following generators are available: * [nodejs-express-server (beta)](nodejs-express-server.md) * [php-laravel](php-laravel.md) * [php-lumen](php-lumen.md) +* [php-mezzio-ph](php-mezzio-ph.md) * [php-slim4](php-slim4.md) * [php-symfony](php-symfony.md) -* [php-ze-ph](php-ze-ph.md) * [python-aiohttp](python-aiohttp.md) * [python-blueplanet](python-blueplanet.md) * [python-flask](python-flask.md) diff --git a/docs/generators/php-ze-ph.md b/docs/generators/php-mezzio-ph.md similarity index 99% rename from docs/generators/php-ze-ph.md rename to docs/generators/php-mezzio-ph.md index cde96162014..3a599e531ab 100644 --- a/docs/generators/php-ze-ph.md +++ b/docs/generators/php-mezzio-ph.md @@ -1,6 +1,6 @@ --- -title: Config Options for php-ze-ph -sidebar_label: php-ze-ph +title: Config Options for php-mezzio-ph +sidebar_label: php-mezzio-ph --- These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details. diff --git a/docs/migration-from-swagger-codegen.md b/docs/migration-from-swagger-codegen.md index d2c57b7d8df..db6069bec79 100644 --- a/docs/migration-from-swagger-codegen.md +++ b/docs/migration-from-swagger-codegen.md @@ -129,7 +129,7 @@ All languages of `swagger-codegen` have been migrated to `openapi-generator`, bu | `swift` | `swift2-deprecated` | | `lumen` | `php-lumen` | | `slim` | `php-slim` | -| `ze-ph` | `php-ze-ph` | +| `ze-ph` | `php-mezzio-ph` | | `nancyfx` | `csharp-nancyfx` | We provide a temporary mapping in code for these old values. You'll receive a warning with instructions to migrate to the new names. diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpZendExpressivePathHandlerServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpMezzioPathHandlerServerCodegen.java similarity index 91% rename from modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpZendExpressivePathHandlerServerCodegen.java rename to modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpMezzioPathHandlerServerCodegen.java index ee2099b6af8..7630de3225c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpZendExpressivePathHandlerServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpMezzioPathHandlerServerCodegen.java @@ -33,8 +33,8 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.util.*; -public class PhpZendExpressivePathHandlerServerCodegen extends AbstractPhpCodegen { - private static final Logger LOGGER = LoggerFactory.getLogger(PhpZendExpressivePathHandlerServerCodegen.class); +public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen { + private static final Logger LOGGER = LoggerFactory.getLogger(PhpMezzioPathHandlerServerCodegen.class); // TODO: Rename to x- prefixed vendor extensions, per specification. public static final String VEN_FROM_QUERY = "internal.ze-ph.fromQuery"; @@ -49,15 +49,15 @@ public class PhpZendExpressivePathHandlerServerCodegen extends AbstractPhpCodege @Override public String getName() { - return "php-ze-ph"; + return "php-mezzio-ph"; } @Override public String getHelp() { - return "Generates PHP server stub using Zend Expressive ( https://zendframework.github.io/zend-expressive ) and Path Handler ( https://github.com/Articus/PathHandler )."; + return "Generates PHP server stub using Mezzio ( https://docs.mezzio.dev/mezzio/ ) and Path Handler ( https://github.com/Articus/PathHandler )."; } - public PhpZendExpressivePathHandlerServerCodegen() { + public PhpMezzioPathHandlerServerCodegen() { super(); modifyFeatureSet(features -> features @@ -78,7 +78,7 @@ public class PhpZendExpressivePathHandlerServerCodegen extends AbstractPhpCodege //no point to use double - http://php.net/manual/en/language.types.float.php , especially because of PHP 7+ float type declaration typeMapping.put("double", "float"); - embeddedTemplateDir = templateDir = "php-ze-ph"; + embeddedTemplateDir = templateDir = "php-mezzio-ph"; invokerPackage = "App"; srcBasePath = "src" + File.separator + "App"; apiDirName = "Handler"; @@ -101,13 +101,6 @@ public class PhpZendExpressivePathHandlerServerCodegen extends AbstractPhpCodege supportingFiles.add(new SupportingFile("data_transfer.yml.mustache", "application" + File.separator + "config", "data_transfer.yml")); supportingFiles.add(new SupportingFile("Factory.php.mustache", srcBasePath, "Factory.php")); supportingFiles.add(new SupportingFile("InternalServerError.php.mustache", srcBasePath + File.separator + "Middleware", "InternalServerError.php")); - supportingFiles.add(new SupportingFile("Date.php.mustache", srcBasePath + File.separator + "Strategy", "Date.php")); - supportingFiles.add(new SupportingFile("DateTime.php.mustache", srcBasePath + File.separator + "Strategy", "DateTime.php")); - supportingFiles.add(new SupportingFile("QueryParameter.php.mustache", srcBasePath + File.separator + "Strategy", "QueryParameter.php")); - supportingFiles.add(new SupportingFile("QueryParameterArray.php.mustache", srcBasePath + File.separator + "Strategy", "QueryParameterArray.php")); - supportingFiles.add(new SupportingFile("Type.php.mustache", srcBasePath + File.separator + "Validator", "Type.php")); - supportingFiles.add(new SupportingFile("QueryParameterType.php.mustache", srcBasePath + File.separator + "Validator", "QueryParameterType.php")); - supportingFiles.add(new SupportingFile("QueryParameterArrayType.php.mustache", srcBasePath + File.separator + "Validator", "QueryParameterArrayType.php")); additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, "1.0.0"); } diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index c3c1cf584e2..8fe400f1148 100644 --- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -86,7 +86,7 @@ org.openapitools.codegen.languages.PhpSlimServerCodegen org.openapitools.codegen.languages.PhpSlim4ServerCodegen org.openapitools.codegen.languages.PhpSilexServerCodegen org.openapitools.codegen.languages.PhpSymfonyServerCodegen -org.openapitools.codegen.languages.PhpZendExpressivePathHandlerServerCodegen +org.openapitools.codegen.languages.PhpMezzioPathHandlerServerCodegen org.openapitools.codegen.languages.PowerShellClientCodegen org.openapitools.codegen.languages.ProtobufSchemaCodegen org.openapitools.codegen.languages.PythonLegacyClientCodegen diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/Factory.php.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/Factory.php.mustache similarity index 76% rename from modules/openapi-generator/src/main/resources/php-ze-ph/Factory.php.mustache rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/Factory.php.mustache index 0edc4a175ac..68787c5fd6c 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/Factory.php.mustache +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/Factory.php.mustache @@ -7,17 +7,17 @@ use {{invokerPackage}}\Middleware; use Interop\Container\ContainerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Zend\Expressive\Application; -use Zend\Expressive\Handler\NotFoundHandler; -use Zend\Expressive\MiddlewareFactory; -use Zend\Expressive\Router\Middleware\DispatchMiddleware; -use Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware; -use Zend\Expressive\Router\Middleware\RouteMiddleware; -use Zend\Expressive\Router\RouteCollector; -use Zend\HttpHandlerRunner\Emitter\EmitterInterface; -use Zend\HttpHandlerRunner\RequestHandlerRunner; -use Zend\ServiceManager\Factory\FactoryInterface; -use Zend\Stratigility\MiddlewarePipe; +use Mezzio\Application; +use Mezzio\Handler\NotFoundHandler; +use Mezzio\MiddlewareFactory; +use Mezzio\Router\Middleware\DispatchMiddleware; +use Mezzio\Router\Middleware\MethodNotAllowedMiddleware; +use Mezzio\Router\Middleware\RouteMiddleware; +use Mezzio\Router\RouteCollector; +use Laminas\HttpHandlerRunner\Emitter\EmitterInterface; +use Laminas\HttpHandlerRunner\RequestHandlerRunner; +use Laminas\ServiceManager\Factory\FactoryInterface; +use Laminas\Stratigility\MiddlewarePipe; class Factory implements FactoryInterface { diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/InternalServerError.php.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/InternalServerError.php.mustache similarity index 97% rename from modules/openapi-generator/src/main/resources/php-ze-ph/InternalServerError.php.mustache rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/InternalServerError.php.mustache index a13f14f871e..9a6cbde5ea7 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/InternalServerError.php.mustache +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/InternalServerError.php.mustache @@ -7,7 +7,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; -use Zend\Stdlib\ErrorHandler; +use Laminas\Stdlib\ErrorHandler; class InternalServerError implements MiddlewareInterface { diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/README.md.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/README.md.mustache similarity index 76% rename from modules/openapi-generator/src/main/resources/php-ze-ph/README.md.mustache rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/README.md.mustache index 1cc1e36e9c2..584fd156879 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/README.md.mustache +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/README.md.mustache @@ -6,14 +6,14 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project. This server stub aims to provide light, yet comprehensive structure for your API project using: - PHP: >=7.2 -- [Zend Expressive](https://zendframework.github.io/zend-expressive): >=3.2 -- [Path Handler](https://github.com/Articus/PathHandler): >=0.4 +- [Laminas Mezzio](https://docs.mezzio.dev/mezzio/): >=3.2 +- [Path Handler](https://github.com/Articus/PathHandler): >=0.6 ## How to use All you have to do to start development is: - install dependencies via [Composer](https://getcomposer.org/) (small note: [ext-yaml](https://pecl.php.net/package/yaml) is used only for configuration parsing, so if you want to drop this dependency, simply adjust `./application/container.php`) -- create cache folder: `mkdir -p ./data/cache/ZendCache` (you will need it later for configuration and metadata caches - check comments in `./application/config.yml`) +- create cache folder: `mkdir -p ./data/cache` (you will need it later for configuration and metadata caches - check comments in `./application/config.yml`) - start PHP development server: `php -S 0.0.0.0:8080 -t ./public` (or any other SAPI you prefer, just make sure that you configure webroot to `./public` and rewrites to `./public/index.php`) After that you should be able to call all methods from your API spec. Most of the negative scenarios should be handled: @@ -31,4 +31,4 @@ But for obvious reason you will not get any `200 OK`, only `501 Not implemented` - implement your handlers - the most tricky part :) ## Enjoy! -Hopefully this stub will reduce the amount of boilerplate code you have to write manually. If you have any suggestions or questions about `php-ze-ph` generator, feel free to create issue either in [Path Handler repository](https://github.com/Articus/PathHandler/issues) or in [OpenAPI Generator repository](https://openapi-generator.tech/issues). +Hopefully this stub will reduce the amount of boilerplate code you have to write manually. If you have any suggestions or questions about `php-mezzio-ph` generator, feel free to create issue either in [Path Handler repository](https://github.com/Articus/PathHandler/issues) or in [OpenAPI Generator repository](https://openapi-generator.tech/issues). diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/api.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/api.mustache similarity index 97% rename from modules/openapi-generator/src/main/resources/php-ze-ph/api.mustache rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/api.mustache index 82f3782ab9b..1b599464274 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/api.mustache +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/api.mustache @@ -40,7 +40,7 @@ class {{classname}} {{#bodyParam}} {{#consumes}} * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="{{{mediaType}}}") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="{{{mediaType}}}") {{/consumes}} {{^isPrimitiveType}} {{#isContainer}} diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/app.yml.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/app.yml.mustache new file mode 100644 index 00000000000..0ffd5e8864c --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/app.yml.mustache @@ -0,0 +1,22 @@ +dependencies: + invokables: + Laminas\HttpHandlerRunner\Emitter\EmitterInterface: Laminas\HttpHandlerRunner\Emitter\SapiStreamEmitter + factories: + Mezzio\Application: App\Factory + Mezzio\MiddlewareContainer: Mezzio\Container\MiddlewareContainerFactory + Mezzio\MiddlewareFactory: Mezzio\Container\MiddlewareFactoryFactory + Mezzio\Router\RouteCollector: Mezzio\Router\RouteCollectorFactory + + Psr\Http\Message\ServerRequestInterface: Mezzio\Container\ServerRequestFactoryFactory + Psr\Http\Message\StreamInterface: Mezzio\Container\StreamFactoryFactory + Psr\Http\Message\ResponseInterface: Mezzio\Container\ResponseFactoryFactory + + App\Middleware\InternalServerError: Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory + Mezzio\Router\Middleware\RouteMiddleware: Mezzio\Router\Middleware\RouteMiddlewareFactory + Mezzio\Router\Middleware\DispatchMiddleware: Mezzio\Router\Middleware\DispatchMiddlewareFactory + Mezzio\Router\Middleware\MethodNotAllowedMiddleware: Mezzio\Router\Middleware\MethodNotAllowedMiddlewareFactory + Mezzio\Handler\NotFoundHandler: Mezzio\Container\NotFoundHandlerFactory + +Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory: + App\Middleware\InternalServerError: + - Psr\Http\Message\ResponseInterface diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/composer.json.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/composer.json.mustache new file mode 100644 index 00000000000..a768982234a --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/composer.json.mustache @@ -0,0 +1,27 @@ +{ + "name": "{{#lambda.lowercase}}{{gitUserId}}/{{gitRepoId}}{{/lambda.lowercase}}", + "description": "{{description}}", + "license": "unlicense", + "version": "{{artifactVersion}}", + "type": "project", + "require": { + "php": "^7.2", + "ext-yaml": "^2.0", + "mezzio/mezzio": "^3.2", + "laminas/laminas-diactoros": "^2.1", + "articus/path-handler": "^0.6", + "articus/data-transfer": "^0.4", + "articus/openapi-generator-common": "^0.1", + "doctrine/annotations": "^1.10", + "psr/simple-cache": "^1.0", + "laminas/laminas-config": "^3.4", + "laminas/laminas-stdlib": "^3.2", + "laminas/laminas-validator": "^2.13", + "nikic/fast-route": "^1.3" + }, + "autoload": { + "psr-4": { + "": "src/" + } + } +} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/config.yml b/modules/openapi-generator/src/main/resources/php-mezzio-ph/config.yml new file mode 100644 index 00000000000..1f106812353 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/config.yml @@ -0,0 +1,20 @@ +#Empty configuration placeholder, remove when you add any real configuration settings to this file +{} + +#Enable configuration cache +#cache_configuration: true + +#Articus\PathHandler\RouteInjection\Factory: +# #Enable routing table cache +# router: +# cache: +# directory: ./data/cache/PathHandler +# #Enable handler metadata cache +# metadata: +# cache: +# directory: ./data/cache/PathHandler + +#Enable data transfer metadata cache for DTOs +#Articus\DataTransfer\MetadataProvider\Annotation: +# cache: +# directory: ./data/cache/DataTransfer diff --git a/samples/server/petstore/php-ze-ph/application/container.php b/modules/openapi-generator/src/main/resources/php-mezzio-ph/container.php similarity index 90% rename from samples/server/petstore/php-ze-ph/application/container.php rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/container.php index 3518792765f..b9638c5584b 100644 --- a/samples/server/petstore/php-ze-ph/application/container.php +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/container.php @@ -1,7 +1,7 @@ setService('config', $config); diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/data_transfer.yml.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/data_transfer.yml.mustache new file mode 100644 index 00000000000..c5174147c23 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/data_transfer.yml.mustache @@ -0,0 +1,26 @@ +dependencies: + factories: + Articus\DataTransfer\Service: Articus\DataTransfer\Factory + Articus\DataTransfer\MetadataProvider\Annotation: Articus\DataTransfer\MetadataProvider\Factory\Annotation + Articus\DataTransfer\Strategy\PluginManager: Articus\DataTransfer\Strategy\Factory\PluginManager + Articus\DataTransfer\Validator\PluginManager: Articus\DataTransfer\Validator\Factory\PluginManager + Laminas\Validator\ValidatorPluginManager: Laminas\Validator\ValidatorPluginManagerFactory + aliases: + Articus\DataTransfer\ClassMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\Annotation + Articus\DataTransfer\FieldMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\Annotation + +Articus\DataTransfer\Strategy\PluginManager: + invokables: + QueryStringScalar: OpenAPIGenerator\Common\Strategy\QueryStringScalar + QueryStringScalarArray: OpenAPIGenerator\Common\Strategy\QueryStringScalarArray + factories: + Date: OpenAPIGenerator\Common\Strategy\Factory\MutableDate + DateTime: OpenAPIGenerator\Common\Strategy\Factory\MutableDateTime + +Articus\DataTransfer\Validator\PluginManager: + invokables: + Scalar: OpenAPIGenerator\Common\Validator\Scalar + QueryStringScalar: OpenAPIGenerator\Common\Validator\QueryStringScalar + QueryStringScalarArray: OpenAPIGenerator\Common\Validator\QueryStringScalarArray + abstract_factories: + - Articus\DataTransfer\Validator\Factory\Laminas diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/gitignore b/modules/openapi-generator/src/main/resources/php-mezzio-ph/gitignore similarity index 100% rename from modules/openapi-generator/src/main/resources/php-ze-ph/gitignore rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/gitignore diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/index.php b/modules/openapi-generator/src/main/resources/php-mezzio-ph/index.php new file mode 100644 index 00000000000..7c3de73df16 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/index.php @@ -0,0 +1,11 @@ +get(\Mezzio\Application::class); +$app->run(); diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/model.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model.mustache similarity index 98% rename from modules/openapi-generator/src/main/resources/php-ze-ph/model.mustache rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/model.mustache index 2c8a9fa1021..57f70bfc767 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/model.mustache +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model.mustache @@ -20,7 +20,7 @@ class {{classname}} * @DTA\Data(field="{{baseName}}"{{^required}}, nullable=true{{/required}}){{#vendorExtensions}}{{#internal.ze-ph.fromQuery}} {{>model_query_var}}{{/internal.ze-ph.fromQuery}}{{/vendorExtensions}}{{#vendorExtensions}}{{^internal.ze-ph.fromQuery}} {{>model_normal_var}}{{/internal.ze-ph.fromQuery}}{{/vendorExtensions}}{{^vendorExtensions}} -{{>model_normal_var}}{{/vendorExtensions}} * @var {{dataType}} +{{>model_normal_var}}{{/vendorExtensions}} * @var {{dataType}}|null */ public ${{name}}; {{/vars}} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/model_normal_var.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_normal_var.mustache similarity index 85% rename from modules/openapi-generator/src/main/resources/php-ze-ph/model_normal_var.mustache rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/model_normal_var.mustache index 3aee768b133..33c6e46337a 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/model_normal_var.mustache +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_normal_var.mustache @@ -3,7 +3,7 @@ {{^isDate}} {{^isDateTime}} * @DTA\Strategy(name="Object", options={"type":{{dataType}}::class}) - * @DTA\Validator(name="Dictionary", options={"type":{{dataType}}::class}) + * @DTA\Validator(name="TypeCompliant", options={"type":{{dataType}}::class}) {{/isDateTime}} {{/isDate}} {{#isDate}} @@ -19,7 +19,7 @@ * TODO check validator and strategy are correct and can handle container item type * @DTA\Strategy(name="ObjectArray", options={"type":{{#items}}{{dataType}}{{/items}}::class}) * @DTA\Validator(name="Collection", options={"validators":{ - * {"name":"Dictionary", "options":{"type":{{#items}}{{dataType}}{{/items}}::class}} + * {"name":"TypeCompliant", "options":{"type":{{#items}}{{dataType}}{{/items}}::class}} * }}) {{/isContainer}} {{/isPrimitiveType}} @@ -28,12 +28,12 @@ {{#items}} * TODO check validator and strategy are correct and can handle container item type * @DTA\Validator(name="Collection", options={"validators":{ - * {"name":"Type", "options":{"type":"{{dataType}}"}} + * {"name":"Scalar", "options":{"type":"{{dataType}}"}} * }}) {{/items}} {{/isContainer}} {{^isContainer}} - * @DTA\Validator(name="Type", options={"type":"{{dataType}}"}) + * @DTA\Validator(name="Scalar", options={"type":"{{dataType}}"}) {{/isContainer}} {{/isPrimitiveType}} {{#hasValidation}} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/model_query_var.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_query_var.mustache similarity index 72% rename from modules/openapi-generator/src/main/resources/php-ze-ph/model_query_var.mustache rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/model_query_var.mustache index 2a542a8e2cf..27f0a72c955 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/model_query_var.mustache +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_query_var.mustache @@ -15,15 +15,13 @@ {{/isPrimitiveType}} {{#isPrimitiveType}} {{#isContainer}} -{{#items}} * TODO check validator and strategy are correct and can handle container item type - * @DTA\Strategy(name="QueryParameterArray", options={"type":"{{dataType}}", "format":"{{internal.ze-ph.collectionFormat}}"}) - * @DTA\Validator(name="QueryParameterArrayType", options={"type":"{{dataType}}", "format":"{{internal.ze-ph.collectionFormat}}"}) -{{/items}} + * @DTA\Strategy(name="QueryStringScalarArray", options={"type":"{{#items}}{{dataType}}{{/items}}", "format":"{{internal.ze-ph.collectionFormat}}"}) + * @DTA\Validator(name="QueryStringScalarArray", options={"type":"{{#items}}{{dataType}}{{/items}}", "format":"{{internal.ze-ph.collectionFormat}}"{{#minItems}}, "min_items":{{minItems}}{{/minItems}}{{#maxItems}}, "max_items":{{maxItems}}{{/maxItems}}}) {{/isContainer}} {{^isContainer}} - * @DTA\Strategy(name="QueryParameter", options={"type":"{{dataType}}"}) - * @DTA\Validator(name="QueryParameterType", options={"type":"{{dataType}}"}) + * @DTA\Strategy(name="QueryStringScalar", options={"type":"{{dataType}}"}) + * @DTA\Validator(name="QueryStringScalar", options={"type":"{{dataType}}"}) {{/isContainer}} {{/isPrimitiveType}} {{#hasValidation}} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/path_handler.yml.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/path_handler.yml.mustache similarity index 67% rename from modules/openapi-generator/src/main/resources/php-ze-ph/path_handler.yml.mustache rename to modules/openapi-generator/src/main/resources/php-mezzio-ph/path_handler.yml.mustache index 2520ae6b28d..dd01611f359 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/path_handler.yml.mustache +++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/path_handler.yml.mustache @@ -1,3 +1,7 @@ +dependencies: + factories: + Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory + Articus\PathHandler\RouteInjection\Factory: paths: '{{basePathWithoutHost}}': @@ -10,7 +14,7 @@ Articus\PathHandler\RouteInjection\Factory: {{/apiInfo}} handlers: abstract_factories: - - Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory + - Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory # consumers: # factories: # invokables: @@ -21,7 +25,7 @@ Articus\PathHandler\RouteInjection\Factory: # factories: # invokables: -Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory: +Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory: {{#apiInfo}} {{#apis}} {{#operations}} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/Date.php.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/Date.php.mustache deleted file mode 100644 index 0c06196db3b..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/Date.php.mustache +++ /dev/null @@ -1,21 +0,0 @@ -format(static::DATE_TIME_FORMAT); - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if (!empty($arrayValue)) { - $date = $this->parseDateString($arrayValue); - if ($date instanceof \DateTime) { - $result = $date; - } - } - return $result; - } - - /** - * @param $arrayValue - * @return bool|\DateTime - */ - protected function parseDateString($arrayValue) - { - return \DateTime::createFromFormat(static::DATE_TIME_FORMAT, $arrayValue, new \DateTimeZone('UTC')); - } -} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameter.php.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameter.php.mustache deleted file mode 100644 index a9a25841c58..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameter.php.mustache +++ /dev/null @@ -1,77 +0,0 @@ - true, - self::TYPE_FLOAT => true, - self::TYPE_BOOL => true, - self::TYPE_STRING => true, - ]; - - /** - * @var string - */ - protected $type; - - /** - * QueryParameterArray constructor. - */ - public function __construct(array $options) - { - if (empty($options['type'])) { - throw new \InvalidArgumentException('Option "type" is required.'); - } elseif (!isset(self::TYPE_MAP[$options['type']])) { - throw new \InvalidArgumentException(\sprintf('Unknown type "%s".', $options['type'])); - } - $this->type = $options['type']; - } - - - /** - * @inheritdoc - */ - public function extract($objectValue, $object = null) - { - $result = null; - if ($objectValue !== null) { - $result = (string)$objectValue; - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if ($arrayValue !== null) { - switch ($this->type) { - case self::TYPE_INT: - $result = (int)$arrayValue; - break; - case self::TYPE_FLOAT: - $result = (float)$arrayValue; - break; - case self::TYPE_BOOL: - $result = ($arrayValue === 'true')? true : false; - break; - case self::TYPE_STRING: - $result = (string)$arrayValue; - break; - } - } - return $result; - } -} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterArray.php.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterArray.php.mustache deleted file mode 100644 index 3df9aa3291f..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterArray.php.mustache +++ /dev/null @@ -1,74 +0,0 @@ - ',', - self::FORMAT_SSV => ' ', - self::FORMAT_TSV => "\t", - self::FORMAT_PIPES => '|', - self::FORMAT_MULTI => null, - ]; - - /** - * @var string|null - */ - protected $delimiter; - - public function __construct(array $options) - { - parent::__construct($options); - if (empty($options['format'])) { - throw new \InvalidArgumentException('Option "format" is required.'); - } elseif (!\array_key_exists($options['format'], self::DELIMITER_MAP)) { - throw new \InvalidArgumentException(\sprintf('Unknown format "%s".', $options['format'])); - } - $this->delimiter = self::DELIMITER_MAP[$options['format']]; - } - - /** - * @inheritdoc - */ - public function extract($objectValue, $object = null) - { - $result = null; - if (\is_array($objectValue)) { - if ($this->delimiter === null) { - $result = $objectValue; - } else { - $result = \implode($this->delimiter, $objectValue); - } - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if ($arrayValue !== null) { - $list = null; - if ($this->delimiter === null) { - $list = (\is_array($arrayValue))? $arrayValue : [$arrayValue]; - } else { - $list = \explode($this->delimiter, $arrayValue); - } - $result = []; - foreach ($list as $item) { - $result[] = parent::hydrate($item, null); - } - } - return $result; - } -} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterArrayType.php.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterArrayType.php.mustache deleted file mode 100644 index b818360496e..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterArrayType.php.mustache +++ /dev/null @@ -1,74 +0,0 @@ -format; - } - - /** - * @param string $format - * @return self - */ - public function setFormat(string $format): self - { - $this->format = $format; - return $this; - } - - protected function checkType($value): bool - { - $result = true; - if (!\array_key_exists($this->format, QueryParameterArray::DELIMITER_MAP)) { - throw new \InvalidArgumentException(\sprintf('Can not check for format %s.', $this->format)); - } - $delimiter = QueryParameterArray::DELIMITER_MAP[$this->format]; - if ($delimiter === null) { - if (\is_array($value)) { - foreach ($value as $item) { - $result = $result && parent::checkType($item); - } - } else { - $result = false; - } - } else { - switch ($this->type) { - case QueryParameterArray::TYPE_INT: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_INT, $delimiter), $value); - break; - case QueryParameterArray::TYPE_BOOL: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_BOOL, $delimiter), $value); - break; - case QueryParameterArray::TYPE_FLOAT: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_FLOAT, $delimiter), $value); - break; - case QueryParameterArray::TYPE_STRING: - $result = \is_string($value); - break; - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } - return $result; - } - - protected static function prepareRepeatingTypeRegExp(string $typeRegExp, string $delimiter): string - { - $escapedDelimiter = \preg_quote($delimiter, '/'); - return '/^(' . $typeRegExp . ')(' . $escapedDelimiter . '('. $typeRegExp . '))*$/'; - } -} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterType.php.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterType.php.mustache deleted file mode 100644 index 98b59bcec16..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/QueryParameterType.php.mustache +++ /dev/null @@ -1,29 +0,0 @@ -type) { - case QueryParameter::TYPE_INT: - return \is_string($value) && \preg_match('/^(' . self::RE_INT . ')$/', $value); - case QueryParameter::TYPE_BOOL: - return \is_string($value) && \preg_match('/^(' . self::RE_BOOL . ')$/', $value); - case QueryParameter::TYPE_FLOAT: - return \is_string($value) && \preg_match('/^(' . self::RE_FLOAT . ')$/', $value); - case QueryParameter::TYPE_STRING: - return \is_string($value); - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } -} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/Type.php.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/Type.php.mustache deleted file mode 100644 index 6c72a6a00d0..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/Type.php.mustache +++ /dev/null @@ -1,73 +0,0 @@ - 'Invalid type given.', - ]; - - /** - * @var null|string - */ - protected $type; - - /** - * @return string - */ - public function getType(): ?string - { - return $this->type; - } - - /** - * @param string $type - * @return self - */ - public function setType(string $type): self - { - $this->type = $type; - return $this; - } - - /** - * @inheritdoc - */ - public function isValid($value) - { - $result = true; - if (!$this->checkType($value)) { - $this->error(self::INVALID); - $result = false; - } - return $result; - } - - protected function checkType($value): bool - { - switch ($this->type) { - case 'int': - return \is_int($value); - case 'bool': - return \is_bool($value); - case 'float': - return \is_float($value) || \is_int($value); - case 'string': - return \is_string($value); - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } -} diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/app.yml.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/app.yml.mustache deleted file mode 100644 index 8d8bac997f1..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/app.yml.mustache +++ /dev/null @@ -1,23 +0,0 @@ -dependencies: - invokables: - Zend\HttpHandlerRunner\Emitter\EmitterInterface: Zend\HttpHandlerRunner\Emitter\SapiStreamEmitter - factories: - Zend\Expressive\Application: App\Factory - Zend\Expressive\MiddlewareContainer: Zend\Expressive\Container\MiddlewareContainerFactory - Zend\Expressive\MiddlewareFactory: Zend\Expressive\Container\MiddlewareFactoryFactory - Zend\Expressive\Router\RouteCollector: Zend\Expressive\Router\RouteCollectorFactory - Zend\Expressive\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory - - Psr\Http\Message\ServerRequestInterface: Zend\Expressive\Container\ServerRequestFactoryFactory - Psr\Http\Message\StreamInterface: Zend\Expressive\Container\StreamFactoryFactory - Psr\Http\Message\ResponseInterface: Zend\Expressive\Container\ResponseFactoryFactory - - Zend\Expressive\Router\Middleware\RouteMiddleware: Zend\Expressive\Router\Middleware\RouteMiddlewareFactory - Zend\Expressive\Router\Middleware\DispatchMiddleware: Zend\Expressive\Router\Middleware\DispatchMiddlewareFactory - Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware: Zend\Expressive\Router\Middleware\MethodNotAllowedMiddlewareFactory - Zend\Expressive\Handler\NotFoundHandler: Zend\Expressive\Container\NotFoundHandlerFactory - App\Middleware\InternalServerError: Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory - -Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory: - App\Middleware\InternalServerError: - - Psr\Http\Message\ResponseInterface diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/composer.json.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/composer.json.mustache deleted file mode 100644 index 8306bc621e1..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/composer.json.mustache +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "{{gitUserId}}/{{gitRepoId}}", - "description": "{{description}}", - "license": "unlicense", - "version": "{{artifactVersion}}", - "type": "project", - "require": { - "php": "^7.2", - "ext-yaml": "^2.0", - "zendframework/zend-expressive": "^3.2", - "zendframework/zend-diactoros": "^2.1", - "articus/path-handler": "^0.4", - "articus/data-transfer": "^0.2", - "doctrine/annotations": "^1.6", - "zendframework/zend-cache": "^2.8", - "zendframework/zend-serializer": "^2.9", - "zendframework/zend-config": "^3.2", - "nikic/fast-route": "^1.3" - }, - "autoload": { - "psr-4": { - "": "src/" - } - } -} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/config.yml b/modules/openapi-generator/src/main/resources/php-ze-ph/config.yml deleted file mode 100644 index 4eae86f67b3..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/config.yml +++ /dev/null @@ -1,39 +0,0 @@ -#Empty configuration placeholder, remove when you add any real configuration settings to this file -{} - -#Enable configuration cache -#cache_configuration: true - -#Articus\PathHandler\RouteInjection\Factory: -# #Enable routing table cache -# router: -# cache: -# adapter: filesystem -# options: -# cache_dir: data/cache/ZendCache -# namespace: ph-router -# plugins: -# serializer: -# serializer: phpserialize -# #Enable handler metadata cache -# metadata: -# cache: -# adapter: filesystem -# options: -# cache_dir: data/cache/ZendCache -# namespace: ph-metadata -# plugins: -# serializer: -# serializer: phpserialize - -#Enable data transfer metadata cache for DTOs -#Articus\DataTransfer\Service: -# metadata_cache: -# adapter: -# name: filesystem -# options: -# cache_dir: data/cache/ZendCache -# namespace: dt -# plugins: -# serializer: -# serializer: phpserialize diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/data_transfer.yml.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/data_transfer.yml.mustache deleted file mode 100644 index f6766802ac8..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/data_transfer.yml.mustache +++ /dev/null @@ -1,33 +0,0 @@ -dependencies: - factories: - Articus\DataTransfer\Service: Articus\DataTransfer\ServiceFactory - -Articus\DataTransfer\Service: - metadata_cache: - adapter: - name: blackhole - strategies: - invokables: - {{invokerPackage}}\Strategy\Date: {{invokerPackage}}\Strategy\Date - {{invokerPackage}}\Strategy\DateTime: {{invokerPackage}}\Strategy\DateTime - {{invokerPackage}}\Strategy\QueryParameter: {{invokerPackage}}\Strategy\QueryParameter - {{invokerPackage}}\Strategy\QueryParameterArray: {{invokerPackage}}\Strategy\QueryParameterArray - aliases: - Date: {{invokerPackage}}\Strategy\Date - DateTime: {{invokerPackage}}\Strategy\DateTime - QueryParameter: {{invokerPackage}}\Strategy\QueryParameter - QueryParameterArray: {{invokerPackage}}\Strategy\QueryParameterArray - validators: - invokables: - {{invokerPackage}}\Validator\Type: {{invokerPackage}}\Validator\Type - {{invokerPackage}}\Validator\QueryParameterType: {{invokerPackage}}\Validator\QueryParameterType - {{invokerPackage}}\Validator\QueryParameterArrayType: {{invokerPackage}}\Validator\QueryParameterArrayType - factories: - Articus\DataTransfer\Validator\Dictionary: Articus\DataTransfer\Validator\Factory - Articus\DataTransfer\Validator\Collection: Articus\DataTransfer\Validator\Factory - aliases: - Dictionary: Articus\DataTransfer\Validator\Dictionary - Collection: Articus\DataTransfer\Validator\Collection - Type: {{invokerPackage}}\Validator\Type - QueryParameterType: {{invokerPackage}}\Validator\QueryParameterType - QueryParameterArrayType: {{invokerPackage}}\Validator\QueryParameterArrayType diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/index.php b/modules/openapi-generator/src/main/resources/php-ze-ph/index.php deleted file mode 100644 index 2f84d8776b0..00000000000 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/index.php +++ /dev/null @@ -1,11 +0,0 @@ -get(\Zend\Expressive\Application::class); -$app->run(); diff --git a/samples/openapi3/server/petstore/php-ze-ph/.gitignore b/samples/openapi3/server/petstore/php-mezzio-ph/.gitignore similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/.gitignore rename to samples/openapi3/server/petstore/php-mezzio-ph/.gitignore diff --git a/samples/openapi3/server/petstore/php-ze-ph/.openapi-generator-ignore b/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator-ignore similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/.openapi-generator-ignore rename to samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator-ignore diff --git a/samples/server/petstore/php-ze-ph/.openapi-generator/FILES b/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/FILES similarity index 79% rename from samples/server/petstore/php-ze-ph/.openapi-generator/FILES rename to samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/FILES index bfad086c5ac..fd268242a0e 100644 --- a/samples/server/petstore/php-ze-ph/.openapi-generator/FILES +++ b/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/FILES @@ -11,6 +11,8 @@ src/App/DTO/ApiResponse.php src/App/DTO/Category.php src/App/DTO/FindPetsByStatusQueryData.php src/App/DTO/FindPetsByTagsQueryData.php +src/App/DTO/InlineObject.php +src/App/DTO/InlineObject1.php src/App/DTO/LoginUserQueryData.php src/App/DTO/Order.php src/App/DTO/Pet.php @@ -32,10 +34,3 @@ src/App/Handler/UserLogin.php src/App/Handler/UserLogout.php src/App/Handler/UserUsername.php src/App/Middleware/InternalServerError.php -src/App/Strategy/Date.php -src/App/Strategy/DateTime.php -src/App/Strategy/QueryParameter.php -src/App/Strategy/QueryParameterArray.php -src/App/Validator/QueryParameterArrayType.php -src/App/Validator/QueryParameterType.php -src/App/Validator/Type.php diff --git a/samples/server/petstore/php-ze-ph/.openapi-generator/VERSION b/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/VERSION similarity index 100% rename from samples/server/petstore/php-ze-ph/.openapi-generator/VERSION rename to samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/VERSION diff --git a/samples/server/petstore/php-ze-ph/README.md b/samples/openapi3/server/petstore/php-mezzio-ph/README.md similarity index 76% rename from samples/server/petstore/php-ze-ph/README.md rename to samples/openapi3/server/petstore/php-mezzio-ph/README.md index 1cc1e36e9c2..584fd156879 100644 --- a/samples/server/petstore/php-ze-ph/README.md +++ b/samples/openapi3/server/petstore/php-mezzio-ph/README.md @@ -6,14 +6,14 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project. This server stub aims to provide light, yet comprehensive structure for your API project using: - PHP: >=7.2 -- [Zend Expressive](https://zendframework.github.io/zend-expressive): >=3.2 -- [Path Handler](https://github.com/Articus/PathHandler): >=0.4 +- [Laminas Mezzio](https://docs.mezzio.dev/mezzio/): >=3.2 +- [Path Handler](https://github.com/Articus/PathHandler): >=0.6 ## How to use All you have to do to start development is: - install dependencies via [Composer](https://getcomposer.org/) (small note: [ext-yaml](https://pecl.php.net/package/yaml) is used only for configuration parsing, so if you want to drop this dependency, simply adjust `./application/container.php`) -- create cache folder: `mkdir -p ./data/cache/ZendCache` (you will need it later for configuration and metadata caches - check comments in `./application/config.yml`) +- create cache folder: `mkdir -p ./data/cache` (you will need it later for configuration and metadata caches - check comments in `./application/config.yml`) - start PHP development server: `php -S 0.0.0.0:8080 -t ./public` (or any other SAPI you prefer, just make sure that you configure webroot to `./public` and rewrites to `./public/index.php`) After that you should be able to call all methods from your API spec. Most of the negative scenarios should be handled: @@ -31,4 +31,4 @@ But for obvious reason you will not get any `200 OK`, only `501 Not implemented` - implement your handlers - the most tricky part :) ## Enjoy! -Hopefully this stub will reduce the amount of boilerplate code you have to write manually. If you have any suggestions or questions about `php-ze-ph` generator, feel free to create issue either in [Path Handler repository](https://github.com/Articus/PathHandler/issues) or in [OpenAPI Generator repository](https://openapi-generator.tech/issues). +Hopefully this stub will reduce the amount of boilerplate code you have to write manually. If you have any suggestions or questions about `php-mezzio-ph` generator, feel free to create issue either in [Path Handler repository](https://github.com/Articus/PathHandler/issues) or in [OpenAPI Generator repository](https://openapi-generator.tech/issues). diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/application/config.yml b/samples/openapi3/server/petstore/php-mezzio-ph/application/config.yml new file mode 100644 index 00000000000..1f106812353 --- /dev/null +++ b/samples/openapi3/server/petstore/php-mezzio-ph/application/config.yml @@ -0,0 +1,20 @@ +#Empty configuration placeholder, remove when you add any real configuration settings to this file +{} + +#Enable configuration cache +#cache_configuration: true + +#Articus\PathHandler\RouteInjection\Factory: +# #Enable routing table cache +# router: +# cache: +# directory: ./data/cache/PathHandler +# #Enable handler metadata cache +# metadata: +# cache: +# directory: ./data/cache/PathHandler + +#Enable data transfer metadata cache for DTOs +#Articus\DataTransfer\MetadataProvider\Annotation: +# cache: +# directory: ./data/cache/DataTransfer diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/application/config/app.yml b/samples/openapi3/server/petstore/php-mezzio-ph/application/config/app.yml new file mode 100644 index 00000000000..0ffd5e8864c --- /dev/null +++ b/samples/openapi3/server/petstore/php-mezzio-ph/application/config/app.yml @@ -0,0 +1,22 @@ +dependencies: + invokables: + Laminas\HttpHandlerRunner\Emitter\EmitterInterface: Laminas\HttpHandlerRunner\Emitter\SapiStreamEmitter + factories: + Mezzio\Application: App\Factory + Mezzio\MiddlewareContainer: Mezzio\Container\MiddlewareContainerFactory + Mezzio\MiddlewareFactory: Mezzio\Container\MiddlewareFactoryFactory + Mezzio\Router\RouteCollector: Mezzio\Router\RouteCollectorFactory + + Psr\Http\Message\ServerRequestInterface: Mezzio\Container\ServerRequestFactoryFactory + Psr\Http\Message\StreamInterface: Mezzio\Container\StreamFactoryFactory + Psr\Http\Message\ResponseInterface: Mezzio\Container\ResponseFactoryFactory + + App\Middleware\InternalServerError: Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory + Mezzio\Router\Middleware\RouteMiddleware: Mezzio\Router\Middleware\RouteMiddlewareFactory + Mezzio\Router\Middleware\DispatchMiddleware: Mezzio\Router\Middleware\DispatchMiddlewareFactory + Mezzio\Router\Middleware\MethodNotAllowedMiddleware: Mezzio\Router\Middleware\MethodNotAllowedMiddlewareFactory + Mezzio\Handler\NotFoundHandler: Mezzio\Container\NotFoundHandlerFactory + +Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory: + App\Middleware\InternalServerError: + - Psr\Http\Message\ResponseInterface diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/application/config/data_transfer.yml b/samples/openapi3/server/petstore/php-mezzio-ph/application/config/data_transfer.yml new file mode 100644 index 00000000000..c5174147c23 --- /dev/null +++ b/samples/openapi3/server/petstore/php-mezzio-ph/application/config/data_transfer.yml @@ -0,0 +1,26 @@ +dependencies: + factories: + Articus\DataTransfer\Service: Articus\DataTransfer\Factory + Articus\DataTransfer\MetadataProvider\Annotation: Articus\DataTransfer\MetadataProvider\Factory\Annotation + Articus\DataTransfer\Strategy\PluginManager: Articus\DataTransfer\Strategy\Factory\PluginManager + Articus\DataTransfer\Validator\PluginManager: Articus\DataTransfer\Validator\Factory\PluginManager + Laminas\Validator\ValidatorPluginManager: Laminas\Validator\ValidatorPluginManagerFactory + aliases: + Articus\DataTransfer\ClassMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\Annotation + Articus\DataTransfer\FieldMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\Annotation + +Articus\DataTransfer\Strategy\PluginManager: + invokables: + QueryStringScalar: OpenAPIGenerator\Common\Strategy\QueryStringScalar + QueryStringScalarArray: OpenAPIGenerator\Common\Strategy\QueryStringScalarArray + factories: + Date: OpenAPIGenerator\Common\Strategy\Factory\MutableDate + DateTime: OpenAPIGenerator\Common\Strategy\Factory\MutableDateTime + +Articus\DataTransfer\Validator\PluginManager: + invokables: + Scalar: OpenAPIGenerator\Common\Validator\Scalar + QueryStringScalar: OpenAPIGenerator\Common\Validator\QueryStringScalar + QueryStringScalarArray: OpenAPIGenerator\Common\Validator\QueryStringScalarArray + abstract_factories: + - Articus\DataTransfer\Validator\Factory\Laminas diff --git a/samples/server/petstore/php-ze-ph/application/config/path_handler.yml b/samples/openapi3/server/petstore/php-mezzio-ph/application/config/path_handler.yml similarity index 82% rename from samples/server/petstore/php-ze-ph/application/config/path_handler.yml rename to samples/openapi3/server/petstore/php-mezzio-ph/application/config/path_handler.yml index 08762d5415a..25995b20d6f 100644 --- a/samples/server/petstore/php-ze-ph/application/config/path_handler.yml +++ b/samples/openapi3/server/petstore/php-mezzio-ph/application/config/path_handler.yml @@ -1,3 +1,7 @@ +dependencies: + factories: + Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory + Articus\PathHandler\RouteInjection\Factory: paths: '/v2': @@ -17,7 +21,7 @@ Articus\PathHandler\RouteInjection\Factory: - App\Handler\UserUsername handlers: abstract_factories: - - Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory + - Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory # consumers: # factories: # invokables: @@ -28,7 +32,7 @@ Articus\PathHandler\RouteInjection\Factory: # factories: # invokables: -Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory: +Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory: App\Handler\Pet: [] App\Handler\PetFindByStatus: [] App\Handler\PetFindByTags: [] diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/container.php b/samples/openapi3/server/petstore/php-mezzio-ph/application/container.php similarity index 90% rename from modules/openapi-generator/src/main/resources/php-ze-ph/container.php rename to samples/openapi3/server/petstore/php-mezzio-ph/application/container.php index 3518792765f..b9638c5584b 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/container.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/application/container.php @@ -1,7 +1,7 @@ setService('config', $config); diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/composer.json b/samples/openapi3/server/petstore/php-mezzio-ph/composer.json new file mode 100644 index 00000000000..54f8e97226c --- /dev/null +++ b/samples/openapi3/server/petstore/php-mezzio-ph/composer.json @@ -0,0 +1,27 @@ +{ + "name": "git_user_id/git_repo_id", + "description": "", + "license": "unlicense", + "version": "1.0.0", + "type": "project", + "require": { + "php": "^7.2", + "ext-yaml": "^2.0", + "mezzio/mezzio": "^3.2", + "laminas/laminas-diactoros": "^2.1", + "articus/path-handler": "^0.6", + "articus/data-transfer": "^0.4", + "articus/openapi-generator-common": "^0.1", + "doctrine/annotations": "^1.10", + "psr/simple-cache": "^1.0", + "laminas/laminas-config": "^3.4", + "laminas/laminas-stdlib": "^3.2", + "laminas/laminas-validator": "^2.13", + "nikic/fast-route": "^1.3" + }, + "autoload": { + "psr-4": { + "": "src/" + } + } +} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/public/index.php b/samples/openapi3/server/petstore/php-mezzio-ph/public/index.php new file mode 100644 index 00000000000..7c3de73df16 --- /dev/null +++ b/samples/openapi3/server/petstore/php-mezzio-ph/public/index.php @@ -0,0 +1,11 @@ +get(\Mezzio\Application::class); +$app->run(); diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/ApiResponse.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php similarity index 62% rename from samples/server/petstore/php-ze-ph/src/App/DTO/ApiResponse.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php index c15871c7017..a08cb2c9275 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/ApiResponse.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php @@ -12,20 +12,20 @@ class ApiResponse { /** * @DTA\Data(field="code", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $code; /** * @DTA\Data(field="type", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $type; /** * @DTA\Data(field="message", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $message; } diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/Category.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Category.php similarity index 70% rename from samples/server/petstore/php-ze-ph/src/App/DTO/Category.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Category.php index 374098e1540..7b65c273d40 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/Category.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Category.php @@ -12,15 +12,15 @@ class Category { /** * @DTA\Data(field="id", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $id; /** * @DTA\Data(field="name", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) + * @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 + * @var string|null */ public $name; } diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/FindPetsByStatusQueryData.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/FindPetsByStatusQueryData.php similarity index 64% rename from samples/server/petstore/php-ze-ph/src/App/DTO/FindPetsByStatusQueryData.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/FindPetsByStatusQueryData.php index 4abe941d3df..7ddc126e1ee 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/FindPetsByStatusQueryData.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/FindPetsByStatusQueryData.php @@ -14,9 +14,9 @@ class FindPetsByStatusQueryData * Status values that need to be considered for filter * @DTA\Data(field="status") * TODO check validator and strategy are correct and can handle container item type - * @DTA\Strategy(name="QueryParameterArray", options={"type":"string", "format":"csv"}) - * @DTA\Validator(name="QueryParameterArrayType", options={"type":"string", "format":"csv"}) - * @var string[] + * @DTA\Strategy(name="QueryStringScalarArray", options={"type":"string", "format":"csv"}) + * @DTA\Validator(name="QueryStringScalarArray", options={"type":"string", "format":"csv"}) + * @var string[]|null */ public $status; } diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/FindPetsByTagsQueryData.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/FindPetsByTagsQueryData.php similarity index 62% rename from samples/server/petstore/php-ze-ph/src/App/DTO/FindPetsByTagsQueryData.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/FindPetsByTagsQueryData.php index e3b6f876c94..e67697987a1 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/FindPetsByTagsQueryData.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/FindPetsByTagsQueryData.php @@ -14,9 +14,9 @@ class FindPetsByTagsQueryData * Tags to filter by * @DTA\Data(field="tags") * TODO check validator and strategy are correct and can handle container item type - * @DTA\Strategy(name="QueryParameterArray", options={"type":"string", "format":"csv"}) - * @DTA\Validator(name="QueryParameterArrayType", options={"type":"string", "format":"csv"}) - * @var string[] + * @DTA\Strategy(name="QueryStringScalarArray", options={"type":"string", "format":"csv"}) + * @DTA\Validator(name="QueryStringScalarArray", options={"type":"string", "format":"csv"}) + * @var string[]|null */ public $tags; } diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/InlineObject.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/InlineObject.php similarity index 66% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/InlineObject.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/InlineObject.php index 56871d3a916..ab36677158c 100644 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/InlineObject.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/InlineObject.php @@ -12,15 +12,15 @@ class InlineObject /** * Updated name of the pet * @DTA\Data(field="name", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $name; /** * Updated status of the pet * @DTA\Data(field="status", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $status; } diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/InlineObject1.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/InlineObject1.php similarity index 69% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/InlineObject1.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/InlineObject1.php index d65e76823b7..4e36c4f7779 100644 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/InlineObject1.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/InlineObject1.php @@ -12,16 +12,16 @@ class InlineObject1 /** * Additional data to pass to server * @DTA\Data(field="additionalMetadata", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $additional_metadata; /** * file to upload * @DTA\Data(field="file", nullable=true) * @DTA\Strategy(name="Object", options={"type":\SplFileObject::class}) - * @DTA\Validator(name="Dictionary", options={"type":\SplFileObject::class}) - * @var \SplFileObject + * @DTA\Validator(name="TypeCompliant", options={"type":\SplFileObject::class}) + * @var \SplFileObject|null */ public $file; } diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/LoginUserQueryData.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/LoginUserQueryData.php similarity index 58% rename from samples/server/petstore/php-ze-ph/src/App/DTO/LoginUserQueryData.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/LoginUserQueryData.php index 0d279a084aa..23946129bd9 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/LoginUserQueryData.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/LoginUserQueryData.php @@ -13,18 +13,18 @@ class LoginUserQueryData /** * The password for login in clear text * @DTA\Data(field="password") - * @DTA\Strategy(name="QueryParameter", options={"type":"string"}) - * @DTA\Validator(name="QueryParameterType", options={"type":"string"}) - * @var string + * @DTA\Strategy(name="QueryStringScalar", options={"type":"string"}) + * @DTA\Validator(name="QueryStringScalar", options={"type":"string"}) + * @var string|null */ public $password; /** * The user name for login * @DTA\Data(field="username") - * @DTA\Strategy(name="QueryParameter", options={"type":"string"}) - * @DTA\Validator(name="QueryParameterType", options={"type":"string"}) + * @DTA\Strategy(name="QueryStringScalar", options={"type":"string"}) + * @DTA\Validator(name="QueryStringScalar", options={"type":"string"}) * @DTA\Validator(name="Regex", options={"pattern":"/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"}) - * @var string + * @var string|null */ public $username; } diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/Order.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Order.php similarity index 64% rename from samples/server/petstore/php-ze-ph/src/App/DTO/Order.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Order.php index 63135e8ec50..6cf05b4bc97 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/Order.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Order.php @@ -12,40 +12,40 @@ class Order { /** * @DTA\Data(field="id", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $id; /** * @DTA\Data(field="petId", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $pet_id; /** * @DTA\Data(field="quantity", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $quantity; /** * @DTA\Data(field="shipDate", nullable=true) * @DTA\Strategy(name="DateTime") * @DTA\Validator(name="Date", options={"format": \DateTime::RFC3339}) - * @var \DateTime + * @var \DateTime|null */ public $ship_date; /** * Order Status * @DTA\Data(field="status", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $status; /** * @DTA\Data(field="complete", nullable=true) - * @DTA\Validator(name="Type", options={"type":"bool"}) - * @var bool + * @DTA\Validator(name="Scalar", options={"type":"bool"}) + * @var bool|null */ public $complete; } diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/Pet.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Pet.php similarity index 66% rename from samples/server/petstore/php-ze-ph/src/App/DTO/Pet.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Pet.php index e25ed83c514..11d86eb1473 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/Pet.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Pet.php @@ -12,30 +12,30 @@ class Pet { /** * @DTA\Data(field="id", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $id; /** * @DTA\Data(field="category", nullable=true) * @DTA\Strategy(name="Object", options={"type":\App\DTO\Category::class}) - * @DTA\Validator(name="Dictionary", options={"type":\App\DTO\Category::class}) - * @var \App\DTO\Category + * @DTA\Validator(name="TypeCompliant", options={"type":\App\DTO\Category::class}) + * @var \App\DTO\Category|null */ public $category; /** * @DTA\Data(field="name") - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $name; /** * @DTA\Data(field="photoUrls") * TODO check validator and strategy are correct and can handle container item type * @DTA\Validator(name="Collection", options={"validators":{ - * {"name":"Type", "options":{"type":"string"}} + * {"name":"Scalar", "options":{"type":"string"}} * }}) - * @var string[] + * @var string[]|null */ public $photo_urls; /** @@ -43,16 +43,16 @@ class Pet * TODO check validator and strategy are correct and can handle container item type * @DTA\Strategy(name="ObjectArray", options={"type":\App\DTO\Tag::class}) * @DTA\Validator(name="Collection", options={"validators":{ - * {"name":"Dictionary", "options":{"type":\App\DTO\Tag::class}} + * {"name":"TypeCompliant", "options":{"type":\App\DTO\Tag::class}} * }}) - * @var \App\DTO\Tag[] + * @var \App\DTO\Tag[]|null */ public $tags; /** * pet status in the store * @DTA\Data(field="status", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $status; } diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/Tag.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Tag.php similarity index 63% rename from samples/server/petstore/php-ze-ph/src/App/DTO/Tag.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Tag.php index ebc8a7a7f43..ce7d6ce4e62 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/Tag.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/Tag.php @@ -12,14 +12,14 @@ class Tag { /** * @DTA\Data(field="id", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $id; /** * @DTA\Data(field="name", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $name; } diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/User.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/User.php similarity index 55% rename from samples/server/petstore/php-ze-ph/src/App/DTO/User.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/User.php index f4ed5d4fd1c..dc0c2ab925c 100644 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/User.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/User.php @@ -12,51 +12,51 @@ class User { /** * @DTA\Data(field="id", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $id; /** * @DTA\Data(field="username", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $username; /** * @DTA\Data(field="firstName", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $first_name; /** * @DTA\Data(field="lastName", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $last_name; /** * @DTA\Data(field="email", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $email; /** * @DTA\Data(field="password", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $password; /** * @DTA\Data(field="phone", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $phone; /** * User Status * @DTA\Data(field="userStatus", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $user_status; } diff --git a/samples/server/petstore/php-ze-ph/src/App/Factory.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Factory.php similarity index 76% rename from samples/server/petstore/php-ze-ph/src/App/Factory.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Factory.php index 0fb4a7d732a..0757bcfbea7 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Factory.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Factory.php @@ -7,17 +7,17 @@ use App\Middleware; use Interop\Container\ContainerInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; -use Zend\Expressive\Application; -use Zend\Expressive\Handler\NotFoundHandler; -use Zend\Expressive\MiddlewareFactory; -use Zend\Expressive\Router\Middleware\DispatchMiddleware; -use Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware; -use Zend\Expressive\Router\Middleware\RouteMiddleware; -use Zend\Expressive\Router\RouteCollector; -use Zend\HttpHandlerRunner\Emitter\EmitterInterface; -use Zend\HttpHandlerRunner\RequestHandlerRunner; -use Zend\ServiceManager\Factory\FactoryInterface; -use Zend\Stratigility\MiddlewarePipe; +use Mezzio\Application; +use Mezzio\Handler\NotFoundHandler; +use Mezzio\MiddlewareFactory; +use Mezzio\Router\Middleware\DispatchMiddleware; +use Mezzio\Router\Middleware\MethodNotAllowedMiddleware; +use Mezzio\Router\Middleware\RouteMiddleware; +use Mezzio\Router\RouteCollector; +use Laminas\HttpHandlerRunner\Emitter\EmitterInterface; +use Laminas\HttpHandlerRunner\RequestHandlerRunner; +use Laminas\ServiceManager\Factory\FactoryInterface; +use Laminas\Stratigility\MiddlewarePipe; class Factory implements FactoryInterface { diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/Pet.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/Pet.php similarity index 89% rename from samples/server/petstore/php-ze-ph/src/App/Handler/Pet.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/Pet.php index c4dfdce081f..06f9bf950dc 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/Pet.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/Pet.php @@ -19,9 +19,9 @@ class Pet * Add a new pet to the store * @PHA\Post() * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/json") * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/xml") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/xml") * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Pet::class,"objectAttr":"bodyData"}) * TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation * @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml") @@ -44,9 +44,9 @@ class Pet * Update an existing pet * @PHA\Put() * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/json") * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/xml") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/xml") * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Pet::class,"objectAttr":"bodyData"}) * TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation * @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml") diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/PetFindByStatus.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/PetFindByStatus.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/PetFindByTags.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/PetFindByTags.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/PetPetId.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetId.php similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/PetPetId.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetId.php diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/PetPetIdUploadImage.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetIdUploadImage.php similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/PetPetIdUploadImage.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetIdUploadImage.php diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/StoreInventory.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/StoreInventory.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrder.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrder.php similarity index 95% rename from samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrder.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrder.php index 567e312fea5..be6af69243a 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrder.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrder.php @@ -19,7 +19,7 @@ class StoreOrder * Place an order for a pet * @PHA\Post() * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/json") * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Order::class,"objectAttr":"bodyData"}) * TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation * @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml") diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrderOrderId.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrderOrderId.php similarity index 100% rename from samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrderOrderId.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrderOrderId.php diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/User.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/User.php similarity index 92% rename from samples/server/petstore/php-ze-ph/src/App/Handler/User.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/User.php index db151a05c60..5a48f2ec072 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/User.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/User.php @@ -19,7 +19,7 @@ class User * Create user * @PHA\Post() * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/json") * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"}) * @param ServerRequestInterface $request * diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithArray.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php similarity index 93% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithArray.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php index 4a2204fb7c0..a8a39215bab 100644 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithArray.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php @@ -19,7 +19,7 @@ class UserCreateWithArray * Creates list of users with given input array * @PHA\Post() * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/json") * TODO check if attribute is valid and can handle your container type * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":"\App\DTO\User[]","objectAttr":"bodyData"}) * @param ServerRequestInterface $request diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithList.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php similarity index 93% rename from samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithList.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php index f61d9e4061e..b34cca7045f 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithList.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php @@ -19,7 +19,7 @@ class UserCreateWithList * Creates list of users with given input array * @PHA\Post() * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/json") * TODO check if attribute is valid and can handle your container type * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":"\App\DTO\User[]","objectAttr":"bodyData"}) * @param ServerRequestInterface $request diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserLogin.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogin.php similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserLogin.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogin.php diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserLogout.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogout.php similarity index 100% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserLogout.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogout.php diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserUsername.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserUsername.php similarity index 96% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserUsername.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserUsername.php index 1888015fea9..ce3de984969 100644 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/UserUsername.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserUsername.php @@ -49,7 +49,7 @@ class UserUsername * Updated user * @PHA\Put() * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation - * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") + * @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="application/json") * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"}) * @param ServerRequestInterface $request * diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Middleware/InternalServerError.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php similarity index 97% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/Middleware/InternalServerError.php rename to samples/openapi3/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php index ba889f44ae2..f0354421e00 100644 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Middleware/InternalServerError.php +++ b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php @@ -7,7 +7,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; -use Zend\Stdlib\ErrorHandler; +use Laminas\Stdlib\ErrorHandler; class InternalServerError implements MiddlewareInterface { diff --git a/samples/openapi3/server/petstore/php-ze-ph/.openapi-generator/VERSION b/samples/openapi3/server/petstore/php-ze-ph/.openapi-generator/VERSION deleted file mode 100644 index afa63656064..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/php-ze-ph/application/config.yml b/samples/openapi3/server/petstore/php-ze-ph/application/config.yml deleted file mode 100644 index 4eae86f67b3..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/application/config.yml +++ /dev/null @@ -1,39 +0,0 @@ -#Empty configuration placeholder, remove when you add any real configuration settings to this file -{} - -#Enable configuration cache -#cache_configuration: true - -#Articus\PathHandler\RouteInjection\Factory: -# #Enable routing table cache -# router: -# cache: -# adapter: filesystem -# options: -# cache_dir: data/cache/ZendCache -# namespace: ph-router -# plugins: -# serializer: -# serializer: phpserialize -# #Enable handler metadata cache -# metadata: -# cache: -# adapter: filesystem -# options: -# cache_dir: data/cache/ZendCache -# namespace: ph-metadata -# plugins: -# serializer: -# serializer: phpserialize - -#Enable data transfer metadata cache for DTOs -#Articus\DataTransfer\Service: -# metadata_cache: -# adapter: -# name: filesystem -# options: -# cache_dir: data/cache/ZendCache -# namespace: dt -# plugins: -# serializer: -# serializer: phpserialize diff --git a/samples/openapi3/server/petstore/php-ze-ph/application/config/app.yml b/samples/openapi3/server/petstore/php-ze-ph/application/config/app.yml deleted file mode 100644 index 8d8bac997f1..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/application/config/app.yml +++ /dev/null @@ -1,23 +0,0 @@ -dependencies: - invokables: - Zend\HttpHandlerRunner\Emitter\EmitterInterface: Zend\HttpHandlerRunner\Emitter\SapiStreamEmitter - factories: - Zend\Expressive\Application: App\Factory - Zend\Expressive\MiddlewareContainer: Zend\Expressive\Container\MiddlewareContainerFactory - Zend\Expressive\MiddlewareFactory: Zend\Expressive\Container\MiddlewareFactoryFactory - Zend\Expressive\Router\RouteCollector: Zend\Expressive\Router\RouteCollectorFactory - Zend\Expressive\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory - - Psr\Http\Message\ServerRequestInterface: Zend\Expressive\Container\ServerRequestFactoryFactory - Psr\Http\Message\StreamInterface: Zend\Expressive\Container\StreamFactoryFactory - Psr\Http\Message\ResponseInterface: Zend\Expressive\Container\ResponseFactoryFactory - - Zend\Expressive\Router\Middleware\RouteMiddleware: Zend\Expressive\Router\Middleware\RouteMiddlewareFactory - Zend\Expressive\Router\Middleware\DispatchMiddleware: Zend\Expressive\Router\Middleware\DispatchMiddlewareFactory - Zend\Expressive\Router\Middleware\MethodNotAllowedMiddleware: Zend\Expressive\Router\Middleware\MethodNotAllowedMiddlewareFactory - Zend\Expressive\Handler\NotFoundHandler: Zend\Expressive\Container\NotFoundHandlerFactory - App\Middleware\InternalServerError: Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory - -Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory: - App\Middleware\InternalServerError: - - Psr\Http\Message\ResponseInterface diff --git a/samples/openapi3/server/petstore/php-ze-ph/application/config/data_transfer.yml b/samples/openapi3/server/petstore/php-ze-ph/application/config/data_transfer.yml deleted file mode 100644 index 7ed712ca9f1..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/application/config/data_transfer.yml +++ /dev/null @@ -1,33 +0,0 @@ -dependencies: - factories: - Articus\DataTransfer\Service: Articus\DataTransfer\ServiceFactory - -Articus\DataTransfer\Service: - metadata_cache: - adapter: - name: blackhole - strategies: - invokables: - App\Strategy\Date: App\Strategy\Date - App\Strategy\DateTime: App\Strategy\DateTime - App\Strategy\QueryParameter: App\Strategy\QueryParameter - App\Strategy\QueryParameterArray: App\Strategy\QueryParameterArray - aliases: - Date: App\Strategy\Date - DateTime: App\Strategy\DateTime - QueryParameter: App\Strategy\QueryParameter - QueryParameterArray: App\Strategy\QueryParameterArray - validators: - invokables: - App\Validator\Type: App\Validator\Type - App\Validator\QueryParameterType: App\Validator\QueryParameterType - App\Validator\QueryParameterArrayType: App\Validator\QueryParameterArrayType - factories: - Articus\DataTransfer\Validator\Dictionary: Articus\DataTransfer\Validator\Factory - Articus\DataTransfer\Validator\Collection: Articus\DataTransfer\Validator\Factory - aliases: - Dictionary: Articus\DataTransfer\Validator\Dictionary - Collection: Articus\DataTransfer\Validator\Collection - Type: App\Validator\Type - QueryParameterType: App\Validator\QueryParameterType - QueryParameterArrayType: App\Validator\QueryParameterArrayType diff --git a/samples/openapi3/server/petstore/php-ze-ph/application/config/path_handler.yml b/samples/openapi3/server/petstore/php-ze-ph/application/config/path_handler.yml deleted file mode 100644 index 01c5ec66c4e..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/application/config/path_handler.yml +++ /dev/null @@ -1,73 +0,0 @@ -Articus\PathHandler\RouteInjection\Factory: - paths: - '/v2': - - App\Handler\AnotherFakeDummy - - App\Handler\Fake - - App\Handler\FakeBodyWithFileSchema - - App\Handler\FakeBodyWithQueryParams - - App\Handler\FakeHealth - - App\Handler\FakeInlineAdditionalProperties - - App\Handler\FakeJsonFormData - - App\Handler\FakeOuterBoolean - - App\Handler\FakeOuterComposite - - App\Handler\FakeOuterNumber - - App\Handler\FakeOuterString - - App\Handler\FakePetIdUploadImageWithRequiredFile - - App\Handler\FakeClassnameTest - - App\Handler\Foo - - App\Handler\Pet - - App\Handler\PetFindByStatus - - App\Handler\PetFindByTags - - App\Handler\PetPetId - - App\Handler\PetPetIdUploadImage - - App\Handler\StoreInventory - - App\Handler\StoreOrder - - App\Handler\StoreOrderOrderId - - App\Handler\User - - App\Handler\UserCreateWithArray - - App\Handler\UserCreateWithList - - App\Handler\UserLogin - - App\Handler\UserLogout - - App\Handler\UserUsername - handlers: - abstract_factories: - - Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory -# consumers: -# factories: -# invokables: -# attributes: -# factories: -# invokables: -# producers: -# factories: -# invokables: - -Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory: - App\Handler\AnotherFakeDummy: [] - App\Handler\Fake: [] - App\Handler\FakeBodyWithFileSchema: [] - App\Handler\FakeBodyWithQueryParams: [] - App\Handler\FakeHealth: [] - App\Handler\FakeInlineAdditionalProperties: [] - App\Handler\FakeJsonFormData: [] - App\Handler\FakeOuterBoolean: [] - App\Handler\FakeOuterComposite: [] - App\Handler\FakeOuterNumber: [] - App\Handler\FakeOuterString: [] - App\Handler\FakePetIdUploadImageWithRequiredFile: [] - App\Handler\FakeClassnameTest: [] - App\Handler\Foo: [] - App\Handler\Pet: [] - App\Handler\PetFindByStatus: [] - App\Handler\PetFindByTags: [] - App\Handler\PetPetId: [] - App\Handler\PetPetIdUploadImage: [] - App\Handler\StoreInventory: [] - App\Handler\StoreOrder: [] - App\Handler\StoreOrderOrderId: [] - App\Handler\User: [] - App\Handler\UserCreateWithArray: [] - App\Handler\UserCreateWithList: [] - App\Handler\UserLogin: [] - App\Handler\UserLogout: [] - App\Handler\UserUsername: [] diff --git a/samples/openapi3/server/petstore/php-ze-ph/composer.json b/samples/openapi3/server/petstore/php-ze-ph/composer.json deleted file mode 100644 index 99c78857b2f..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/composer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "GIT_USER_ID/GIT_REPO_ID", - "description": "", - "license": "unlicense", - "version": "1.0.0", - "type": "project", - "require": { - "php": "^7.1", - "ext-yaml": "^2.0", - "zendframework/zend-expressive": "^3.2", - "zendframework/zend-diactoros": "^2.1", - "articus/path-handler": "^0.4", - "articus/data-transfer": "^0.2", - "doctrine/annotations": "^1.6", - "zendframework/zend-cache": "^2.8", - "zendframework/zend-serializer": "^2.9", - "zendframework/zend-config": "^3.2", - "nikic/fast-route": "^1.3" - }, - "autoload": { - "psr-4": { - "": "src/" - } - } -} \ No newline at end of file diff --git a/samples/openapi3/server/petstore/php-ze-ph/public/index.php b/samples/openapi3/server/petstore/php-ze-ph/public/index.php deleted file mode 100644 index 2f84d8776b0..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/public/index.php +++ /dev/null @@ -1,11 +0,0 @@ -get(\Zend\Expressive\Application::class); -$app->run(); diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/AdditionalPropertiesClass.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/AdditionalPropertiesClass.php deleted file mode 100644 index 62b20fab02a..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/AdditionalPropertiesClass.php +++ /dev/null @@ -1,31 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/Fake.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/Fake.php deleted file mode 100644 index 566f28ddff8..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/Fake.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } - /** - * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * @PHA\Post() - * @param ServerRequestInterface $request - * - * @throws PHException\HttpCode 501 if the method is not implemented - */ - public function testEndpointParameters(ServerRequestInterface $request) - { - //TODO implement method - throw new PHException\HttpCode(501, "Not implemented"); - } - /** - * To test enum parameters - * @PHA\Get() - * @PHA\Attribute(name=PHAttribute\Transfer::class, options={ - * "type":\App\DTO\TestEnumParametersQueryData::class, - * "objectAttr":"queryData", - * "source": PHAttribute\Transfer::SOURCE_GET - * }) - * @param ServerRequestInterface $request - * - * @throws PHException\HttpCode 501 if the method is not implemented - */ - public function testEnumParameters(ServerRequestInterface $request) - { - //TODO implement method - /** @var \App\DTO\TestEnumParametersQueryData $queryData */ - $queryData = $request->getAttribute("queryData"); - throw new PHException\HttpCode(501, "Not implemented"); - } - /** - * Fake endpoint to test group parameters (optional) - * @PHA\Delete() - * @PHA\Attribute(name=PHAttribute\Transfer::class, options={ - * "type":\App\DTO\TestGroupParametersQueryData::class, - * "objectAttr":"queryData", - * "source": PHAttribute\Transfer::SOURCE_GET - * }) - * @param ServerRequestInterface $request - * - * @throws PHException\HttpCode 501 if the method is not implemented - */ - public function testGroupParameters(ServerRequestInterface $request) - { - //TODO implement method - /** @var \App\DTO\TestGroupParametersQueryData $queryData */ - $queryData = $request->getAttribute("queryData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithFileSchema.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithFileSchema.php deleted file mode 100644 index 47ce029df6e..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithFileSchema.php +++ /dev/null @@ -1,34 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithQueryParams.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithQueryParams.php deleted file mode 100644 index facb461a64a..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithQueryParams.php +++ /dev/null @@ -1,41 +0,0 @@ -getAttribute("queryData"); - /** @var \App\DTO\User $bodyData */ - $bodyData = $request->getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeClassnameTest.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeClassnameTest.php deleted file mode 100644 index 74991195dce..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeClassnameTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeHealth.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeHealth.php deleted file mode 100644 index 347599d5163..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeHealth.php +++ /dev/null @@ -1,34 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeJsonFormData.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeJsonFormData.php deleted file mode 100644 index ed3e0f6d2ef..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeJsonFormData.php +++ /dev/null @@ -1,30 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeOuterNumber.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeOuterNumber.php deleted file mode 100644 index a39bf98d488..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Handler/FakeOuterNumber.php +++ /dev/null @@ -1,35 +0,0 @@ -format(static::DATE_TIME_FORMAT); - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if (!empty($arrayValue)) { - $date = $this->parseDateString($arrayValue); - if ($date instanceof \DateTime) { - $result = $date; - } - } - return $result; - } - - /** - * @param $arrayValue - * @return bool|\DateTime - */ - protected function parseDateString($arrayValue) - { - return \DateTime::createFromFormat(static::DATE_TIME_FORMAT, $arrayValue, new \DateTimeZone('UTC')); - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Strategy/QueryParameter.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Strategy/QueryParameter.php deleted file mode 100644 index e9eac336a33..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Strategy/QueryParameter.php +++ /dev/null @@ -1,77 +0,0 @@ - true, - self::TYPE_FLOAT => true, - self::TYPE_BOOL => true, - self::TYPE_STRING => true, - ]; - - /** - * @var string - */ - protected $type; - - /** - * QueryParameterArray constructor. - */ - public function __construct(array $options) - { - if (empty($options['type'])) { - throw new \InvalidArgumentException('Option "type" is required.'); - } elseif (!isset(self::TYPE_MAP[$options['type']])) { - throw new \InvalidArgumentException(\sprintf('Unknown type "%s".', $options['type'])); - } - $this->type = $options['type']; - } - - - /** - * @inheritdoc - */ - public function extract($objectValue, $object = null) - { - $result = null; - if ($objectValue !== null) { - $result = (string)$objectValue; - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if ($arrayValue !== null) { - switch ($this->type) { - case self::TYPE_INT: - $result = (int)$arrayValue; - break; - case self::TYPE_FLOAT: - $result = (float)$arrayValue; - break; - case self::TYPE_BOOL: - $result = ($arrayValue === 'true')? true : false; - break; - case self::TYPE_STRING: - $result = (string)$arrayValue; - break; - } - } - return $result; - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Strategy/QueryParameterArray.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Strategy/QueryParameterArray.php deleted file mode 100644 index 34f57d140fe..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Strategy/QueryParameterArray.php +++ /dev/null @@ -1,74 +0,0 @@ - ',', - self::FORMAT_SSV => ' ', - self::FORMAT_TSV => "\t", - self::FORMAT_PIPES => '|', - self::FORMAT_MULTI => null, - ]; - - /** - * @var string|null - */ - protected $delimiter; - - public function __construct(array $options) - { - parent::__construct($options); - if (empty($options['format'])) { - throw new \InvalidArgumentException('Option "format" is required.'); - } elseif (!\array_key_exists($options['format'], self::DELIMITER_MAP)) { - throw new \InvalidArgumentException(\sprintf('Unknown format "%s".', $options['format'])); - } - $this->delimiter = self::DELIMITER_MAP[$options['format']]; - } - - /** - * @inheritdoc - */ - public function extract($objectValue, $object = null) - { - $result = null; - if (\is_array($objectValue)) { - if ($this->delimiter === null) { - $result = $objectValue; - } else { - $result = \implode($this->delimiter, $objectValue); - } - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if ($arrayValue !== null) { - $list = null; - if ($this->delimiter === null) { - $list = (\is_array($arrayValue))? $arrayValue : [$arrayValue]; - } else { - $list = \explode($this->delimiter, $arrayValue); - } - $result = []; - foreach ($list as $item) { - $result[] = parent::hydrate($item, null); - } - } - return $result; - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/QueryParameterArrayType.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/QueryParameterArrayType.php deleted file mode 100644 index 069cfaa51a3..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/QueryParameterArrayType.php +++ /dev/null @@ -1,74 +0,0 @@ -format; - } - - /** - * @param string $format - * @return self - */ - public function setFormat(string $format): self - { - $this->format = $format; - return $this; - } - - protected function checkType($value): bool - { - $result = true; - if (!\array_key_exists($this->format, QueryParameterArray::DELIMITER_MAP)) { - throw new \InvalidArgumentException(\sprintf('Can not check for format %s.', $this->format)); - } - $delimiter = QueryParameterArray::DELIMITER_MAP[$this->format]; - if ($delimiter === null) { - if (\is_array($value)) { - foreach ($value as $item) { - $result = $result && parent::checkType($item); - } - } else { - $result = false; - } - } else { - switch ($this->type) { - case QueryParameterArray::TYPE_INT: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_INT, $delimiter), $value); - break; - case QueryParameterArray::TYPE_BOOL: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_BOOL, $delimiter), $value); - break; - case QueryParameterArray::TYPE_FLOAT: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_FLOAT, $delimiter), $value); - break; - case QueryParameterArray::TYPE_STRING: - $result = \is_string($value); - break; - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } - return $result; - } - - protected static function prepareRepeatingTypeRegExp(string $typeRegExp, string $delimiter): string - { - $escapedDelimiter = \preg_quote($delimiter, '/'); - return '/^(' . $typeRegExp . ')(' . $escapedDelimiter . '('. $typeRegExp . '))*$/'; - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/QueryParameterType.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/QueryParameterType.php deleted file mode 100644 index 6643990b744..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/QueryParameterType.php +++ /dev/null @@ -1,29 +0,0 @@ -type) { - case QueryParameter::TYPE_INT: - return \is_string($value) && \preg_match('/^(' . self::RE_INT . ')$/', $value); - case QueryParameter::TYPE_BOOL: - return \is_string($value) && \preg_match('/^(' . self::RE_BOOL . ')$/', $value); - case QueryParameter::TYPE_FLOAT: - return \is_string($value) && \preg_match('/^(' . self::RE_FLOAT . ')$/', $value); - case QueryParameter::TYPE_STRING: - return \is_string($value); - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } -} diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/Type.php b/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/Type.php deleted file mode 100644 index a3b883d6488..00000000000 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/Validator/Type.php +++ /dev/null @@ -1,73 +0,0 @@ - 'Invalid type given.', - ]; - - /** - * @var null|string - */ - protected $type; - - /** - * @return string - */ - public function getType(): ?string - { - return $this->type; - } - - /** - * @param string $type - * @return self - */ - public function setType(string $type): self - { - $this->type = $type; - return $this; - } - - /** - * @inheritdoc - */ - public function isValid($value) - { - $result = true; - if (!$this->checkType($value)) { - $this->error(self::INVALID); - $result = false; - } - return $result; - } - - protected function checkType($value): bool - { - switch ($this->type) { - case 'int': - return \is_int($value); - case 'bool': - return \is_bool($value); - case 'float': - return \is_float($value) || \is_int($value); - case 'string': - return \is_string($value); - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } -} diff --git a/samples/server/petstore/php-ze-ph/.gitignore b/samples/server/petstore/php-mezzio-ph/.gitignore similarity index 100% rename from samples/server/petstore/php-ze-ph/.gitignore rename to samples/server/petstore/php-mezzio-ph/.gitignore diff --git a/samples/server/petstore/php-ze-ph/.openapi-generator-ignore b/samples/server/petstore/php-mezzio-ph/.openapi-generator-ignore similarity index 100% rename from samples/server/petstore/php-ze-ph/.openapi-generator-ignore rename to samples/server/petstore/php-mezzio-ph/.openapi-generator-ignore diff --git a/samples/server/petstore/php-mezzio-ph/.openapi-generator/FILES b/samples/server/petstore/php-mezzio-ph/.openapi-generator/FILES new file mode 100644 index 00000000000..fc8224fecb8 --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/.openapi-generator/FILES @@ -0,0 +1,34 @@ +.gitignore +README.md +application/config.yml +application/config/app.yml +application/config/data_transfer.yml +application/config/path_handler.yml +application/container.php +composer.json +public/index.php +src/App/DTO/ApiResponse.php +src/App/DTO/Category.php +src/App/DTO/FindPetsByStatusQueryData.php +src/App/DTO/FindPetsByTagsQueryData.php +src/App/DTO/LoginUserQueryData.php +src/App/DTO/Order.php +src/App/DTO/Pet.php +src/App/DTO/Tag.php +src/App/DTO/User.php +src/App/Factory.php +src/App/Handler/Pet.php +src/App/Handler/PetFindByStatus.php +src/App/Handler/PetFindByTags.php +src/App/Handler/PetPetId.php +src/App/Handler/PetPetIdUploadImage.php +src/App/Handler/StoreInventory.php +src/App/Handler/StoreOrder.php +src/App/Handler/StoreOrderOrderId.php +src/App/Handler/User.php +src/App/Handler/UserCreateWithArray.php +src/App/Handler/UserCreateWithList.php +src/App/Handler/UserLogin.php +src/App/Handler/UserLogout.php +src/App/Handler/UserUsername.php +src/App/Middleware/InternalServerError.php diff --git a/samples/server/petstore/php-mezzio-ph/.openapi-generator/VERSION b/samples/server/petstore/php-mezzio-ph/.openapi-generator/VERSION new file mode 100644 index 00000000000..d99e7162d01 --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/server/petstore/php-ze-ph/README.md b/samples/server/petstore/php-mezzio-ph/README.md similarity index 75% rename from samples/openapi3/server/petstore/php-ze-ph/README.md rename to samples/server/petstore/php-mezzio-ph/README.md index 973240bb44e..584fd156879 100644 --- a/samples/openapi3/server/petstore/php-ze-ph/README.md +++ b/samples/server/petstore/php-mezzio-ph/README.md @@ -5,15 +5,15 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project. ## Overview This server stub aims to provide light, yet comprehensive structure for your API project using: -- PHP: >=7.1 -- [Zend Expressive](https://zendframework.github.io/zend-expressive): >=3.2 -- [Path Handler](https://github.com/Articus/PathHandler): >=0.4 +- PHP: >=7.2 +- [Laminas Mezzio](https://docs.mezzio.dev/mezzio/): >=3.2 +- [Path Handler](https://github.com/Articus/PathHandler): >=0.6 ## How to use All you have to do to start development is: - install dependencies via [Composer](https://getcomposer.org/) (small note: [ext-yaml](https://pecl.php.net/package/yaml) is used only for configuration parsing, so if you want to drop this dependency, simply adjust `./application/container.php`) -- create cache folder: `mkdir -p ./data/cache/ZendCache` (you will need it later for configuration and metadata caches - check comments in `./application/config.yml`) +- create cache folder: `mkdir -p ./data/cache` (you will need it later for configuration and metadata caches - check comments in `./application/config.yml`) - start PHP development server: `php -S 0.0.0.0:8080 -t ./public` (or any other SAPI you prefer, just make sure that you configure webroot to `./public` and rewrites to `./public/index.php`) After that you should be able to call all methods from your API spec. Most of the negative scenarios should be handled: @@ -31,4 +31,4 @@ But for obvious reason you will not get any `200 OK`, only `501 Not implemented` - implement your handlers - the most tricky part :) ## Enjoy! -Hopefully this stub will reduce the amount of boilerplate code you have to write manually. If you have any suggestions or questions about `php-ze-ph` generator, feel free to create issue either in [Path Handler repository](https://github.com/Articus/PathHandler/issues) or in [OpenAPI Generator repository](https://openapi-generator.tech/issues). +Hopefully this stub will reduce the amount of boilerplate code you have to write manually. If you have any suggestions or questions about `php-mezzio-ph` generator, feel free to create issue either in [Path Handler repository](https://github.com/Articus/PathHandler/issues) or in [OpenAPI Generator repository](https://openapi-generator.tech/issues). diff --git a/samples/server/petstore/php-mezzio-ph/application/config.yml b/samples/server/petstore/php-mezzio-ph/application/config.yml new file mode 100644 index 00000000000..1f106812353 --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/application/config.yml @@ -0,0 +1,20 @@ +#Empty configuration placeholder, remove when you add any real configuration settings to this file +{} + +#Enable configuration cache +#cache_configuration: true + +#Articus\PathHandler\RouteInjection\Factory: +# #Enable routing table cache +# router: +# cache: +# directory: ./data/cache/PathHandler +# #Enable handler metadata cache +# metadata: +# cache: +# directory: ./data/cache/PathHandler + +#Enable data transfer metadata cache for DTOs +#Articus\DataTransfer\MetadataProvider\Annotation: +# cache: +# directory: ./data/cache/DataTransfer diff --git a/samples/server/petstore/php-mezzio-ph/application/config/app.yml b/samples/server/petstore/php-mezzio-ph/application/config/app.yml new file mode 100644 index 00000000000..0ffd5e8864c --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/application/config/app.yml @@ -0,0 +1,22 @@ +dependencies: + invokables: + Laminas\HttpHandlerRunner\Emitter\EmitterInterface: Laminas\HttpHandlerRunner\Emitter\SapiStreamEmitter + factories: + Mezzio\Application: App\Factory + Mezzio\MiddlewareContainer: Mezzio\Container\MiddlewareContainerFactory + Mezzio\MiddlewareFactory: Mezzio\Container\MiddlewareFactoryFactory + Mezzio\Router\RouteCollector: Mezzio\Router\RouteCollectorFactory + + Psr\Http\Message\ServerRequestInterface: Mezzio\Container\ServerRequestFactoryFactory + Psr\Http\Message\StreamInterface: Mezzio\Container\StreamFactoryFactory + Psr\Http\Message\ResponseInterface: Mezzio\Container\ResponseFactoryFactory + + App\Middleware\InternalServerError: Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory + Mezzio\Router\Middleware\RouteMiddleware: Mezzio\Router\Middleware\RouteMiddlewareFactory + Mezzio\Router\Middleware\DispatchMiddleware: Mezzio\Router\Middleware\DispatchMiddlewareFactory + Mezzio\Router\Middleware\MethodNotAllowedMiddleware: Mezzio\Router\Middleware\MethodNotAllowedMiddlewareFactory + Mezzio\Handler\NotFoundHandler: Mezzio\Container\NotFoundHandlerFactory + +Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory: + App\Middleware\InternalServerError: + - Psr\Http\Message\ResponseInterface diff --git a/samples/server/petstore/php-mezzio-ph/application/config/data_transfer.yml b/samples/server/petstore/php-mezzio-ph/application/config/data_transfer.yml new file mode 100644 index 00000000000..c5174147c23 --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/application/config/data_transfer.yml @@ -0,0 +1,26 @@ +dependencies: + factories: + Articus\DataTransfer\Service: Articus\DataTransfer\Factory + Articus\DataTransfer\MetadataProvider\Annotation: Articus\DataTransfer\MetadataProvider\Factory\Annotation + Articus\DataTransfer\Strategy\PluginManager: Articus\DataTransfer\Strategy\Factory\PluginManager + Articus\DataTransfer\Validator\PluginManager: Articus\DataTransfer\Validator\Factory\PluginManager + Laminas\Validator\ValidatorPluginManager: Laminas\Validator\ValidatorPluginManagerFactory + aliases: + Articus\DataTransfer\ClassMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\Annotation + Articus\DataTransfer\FieldMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\Annotation + +Articus\DataTransfer\Strategy\PluginManager: + invokables: + QueryStringScalar: OpenAPIGenerator\Common\Strategy\QueryStringScalar + QueryStringScalarArray: OpenAPIGenerator\Common\Strategy\QueryStringScalarArray + factories: + Date: OpenAPIGenerator\Common\Strategy\Factory\MutableDate + DateTime: OpenAPIGenerator\Common\Strategy\Factory\MutableDateTime + +Articus\DataTransfer\Validator\PluginManager: + invokables: + Scalar: OpenAPIGenerator\Common\Validator\Scalar + QueryStringScalar: OpenAPIGenerator\Common\Validator\QueryStringScalar + QueryStringScalarArray: OpenAPIGenerator\Common\Validator\QueryStringScalarArray + abstract_factories: + - Articus\DataTransfer\Validator\Factory\Laminas diff --git a/samples/server/petstore/php-mezzio-ph/application/config/path_handler.yml b/samples/server/petstore/php-mezzio-ph/application/config/path_handler.yml new file mode 100644 index 00000000000..25995b20d6f --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/application/config/path_handler.yml @@ -0,0 +1,49 @@ +dependencies: + factories: + Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory + +Articus\PathHandler\RouteInjection\Factory: + paths: + '/v2': + - App\Handler\Pet + - App\Handler\PetFindByStatus + - App\Handler\PetFindByTags + - App\Handler\PetPetId + - App\Handler\PetPetIdUploadImage + - App\Handler\StoreInventory + - App\Handler\StoreOrder + - App\Handler\StoreOrderOrderId + - App\Handler\User + - App\Handler\UserCreateWithArray + - App\Handler\UserCreateWithList + - App\Handler\UserLogin + - App\Handler\UserLogout + - App\Handler\UserUsername + handlers: + abstract_factories: + - Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory +# consumers: +# factories: +# invokables: +# attributes: +# factories: +# invokables: +# producers: +# factories: +# invokables: + +Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory: + App\Handler\Pet: [] + App\Handler\PetFindByStatus: [] + App\Handler\PetFindByTags: [] + App\Handler\PetPetId: [] + App\Handler\PetPetIdUploadImage: [] + App\Handler\StoreInventory: [] + App\Handler\StoreOrder: [] + App\Handler\StoreOrderOrderId: [] + App\Handler\User: [] + App\Handler\UserCreateWithArray: [] + App\Handler\UserCreateWithList: [] + App\Handler\UserLogin: [] + App\Handler\UserLogout: [] + App\Handler\UserUsername: [] diff --git a/samples/openapi3/server/petstore/php-ze-ph/application/container.php b/samples/server/petstore/php-mezzio-ph/application/container.php similarity index 90% rename from samples/openapi3/server/petstore/php-ze-ph/application/container.php rename to samples/server/petstore/php-mezzio-ph/application/container.php index 3518792765f..b9638c5584b 100644 --- a/samples/openapi3/server/petstore/php-ze-ph/application/container.php +++ b/samples/server/petstore/php-mezzio-ph/application/container.php @@ -1,7 +1,7 @@ setService('config', $config); diff --git a/samples/server/petstore/php-mezzio-ph/composer.json b/samples/server/petstore/php-mezzio-ph/composer.json new file mode 100644 index 00000000000..54f8e97226c --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/composer.json @@ -0,0 +1,27 @@ +{ + "name": "git_user_id/git_repo_id", + "description": "", + "license": "unlicense", + "version": "1.0.0", + "type": "project", + "require": { + "php": "^7.2", + "ext-yaml": "^2.0", + "mezzio/mezzio": "^3.2", + "laminas/laminas-diactoros": "^2.1", + "articus/path-handler": "^0.6", + "articus/data-transfer": "^0.4", + "articus/openapi-generator-common": "^0.1", + "doctrine/annotations": "^1.10", + "psr/simple-cache": "^1.0", + "laminas/laminas-config": "^3.4", + "laminas/laminas-stdlib": "^3.2", + "laminas/laminas-validator": "^2.13", + "nikic/fast-route": "^1.3" + }, + "autoload": { + "psr-4": { + "": "src/" + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/php-mezzio-ph/public/index.php b/samples/server/petstore/php-mezzio-ph/public/index.php new file mode 100644 index 00000000000..7c3de73df16 --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/public/index.php @@ -0,0 +1,11 @@ +get(\Mezzio\Application::class); +$app->run(); diff --git a/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/ApiResponse.php b/samples/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php similarity index 54% rename from samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/ApiResponse.php rename to samples/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php index 16867d96c40..a08cb2c9275 100644 --- a/samples/openapi3/server/petstore/php-ze-ph/src/App/DTO/ApiResponse.php +++ b/samples/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php @@ -6,25 +6,26 @@ namespace App\DTO; use Articus\DataTransfer\Annotation as DTA; /** + * Describes the result of uploading an image resource */ class ApiResponse { /** * @DTA\Data(field="code", nullable=true) - * @DTA\Validator(name="Type", options={"type":"int"}) - * @var int + * @DTA\Validator(name="Scalar", options={"type":"int"}) + * @var int|null */ public $code; /** * @DTA\Data(field="type", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $type; /** * @DTA\Data(field="message", nullable=true) - * @DTA\Validator(name="Type", options={"type":"string"}) - * @var string + * @DTA\Validator(name="Scalar", options={"type":"string"}) + * @var string|null */ public $message; } diff --git a/samples/server/petstore/php-mezzio-ph/src/App/DTO/Category.php b/samples/server/petstore/php-mezzio-ph/src/App/DTO/Category.php new file mode 100644 index 00000000000..7b65c273d40 --- /dev/null +++ b/samples/server/petstore/php-mezzio-ph/src/App/DTO/Category.php @@ -0,0 +1,26 @@ +get(\Zend\Expressive\Application::class); -$app->run(); diff --git a/samples/server/petstore/php-ze-ph/src/App/Strategy/Date.php b/samples/server/petstore/php-ze-ph/src/App/Strategy/Date.php deleted file mode 100644 index eedff2f01e2..00000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Strategy/Date.php +++ /dev/null @@ -1,21 +0,0 @@ -format(static::DATE_TIME_FORMAT); - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if (!empty($arrayValue)) { - $date = $this->parseDateString($arrayValue); - if ($date instanceof \DateTime) { - $result = $date; - } - } - return $result; - } - - /** - * @param $arrayValue - * @return bool|\DateTime - */ - protected function parseDateString($arrayValue) - { - return \DateTime::createFromFormat(static::DATE_TIME_FORMAT, $arrayValue, new \DateTimeZone('UTC')); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Strategy/QueryParameter.php b/samples/server/petstore/php-ze-ph/src/App/Strategy/QueryParameter.php deleted file mode 100644 index e9eac336a33..00000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Strategy/QueryParameter.php +++ /dev/null @@ -1,77 +0,0 @@ - true, - self::TYPE_FLOAT => true, - self::TYPE_BOOL => true, - self::TYPE_STRING => true, - ]; - - /** - * @var string - */ - protected $type; - - /** - * QueryParameterArray constructor. - */ - public function __construct(array $options) - { - if (empty($options['type'])) { - throw new \InvalidArgumentException('Option "type" is required.'); - } elseif (!isset(self::TYPE_MAP[$options['type']])) { - throw new \InvalidArgumentException(\sprintf('Unknown type "%s".', $options['type'])); - } - $this->type = $options['type']; - } - - - /** - * @inheritdoc - */ - public function extract($objectValue, $object = null) - { - $result = null; - if ($objectValue !== null) { - $result = (string)$objectValue; - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if ($arrayValue !== null) { - switch ($this->type) { - case self::TYPE_INT: - $result = (int)$arrayValue; - break; - case self::TYPE_FLOAT: - $result = (float)$arrayValue; - break; - case self::TYPE_BOOL: - $result = ($arrayValue === 'true')? true : false; - break; - case self::TYPE_STRING: - $result = (string)$arrayValue; - break; - } - } - return $result; - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Strategy/QueryParameterArray.php b/samples/server/petstore/php-ze-ph/src/App/Strategy/QueryParameterArray.php deleted file mode 100644 index 34f57d140fe..00000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Strategy/QueryParameterArray.php +++ /dev/null @@ -1,74 +0,0 @@ - ',', - self::FORMAT_SSV => ' ', - self::FORMAT_TSV => "\t", - self::FORMAT_PIPES => '|', - self::FORMAT_MULTI => null, - ]; - - /** - * @var string|null - */ - protected $delimiter; - - public function __construct(array $options) - { - parent::__construct($options); - if (empty($options['format'])) { - throw new \InvalidArgumentException('Option "format" is required.'); - } elseif (!\array_key_exists($options['format'], self::DELIMITER_MAP)) { - throw new \InvalidArgumentException(\sprintf('Unknown format "%s".', $options['format'])); - } - $this->delimiter = self::DELIMITER_MAP[$options['format']]; - } - - /** - * @inheritdoc - */ - public function extract($objectValue, $object = null) - { - $result = null; - if (\is_array($objectValue)) { - if ($this->delimiter === null) { - $result = $objectValue; - } else { - $result = \implode($this->delimiter, $objectValue); - } - } - return $result; - } - - /** - * @inheritdoc - */ - public function hydrate($arrayValue, $objectValue, array $array = null) - { - $result = null; - if ($arrayValue !== null) { - $list = null; - if ($this->delimiter === null) { - $list = (\is_array($arrayValue))? $arrayValue : [$arrayValue]; - } else { - $list = \explode($this->delimiter, $arrayValue); - } - $result = []; - foreach ($list as $item) { - $result[] = parent::hydrate($item, null); - } - } - return $result; - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Validator/QueryParameterArrayType.php b/samples/server/petstore/php-ze-ph/src/App/Validator/QueryParameterArrayType.php deleted file mode 100644 index 069cfaa51a3..00000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Validator/QueryParameterArrayType.php +++ /dev/null @@ -1,74 +0,0 @@ -format; - } - - /** - * @param string $format - * @return self - */ - public function setFormat(string $format): self - { - $this->format = $format; - return $this; - } - - protected function checkType($value): bool - { - $result = true; - if (!\array_key_exists($this->format, QueryParameterArray::DELIMITER_MAP)) { - throw new \InvalidArgumentException(\sprintf('Can not check for format %s.', $this->format)); - } - $delimiter = QueryParameterArray::DELIMITER_MAP[$this->format]; - if ($delimiter === null) { - if (\is_array($value)) { - foreach ($value as $item) { - $result = $result && parent::checkType($item); - } - } else { - $result = false; - } - } else { - switch ($this->type) { - case QueryParameterArray::TYPE_INT: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_INT, $delimiter), $value); - break; - case QueryParameterArray::TYPE_BOOL: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_BOOL, $delimiter), $value); - break; - case QueryParameterArray::TYPE_FLOAT: - $result = \is_string($value) && \preg_match(self::prepareRepeatingTypeRegExp(self::RE_FLOAT, $delimiter), $value); - break; - case QueryParameterArray::TYPE_STRING: - $result = \is_string($value); - break; - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } - return $result; - } - - protected static function prepareRepeatingTypeRegExp(string $typeRegExp, string $delimiter): string - { - $escapedDelimiter = \preg_quote($delimiter, '/'); - return '/^(' . $typeRegExp . ')(' . $escapedDelimiter . '('. $typeRegExp . '))*$/'; - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Validator/QueryParameterType.php b/samples/server/petstore/php-ze-ph/src/App/Validator/QueryParameterType.php deleted file mode 100644 index 6643990b744..00000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Validator/QueryParameterType.php +++ /dev/null @@ -1,29 +0,0 @@ -type) { - case QueryParameter::TYPE_INT: - return \is_string($value) && \preg_match('/^(' . self::RE_INT . ')$/', $value); - case QueryParameter::TYPE_BOOL: - return \is_string($value) && \preg_match('/^(' . self::RE_BOOL . ')$/', $value); - case QueryParameter::TYPE_FLOAT: - return \is_string($value) && \preg_match('/^(' . self::RE_FLOAT . ')$/', $value); - case QueryParameter::TYPE_STRING: - return \is_string($value); - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Validator/Type.php b/samples/server/petstore/php-ze-ph/src/App/Validator/Type.php deleted file mode 100644 index a3b883d6488..00000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Validator/Type.php +++ /dev/null @@ -1,73 +0,0 @@ - 'Invalid type given.', - ]; - - /** - * @var null|string - */ - protected $type; - - /** - * @return string - */ - public function getType(): ?string - { - return $this->type; - } - - /** - * @param string $type - * @return self - */ - public function setType(string $type): self - { - $this->type = $type; - return $this; - } - - /** - * @inheritdoc - */ - public function isValid($value) - { - $result = true; - if (!$this->checkType($value)) { - $this->error(self::INVALID); - $result = false; - } - return $result; - } - - protected function checkType($value): bool - { - switch ($this->type) { - case 'int': - return \is_int($value); - case 'bool': - return \is_bool($value); - case 'float': - return \is_float($value) || \is_int($value); - case 'string': - return \is_string($value); - default: - throw new \InvalidArgumentException(\sprintf('Can not check for type %s.', $this->type)); - } - } -} diff --git a/website/i18n/en.json b/website/i18n/en.json index 8f1c9b64db2..251a4c177af 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -395,9 +395,9 @@ "title": "Config Options for php-symfony", "sidebar_label": "php-symfony" }, - "generators/php-ze-ph": { - "title": "Config Options for php-ze-ph", - "sidebar_label": "php-ze-ph" + "generators/php-mezzio-ph": { + "title": "Config Options for php-mezzio-ph", + "sidebar_label": "php-mezzio-ph" }, "generators/php": { "title": "Config Options for php",