diff --git a/.gitignore b/.gitignore
index b56824e26e3..3a964a0bc5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -177,7 +177,6 @@ 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-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
diff --git a/bin/configs/php-mezzio-ph-modern.yaml b/bin/configs/php-mezzio-ph-modern.yaml
new file mode 100644
index 00000000000..accaa2dfe30
--- /dev/null
+++ b/bin/configs/php-mezzio-ph-modern.yaml
@@ -0,0 +1,6 @@
+generatorName: php-mezzio-ph
+outputDir: samples/server/petstore/php-mezzio-ph-modern
+inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
+templateDir: modules/openapi-generator/src/main/resources/php-mezzio-ph-modern
+additionalProperties:
+ modern: "true"
diff --git a/docs/generators/php-mezzio-ph.md b/docs/generators/php-mezzio-ph.md
index f691e8f57fb..93f31d7fbca 100644
--- a/docs/generators/php-mezzio-ph.md
+++ b/docs/generators/php-mezzio-ph.md
@@ -15,6 +15,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|invokerPackage|The main namespace to use for all classes. e.g. Yay\Pets| |null|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|
**true** The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document. **false** The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing. |true|
|modelPackage|package for generated models| |null|
+|modern|use modern language features (generated code will require PHP 8.0)| |false|
|packageName|The main package name for classes. e.g. GeneratedPetstore| |null|
|prependFormOrBodyParameters|Add form or body parameters to the beginning of the parameter list.| |false|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpMezzioPathHandlerServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpMezzioPathHandlerServerCodegen.java
index 658537e414b..529c5a27e21 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpMezzioPathHandlerServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpMezzioPathHandlerServerCodegen.java
@@ -21,9 +21,13 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.PathItem.HttpMethod;
+import io.swagger.v3.oas.models.Paths;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.QueryParameter;
+import io.swagger.v3.oas.models.parameters.RequestBody;
+import io.swagger.v3.oas.models.responses.ApiResponse;
+import io.swagger.v3.oas.models.responses.ApiResponses;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
@@ -35,12 +39,17 @@ import java.util.*;
public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(PhpMezzioPathHandlerServerCodegen.class);
-
- // TODO: Rename to x- prefixed vendor extensions, per specification.
+ // Custom generator option names
+ public static final String OPT_MODERN = "modern";
+ // Internal vendor extension names for extra template data that should not be set in specification
public static final String VEN_FROM_QUERY = "internal.ze-ph.fromQuery";
public static final String VEN_COLLECTION_FORMAT = "internal.ze-ph.collectionFormat";
public static final String VEN_QUERY_DATA_TYPE = "internal.ze-ph.queryDataType";
public static final String VEN_HAS_QUERY_DATA = "internal.ze-ph.hasQueryData";
+ public static final String VEN_FROM_CONTAINER = "internal.ze-ph.fromContainer";
+ public static final String VEN_CONTAINER_DATA_TYPE = "internal.ze-ph.containerDataType";
+
+ private boolean useModernSyntax = false;
@Override
public CodegenType getTag() {
@@ -85,6 +94,8 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
modelDirName = "DTO";
apiPackage = invokerPackage + "\\" + apiDirName;
modelPackage = invokerPackage + "\\" + modelDirName;
+ //"Api" classes have dedicated namespace so there is no need to add non-empty suffix by default
+ apiNameSuffix = "";
apiTestTemplateFiles.clear();
modelTestTemplateFiles.clear();
@@ -103,6 +114,17 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
supportingFiles.add(new SupportingFile("InternalServerError.php.mustache", srcBasePath + File.separator + "Middleware", "InternalServerError.php"));
additionalProperties.put(CodegenConstants.ARTIFACT_VERSION, "1.0.0");
+ //Register custom CLI options
+ addSwitch(OPT_MODERN, "use modern language features (generated code will require PHP 8.0)", useModernSyntax);
+ }
+
+ @Override
+ public void processOpts() {
+ super.processOpts();
+ if (additionalProperties.containsKey(OPT_MODERN)) {
+ embeddedTemplateDir = templateDir = "php-mezzio-ph-modern";
+ useModernSyntax = true;
+ }
}
/**
@@ -136,29 +158,31 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
}
}
- /**
- * Return the file name of the Api Test
- *
- * @param name the file name of the Api
- * @return the file name of the Api
- */
- @Override
- public String toApiFilename(String name) {
- return toApiName(name);
- }
-
- /**
- * Output the API (class) name (capitalized) ending with "Api"
- * Return DefaultApi if name is empty
- *
- * @param name the name of the Api
- * @return capitalized Api name ending with "Api"
- */
@Override
public String toApiName(String name) {
- //Remove }
- name = name.replaceAll("[\\}]", "");
- return super.toModelName(name);
+ return super.toApiName(toModelName(name));
+ }
+
+ @Override
+ public String getTypeDeclaration(Schema p) {
+ String result;
+ Map extensions = p.getExtensions();
+ if ((extensions != null) && extensions.containsKey(VEN_CONTAINER_DATA_TYPE)) {
+ result = (String) extensions.get(VEN_CONTAINER_DATA_TYPE);
+ } else if (useModernSyntax && (ModelUtils.isArraySchema(p) || ModelUtils.isMapSchema(p))) {
+ result = "array";
+ } else {
+ result = super.getTypeDeclaration(p);
+ }
+ return result;
+ }
+
+ @Override
+ public void preprocessOpenAPI(OpenAPI openAPI) {
+ super.preprocessOpenAPI(openAPI);
+
+ generateParameterSchemas(openAPI);
+ generateContainerSchemas(openAPI);
}
/**
@@ -166,10 +190,7 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
*
* @param openAPI OpenAPI object
*/
- @Override
- public void preprocessOpenAPI(OpenAPI openAPI) {
- super.preprocessOpenAPI(openAPI);
-
+ protected void generateParameterSchemas(OpenAPI openAPI) {
Map paths = openAPI.getPaths();
if (paths != null) {
for (String pathname : paths.keySet()) {
@@ -178,34 +199,34 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
if (operationMap != null) {
for (HttpMethod method : operationMap.keySet()) {
Operation operation = operationMap.get(method);
- Map schemas = new HashMap<>();
+ Map propertySchemas = new HashMap<>();
if (operation == null || operation.getParameters() == null) {
continue;
}
List requiredProperties = new ArrayList<>();
for (Parameter parameter : operation.getParameters()) {
- Schema schema = convertParameterToSchema(parameter);
- if (schema != null) {
- schemas.put(schema.getName(), schema);
- if (Boolean.TRUE.equals(parameter.getRequired())) {
- requiredProperties.add(schema.getName());
+ Parameter referencedParameter = ModelUtils.getReferencedParameter(openAPI, parameter);
+ Schema propertySchema = convertParameterToSchema(openAPI, referencedParameter);
+ if (propertySchema != null) {
+ propertySchemas.put(propertySchema.getName(), propertySchema);
+ if (Boolean.TRUE.equals(referencedParameter.getRequired())) {
+ requiredProperties.add(propertySchema.getName());
}
}
}
- if (!schemas.isEmpty()) {
- ObjectSchema model = new ObjectSchema();
+ if (!propertySchemas.isEmpty()) {
+ ObjectSchema schema = new ObjectSchema();
String operationId = getOrGenerateOperationId(operation, pathname, method.name());
- model.setDescription("Query parameters for " + operationId);
- model.setProperties(schemas);
- model.setRequired(requiredProperties);
- //Add internal extension directly, because addExtension filters extension names
- addInternalExtensionToSchema(model, VEN_FROM_QUERY, Boolean.TRUE);
- String definitionName = generateUniqueDefinitionName(operationId + "QueryData", openAPI);
- openAPI.getComponents().addSchemas(definitionName, model);
- String definitionModel = "\\" + modelPackage + "\\" + toModelName(definitionName);
- addInternalExtensionToOperation(operation, VEN_QUERY_DATA_TYPE, definitionModel);
+ schema.setDescription("Query parameters for " + operationId);
+ schema.setProperties(propertySchemas);
+ schema.setRequired(requiredProperties);
+ addInternalExtensionToSchema(schema, VEN_FROM_QUERY, Boolean.TRUE);
+ String schemaName = generateUniqueSchemaName(openAPI, operationId + "QueryData");
+ openAPI.getComponents().addSchemas(schemaName, schema);
+ String schemaDataType = getTypeDeclaration(toModelName(schemaName));
+ addInternalExtensionToOperation(operation, VEN_QUERY_DATA_TYPE, schemaDataType);
addInternalExtensionToOperation(operation, VEN_HAS_QUERY_DATA, Boolean.TRUE);
}
}
@@ -214,17 +235,18 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
}
}
- protected Schema convertParameterToSchema(Parameter parameter) {
+ protected Schema convertParameterToSchema(OpenAPI openAPI, Parameter parameter) {
Schema property = null;
if (parameter instanceof QueryParameter) {
QueryParameter queryParameter = (QueryParameter) parameter;
+ Schema parameterSchema = ModelUtils.getReferencedSchema(openAPI, queryParameter.getSchema());
// array
- if (ModelUtils.isArraySchema(queryParameter.getSchema())) {
- Schema inner = ((ArraySchema) queryParameter.getSchema()).getItems();
+ if (ModelUtils.isArraySchema(parameterSchema)) {
+ Schema itemSchema = ((ArraySchema) parameterSchema).getItems();
ArraySchema arraySchema = new ArraySchema();
- arraySchema.setMinItems(queryParameter.getSchema().getMinItems());
- arraySchema.setMaxItems(queryParameter.getSchema().getMaxItems());
- arraySchema.setItems(inner);
+ arraySchema.setMinItems(parameterSchema.getMinItems());
+ arraySchema.setMaxItems(parameterSchema.getMaxItems());
+ arraySchema.setItems(itemSchema);
String collectionFormat = getCollectionFormat(queryParameter);
if (collectionFormat == null) {
collectionFormat = "csv";
@@ -232,25 +254,25 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
addInternalExtensionToSchema(arraySchema, VEN_COLLECTION_FORMAT, collectionFormat);
property = arraySchema;
} else { // non-array e.g. string, integer
- switch (queryParameter.getSchema().getType()) {
+ switch (parameterSchema.getType()) {
case "string":
StringSchema stringSchema = new StringSchema();
- stringSchema.setMinLength(queryParameter.getSchema().getMinLength());
- stringSchema.setMaxLength(queryParameter.getSchema().getMaxLength());
- stringSchema.setPattern(queryParameter.getSchema().getPattern());
- stringSchema.setEnum(queryParameter.getSchema().getEnum());
+ stringSchema.setMinLength(parameterSchema.getMinLength());
+ stringSchema.setMaxLength(parameterSchema.getMaxLength());
+ stringSchema.setPattern(parameterSchema.getPattern());
+ stringSchema.setEnum(parameterSchema.getEnum());
property = stringSchema;
break;
case "integer":
IntegerSchema integerSchema = new IntegerSchema();
- integerSchema.setMinimum(queryParameter.getSchema().getMinimum());
- integerSchema.setMaximum(queryParameter.getSchema().getMaximum());
+ integerSchema.setMinimum(parameterSchema.getMinimum());
+ integerSchema.setMaximum(parameterSchema.getMaximum());
property = integerSchema;
break;
case "number":
NumberSchema floatSchema = new NumberSchema();
- floatSchema.setMinimum(queryParameter.getSchema().getMinimum());
- floatSchema.setMaximum(queryParameter.getSchema().getMaximum());
+ floatSchema.setMinimum(parameterSchema.getMinimum());
+ floatSchema.setMaximum(parameterSchema.getMaximum());
property = floatSchema;
break;
case "boolean":
@@ -264,6 +286,7 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
break;
}
}
+
if (property != null) {
property.setName(queryParameter.getName());
property.setDescription(queryParameter.getDescription());
@@ -289,7 +312,7 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
operation.getExtensions().put(name, value);
}
- protected String generateUniqueDefinitionName(String name, OpenAPI openAPI) {
+ protected String generateUniqueSchemaName(OpenAPI openAPI, String name) {
String result = name;
if (openAPI.getComponents().getSchemas() != null) {
int count = 1;
@@ -301,6 +324,90 @@ public class PhpMezzioPathHandlerServerCodegen extends AbstractPhpCodegen {
return result;
}
+ /**
+ * Generate additional model definitions for containers in whole specification
+ *
+ * @param openAPI OpenAPI object
+ */
+ protected void generateContainerSchemas(OpenAPI openAPI) {
+ Paths paths = openAPI.getPaths();
+ for (String pathName : paths.keySet()) {
+ for (Operation operation : paths.get(pathName).readOperations()) {
+ List parameters = operation.getParameters();
+ if (parameters != null) {
+ for (Parameter parameter : parameters) {
+ generateContainerSchemas(openAPI, ModelUtils.getReferencedParameter(openAPI, parameter).getSchema());
+ }
+ }
+ RequestBody requestBody = ModelUtils.getReferencedRequestBody(openAPI, operation.getRequestBody());
+ if (requestBody != null) {
+ Content requestBodyContent = requestBody.getContent();
+ if (requestBodyContent != null) {
+ for (String mediaTypeName : requestBodyContent.keySet()) {
+ generateContainerSchemas(openAPI, requestBodyContent.get(mediaTypeName).getSchema());
+ }
+ }
+ }
+ ApiResponses responses = operation.getResponses();
+ for (String responseCode : responses.keySet()) {
+ ApiResponse response = ModelUtils.getReferencedApiResponse(openAPI, responses.get(responseCode));
+ Content responseContent = response.getContent();
+ if (responseContent != null) {
+ for (String mediaTypeName : responseContent.keySet()) {
+ generateContainerSchemas(openAPI, responseContent.get(mediaTypeName).getSchema());
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Generate additional model definitions for containers in specified schema
+ *
+ * @param openAPI OpenAPI object
+ * @param schema OAS schema to process
+ */
+ protected void generateContainerSchemas(OpenAPI openAPI, Schema schema) {
+ if (schema != null) {
+ //Dereference schema
+ schema = ModelUtils.getReferencedSchema(openAPI, schema);
+ Boolean isContainer = Boolean.FALSE;
+
+ if (ModelUtils.isObjectSchema(schema)) {
+ //Recursively process all schemas of object properties
+ Map properties = schema.getProperties();
+ if (properties != null) {
+ for (String propertyName: properties.keySet()) {
+ generateContainerSchemas(openAPI, properties.get(propertyName));
+ }
+ }
+ } else if (ModelUtils.isArraySchema(schema)) {
+ //Recursively process schema of array items
+ generateContainerSchemas(openAPI, ((ArraySchema) schema).getItems());
+ isContainer = Boolean.TRUE;
+ } else if (ModelUtils.isMapSchema(schema)) {
+ //Recursively process schema of map items
+ Object itemSchema = schema.getAdditionalProperties();
+ if (itemSchema instanceof Schema) {
+ generateContainerSchemas(openAPI, (Schema) itemSchema);
+ }
+ isContainer = Boolean.TRUE;
+ }
+
+ if (isContainer) {
+ //Generate special component schema for container
+ String containerSchemaName = generateUniqueSchemaName(openAPI, "Collection");
+ Schema containerSchema = new ObjectSchema();
+ containerSchema.addProperties("inner", schema);
+ addInternalExtensionToSchema(containerSchema, VEN_FROM_CONTAINER, Boolean.TRUE);
+ openAPI.getComponents().addSchemas(containerSchemaName, containerSchema);
+ String containerDataType = getTypeDeclaration(toModelName(containerSchemaName));
+ addInternalExtensionToSchema(schema, VEN_CONTAINER_DATA_TYPE, containerDataType);
+ }
+ }
+ }
+
@Override
public Map postProcessOperationsWithModels(Map objs, List allModels) {
objs = super.postProcessOperationsWithModels(objs, allModels);
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/Factory.php.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/Factory.php.mustache
new file mode 100644
index 00000000000..c517b693604
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/Factory.php.mustache
@@ -0,0 +1,53 @@
+get(EmitterInterface::class),
+ $container->get(ServerRequestInterface::class),
+ static fn(\Throwable $error): ResponseInterface => $errorMiddleware->handleError($error)
+ );
+ $application = new Application(
+ $container->get(MiddlewareFactory::class),
+ $pipeline,
+ $container->get(RouteCollector::class),
+ $runner
+ );
+ $application->pipe($errorMiddleware);
+ $application->pipe(RouteMiddleware::class);
+ $application->pipe(MethodNotAllowedMiddleware::class);
+ $application->pipe(DispatchMiddleware::class);
+ $application->pipe(NotFoundHandler::class);
+
+ return $application;
+ }
+
+ protected static function getErrorMiddleware(ContainerInterface $container): Middleware\InternalServerError
+ {
+ return $container->get(Middleware\InternalServerError::class);
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/InternalServerError.php.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/InternalServerError.php.mustache
new file mode 100644
index 00000000000..54f4d66a56d
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/InternalServerError.php.mustache
@@ -0,0 +1,45 @@
+handle($request);
+ ErrorHandler::stop(true);
+ }
+ catch (\Throwable $error) {
+ $result = $this->handleError($error);
+ }
+ return $result;
+ }
+
+ public function handleError(\Throwable $error): ResponseInterface
+ {
+ \error_log((string)$error);
+ return $this->generateEmptyResponse()->withStatus(500, 'Internal server error');
+ }
+
+ protected function generateEmptyResponse(): ResponseInterface
+ {
+ return ($this->responseGenerator)();
+ }
+}
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/README.md.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/README.md.mustache
new file mode 100644
index 00000000000..fd66369b261
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/README.md.mustache
@@ -0,0 +1,34 @@
+# OpenAPI generated server
+
+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: >=8.0
+- [Laminas Mezzio](https://docs.mezzio.dev/mezzio/): >=3.3
+- [Path Handler](https://github.com/Articus/PathHandler): >=0.7
+
+## 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` (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:
+
+- `404 Not found` for unknown routes
+- `406 Not acceptable` for invalid `Accept` header
+- `415 Unsupported media type` for invalid `Content-Type` header
+- `400 Malformed JSON` for unparsable JSON body
+- `422 Unprocessable entity` for parsable JSON body that fails validation
+
+But for obvious reason you will not get any `200 OK`, only `501 Not implemented`. So your next steps are:
+
+- check all TODOs left in the stub code where generator was not smart enough and could not guarantee correct implementation
+- implement your API security mechanism (either special attribute or separate middleware) - generator does not do anything about it yet
+- 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-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-mezzio-ph-modern/api.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/api.mustache
new file mode 100644
index 00000000000..fdba51f5e00
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/api.mustache
@@ -0,0 +1,73 @@
+ {{internal.ze-ph.queryDataType}}::class,
+ "objectAttr" => "queryData",
+ "source" => PHAttribute\Transfer::SOURCE_GET
+ ])]
+{{/internal.ze-ph.hasQueryData}}
+{{/vendorExtensions}}
+{{#bodyParam}}
+{{#consumes}}
+ // TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Consumer("{{{mediaType}}}", PHConsumer\Json::class)]
+{{/consumes}}
+{{^isPrimitiveType}}
+ #[PHA\Attribute(PHAttribute\Transfer::class, ["type" => {{dataType}}::class, "objectAttr" => "bodyData"])]
+{{/isPrimitiveType}}
+{{/bodyParam}}
+{{#produces}}
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("{{{mediaType}}}", PHProducer\Transfer::class)]
+{{/produces}}
+ public function {{operationId}}(ServerRequestInterface $request){{#returnType}}: {{returnType}}{{/returnType}}
+ {
+ //TODO implement method
+{{#vendorExtensions}}
+{{#internal.ze-ph.hasQueryData}}
+ /** @var {{internal.ze-ph.queryDataType}} $queryData */
+ $queryData = $request->getAttribute("queryData");
+{{/internal.ze-ph.hasQueryData}}
+{{/vendorExtensions}}
+{{#bodyParam}}
+{{^isPrimitiveType}}
+ /** @var {{dataType}} $bodyData */
+ $bodyData = $request->getAttribute("bodyData");
+{{/isPrimitiveType}}
+{{/bodyParam}}
+ throw new PHException\HttpCode(501, "Not implemented");
+ }
+{{/operation}}
+}
+{{/operations}}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/application/config/app.yml b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/app.yml.mustache
similarity index 100%
rename from samples/openapi3/server/petstore/php-mezzio-ph/application/config/app.yml
rename to modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/app.yml.mustache
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/composer.json.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/composer.json.mustache
new file mode 100644
index 00000000000..787d5fb97f2
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/composer.json.mustache
@@ -0,0 +1,26 @@
+{
+ "name": "{{#lambda.lowercase}}{{gitUserId}}/{{gitRepoId}}{{/lambda.lowercase}}",
+ "description": "{{description}}",
+ "license": "unlicense",
+ "version": "{{artifactVersion}}",
+ "type": "project",
+ "require": {
+ "php": "^8.0",
+ "ext-yaml": "^2.2",
+ "mezzio/mezzio": "^3.3",
+ "laminas/laminas-diactoros": "^2.5",
+ "articus/path-handler": "^0.7",
+ "articus/data-transfer": "^0.5",
+ "articus/openapi-generator-common": "^0.2",
+ "psr/simple-cache": "^1.0",
+ "laminas/laminas-config": "^3.4",
+ "laminas/laminas-stdlib": "^3.3",
+ "laminas/laminas-validator": "^2.14",
+ "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/application/config.yml b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/config.yml
similarity index 68%
rename from samples/openapi3/server/petstore/php-mezzio-ph/application/config.yml
rename to modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/config.yml
index 1f106812353..58056552c5b 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/application/config.yml
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/config.yml
@@ -9,12 +9,13 @@
# router:
# cache:
# directory: ./data/cache/PathHandler
-# #Enable handler metadata cache
-# metadata:
-# cache:
-# directory: ./data/cache/PathHandler
+
+#Enable handler metadata cache
+#Articus\PathHandler\MetadataProvider\PhpAttribute:
+# cache:
+# directory: ./data/cache/PathHandler
#Enable data transfer metadata cache for DTOs
-#Articus\DataTransfer\MetadataProvider\Annotation:
+#Articus\DataTransfer\MetadataProvider\PhpAttribute:
# cache:
# directory: ./data/cache/DataTransfer
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/application/container.php b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/container.php
similarity index 91%
rename from samples/openapi3/server/petstore/php-mezzio-ph/application/container.php
rename to modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/container.php
index b9638c5584b..9c54fafcfec 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/application/container.php
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/container.php
@@ -6,9 +6,6 @@ use Laminas\Config\Factory as ConfigFactory;
//Use Composer autoload that includes code both from ../src and ../vendor
require __DIR__ . '/../vendor/autoload.php';
-//Register Doctrine annotation autoload
-\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
-
//Path to file for caching full configuration
const CONFIG_CACHE_PATH = __DIR__ . '/../data/cache/config.php';
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/data_transfer.yml.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/data_transfer.yml.mustache
new file mode 100644
index 00000000000..7bdd139bb9f
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/data_transfer.yml.mustache
@@ -0,0 +1,34 @@
+dependencies:
+ factories:
+ Articus\DataTransfer\Service: Articus\DataTransfer\Factory
+ Articus\DataTransfer\MetadataProvider\PhpAttribute: Articus\DataTransfer\MetadataProvider\Factory\PhpAttribute
+ 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\PhpAttribute
+ Articus\DataTransfer\FieldMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\PhpAttribute
+
+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
+ ObjectList: OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectList
+ ObjectMap: OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectMap
+ ScalarList: OpenAPIGenerator\Common\Strategy\Factory\ScalarList
+ ScalarMap: OpenAPIGenerator\Common\Strategy\Factory\ScalarMap
+
+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
+
+validators:
+ invokables:
+ Count: Laminas\Validator\IsCountable
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/.gitignore b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/gitignore
similarity index 100%
rename from samples/openapi3/server/petstore/php-mezzio-ph/.gitignore
rename to modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/gitignore
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/public/index.php b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/index.php
similarity index 100%
rename from samples/openapi3/server/petstore/php-mezzio-ph/public/index.php
rename to modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/index.php
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/list_item_type.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/list_item_type.mustache
new file mode 100644
index 00000000000..25467661433
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/list_item_type.mustache
@@ -0,0 +1,8 @@
+{{#items
+}}{{^isContainer
+}}{{#isPrimitiveType}}"{{dataType}}"{{/isPrimitiveType
+}}{{^isPrimitiveType}}{{dataType}}::class{{/isPrimitiveType
+}}{{/isContainer
+}}{{#isContainer
+}}{{dataType}}::class{{/isContainer
+}}{{/items}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/map_item_type.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/map_item_type.mustache
new file mode 100644
index 00000000000..a58e19beca5
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/map_item_type.mustache
@@ -0,0 +1,8 @@
+{{#additionalProperties
+}}{{^isContainer
+}}{{#isPrimitiveType}}"{{dataType}}"{{/isPrimitiveType
+}}{{^isPrimitiveType}}{{dataType}}::class{{/isPrimitiveType
+}}{{/isContainer
+}}{{#isContainer
+}}{{dataType}}::class{{/isContainer
+}}{{/additionalProperties}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model.mustache
new file mode 100644
index 00000000000..4d73c185945
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model.mustache
@@ -0,0 +1,13 @@
+model_container}}{{/internal.ze-ph.fromContainer
+}}{{^internal.ze-ph.fromContainer}}{{>model_object}}{{/internal.ze-ph.fromContainer
+}}{{/vendorExtensions
+}}{{^vendorExtensions}}{{>model_object}}{{/vendorExtensions
+}}{{/model}}{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_container.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_container.mustache
new file mode 100644
index 00000000000..543194c798b
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_container.mustache
@@ -0,0 +1,57 @@
+{{#vars
+}}{{#isArray
+}}#[DTA\Strategy("{{#isPrimitiveType}}ScalarList{{/isPrimitiveType}}{{^isPrimitiveType}}ObjectList{{/isPrimitiveType}}", ["type" => {{>list_item_type}}])]
+{{#minItems}}{{^maxItems
+}}#[DTA\Validator("Count", ["min" => {{minItems}}], blocker: true)]
+{{/maxItems}}{{/minItems
+}}{{^minItems}}{{#maxItems
+}}#[DTA\Validator("Count", ["max" => {{maxItems}}], blocker: true)]
+{{/maxItems}}{{/minItems
+}}{{#minItems}}{{#maxItems
+}}#[DTA\Validator("Count", ["min" => {{minItems}}, "max" => {{maxItems}}], blocker: true)]
+{{/maxItems}}{{/minItems
+}}#[DTA\Validator("Collection", ["validators" => [
+{{#isPrimitiveType
+}} ["name" => "Scalar", "options" => ["type" => {{>list_item_type}}]]
+{{/isPrimitiveType
+}}{{#isDate
+}} ["name" => "Date"]
+{{/isDate
+}}{{#isDateTime
+}} ["name" => "Date", "options" => ["format" => \DateTime::RFC3339]]
+{{/isDateTime
+}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime
+}} ["name" => "TypeCompliant", "options" => ["type" => {{>list_item_type}}]]
+{{/isDateTime}}{{/isDate}}{{/isPrimitiveType
+}}]])]
+{{/isArray
+}}{{#isMap
+}}#[DTA\Strategy("{{#isPrimitiveType}}ScalarMap{{/isPrimitiveType}}{{^isPrimitiveType}}ObjectMap{{/isPrimitiveType}}", ["type" => {{>map_item_type}}])]
+{{#minProperties}}{{^maxProperties
+}}#[DTA\Validator("Count", ["min" => {{minProperties}}], blocker: true)]
+{{/maxProperties}}{{/minProperties
+}}{{^minProperties}}{{#maxProperties
+}}#[DTA\Validator("Count", ["max" => {{maxProperties}}], blocker: true)]
+{{/maxProperties}}{{/minProperties
+}}{{#minProperties}}{{#maxProperties
+}}#[DTA\Validator("Count", ["min" => {{minProperties}}, "max" => {{maxProperties}}], blocker: true)]
+{{/maxProperties}}{{/minProperties
+}}#[DTA\Validator("Collection", ["validators" => [
+{{#isPrimitiveType
+}} ["name" => "Scalar", "options" => ["type" => {{>map_item_type}}]]
+{{/isPrimitiveType
+}}{{#isDate
+}} ["name" => "Date"]
+{{/isDate
+}}{{#isDateTime
+}} ["name" => "Date", "options" => ["format" => \DateTime::RFC3339]]
+{{/isDateTime
+}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime
+}} ["name" => "TypeCompliant", "options" => ["type" => {{>map_item_type}}]]
+{{/isDateTime}}{{/isDate}}{{/isPrimitiveType
+}}]])]
+{{/isMap
+}}{{/vars
+}}class {{classname}} extends \ArrayObject
+{
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_normal_var.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_normal_var.mustache
new file mode 100644
index 00000000000..6e215f7fc63
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_normal_var.mustache
@@ -0,0 +1,45 @@
+{{#isContainer
+}} #[DTA\Strategy("Object", ["type" => {{internal.ze-ph.containerDataType}}::class])]
+ #[DTA\Validator("TypeCompliant", ["type" => {{internal.ze-ph.containerDataType}}::class])]
+{{/isContainer
+}}{{^isContainer
+}}{{#isPrimitiveType
+}} #[DTA\Validator("Scalar", ["type" => "{{dataType}}"])]
+{{/isPrimitiveType
+}}{{#isDate
+}} #[DTA\Strategy("Date")]
+ #[DTA\Validator("Date")]
+{{/isDate
+}}{{#isDateTime
+}} #[DTA\Strategy("DateTime")]
+ #[DTA\Validator("Date", ["format" => \DateTime::RFC3339])]
+{{/isDateTime
+}}{{^isPrimitiveType
+}}{{^isDate
+}}{{^isDateTime
+}} #[DTA\Strategy("Object", ["type" => {{dataType}}::class])]
+ #[DTA\Validator("TypeCompliant", ["type" => {{dataType}}::class])]
+{{/isDateTime
+}}{{/isDate
+}}{{/isPrimitiveType
+}}{{/isContainer
+}}{{#hasValidation
+}}{{#minLength}}{{#maxLength
+}} #[DTA\Validator("StringLength", ["min" => {{minLength}}, "max" => {{maxLength}}])]
+{{/maxLength}}{{/minLength
+}}{{^minLength}}{{#maxLength
+}} #[DTA\Validator("StringLength", ["max" => {{maxLength}}])]
+{{/maxLength}}{{/minLength
+}}{{#minLength}}{{^maxLength
+}} #[DTA\Validator("StringLength", ["min" => {{minLength}}])]
+{{/maxLength}}{{/minLength
+}}{{#minimum
+}} #[DTA\Validator("GreaterThan", ["min" => {{minimum}}{{^exclusiveMinimum}}, "inclusive" => true{{/exclusiveMinimum}}])]
+{{/minimum
+}}{{#maximum
+}} #[DTA\Validator("LessThan", ["max" => {{maximum}}{{^exclusiveMaximum}}, "inclusive" => true{{/exclusiveMaximum}}])]
+{{/maximum
+}}{{#pattern
+}} #[DTA\Validator("Regex", ["pattern" => "{{{pattern}}}"])]
+{{/pattern
+}}{{/hasValidation}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_object.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_object.mustache
new file mode 100644
index 00000000000..253d551e3c7
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_object.mustache
@@ -0,0 +1,23 @@
+{{#description
+}}/**
+ * {{description}}
+ */
+{{/description
+}}class {{classname}}
+{
+{{#vars
+}}{{#description
+}} /**
+ * {{description}}
+ */
+{{/description
+}} #[DTA\Data(field: "{{baseName}}"{{^required}}, nullable: true{{/required}})]
+{{#vendorExtensions
+}}{{#internal.ze-ph.fromQuery}}{{>model_query_var}}{{/internal.ze-ph.fromQuery
+}}{{^internal.ze-ph.fromQuery}}{{>model_normal_var}}{{/internal.ze-ph.fromQuery
+}}{{/vendorExtensions
+}}{{^vendorExtensions}}{{>model_normal_var}}{{/vendorExtensions
+}} public {{dataType}}|null ${{name}} = null;
+
+{{/vars
+}}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_query_var.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_query_var.mustache
new file mode 100644
index 00000000000..f2e6525b9b9
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/model_query_var.mustache
@@ -0,0 +1,51 @@
+{{#isArray
+}}{{#isPrimitiveType
+}} #[DTA\Strategy("QueryStringScalarArray", ["type" => {{>list_item_type}}, "format" => "{{internal.ze-ph.collectionFormat}}"])]
+ #[DTA\Validator("QueryStringScalarArray", ["type" => {{>list_item_type}}, "format" => "{{internal.ze-ph.collectionFormat}}"{{#minItems}}, "min_items" => {{minItems}}{{/minItems}}{{#maxItems}}, "max_items" => {{maxItems}}{{/maxItems}}])]
+{{/isPrimitiveType
+}}{{^isPrimitiveType
+}} // TODO add validator(s) and strategy for list of {{>list_item_type}} and collection format {{internal.ze-ph.collectionFormat}} inside query string
+{{/isPrimitiveType
+}}{{/isArray
+}}{{#isMap
+}} // TODO add validator(s) and strategy for map of {{>map_item_type}} and collection format {{internal.ze-ph.collectionFormat}} inside query string
+{{/isMap
+}}{{^isContainer
+}}{{#isPrimitiveType
+}} #[DTA\Strategy("QueryStringScalar", ["type" => "{{dataType}}"])]
+ #[DTA\Validator("QueryStringScalar", ["type" => "{{dataType}}"])]
+{{/isPrimitiveType
+}}{{#isDate
+}} #[DTA\Strategy("Date")]
+ #[DTA\Validator("Date")]
+{{/isDate
+}}{{#isDateTime
+}} #[DTA\Strategy("DateTime")]
+ #[DTA\Validator("Date", ["format" => \DateTime::RFC3339])]
+{{/isDateTime
+}}{{^isPrimitiveType
+}}{{^isDate}}{{^isDateTime
+}} // TODO add validator(s) and strategy for {{dataType}} inside query string
+{{/isDateTime}}{{/isDate
+}}{{/isPrimitiveType
+}}{{/isContainer
+}}{{#hasValidation
+}}{{#minLength}}{{#maxLength
+}} #[DTA\Validator("StringLength", ["min" => {{minLength}}, "max" => {{maxLength}}])]
+{{/maxLength}}{{/minLength
+}}{{^minLength}}{{#maxLength
+}} #[DTA\Validator("StringLength", ["max" => {{maxLength}}])]
+{{/maxLength}}{{/minLength
+}}{{#minLength}}{{^maxLength
+}} #[DTA\Validator("StringLength", ["min" => {{minLength}}])]
+{{/maxLength}}{{/minLength
+}}{{#minimum
+}} #[DTA\Validator("GreaterThan", ["min" => {{minimum}}{{^exclusiveMinimum}}, "inclusive" => true{{/exclusiveMinimum}}])]
+{{/minimum
+}}{{#maximum
+}} #[DTA\Validator("LessThan", ["max" => {{maximum}}{{^exclusiveMaximum}}, "inclusive" => true{{/exclusiveMaximum}}])]
+{{/maximum
+}}{{#pattern
+}} #[DTA\Validator("Regex", ["pattern" => "{{{pattern}}}"])]
+{{/pattern
+}}{{/hasValidation}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/path_handler.yml.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/path_handler.yml.mustache
new file mode 100644
index 00000000000..a9739a17216
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph-modern/path_handler.yml.mustache
@@ -0,0 +1,44 @@
+dependencies:
+ factories:
+ Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjectionFactory
+ Articus\PathHandler\MetadataProviderInterface: Articus\PathHandler\MetadataProvider\Factory\PhpAttribute
+ Articus\PathHandler\Handler\PluginManager: Articus\PathHandler\Handler\Factory\PluginManager
+ Articus\PathHandler\Consumer\PluginManager: Articus\PathHandler\Consumer\Factory\PluginManager
+ Articus\PathHandler\Attribute\PluginManager: Articus\PathHandler\Attribute\Factory\PluginManager
+ Articus\PathHandler\Producer\PluginManager: Articus\PathHandler\Producer\Factory\PluginManager
+
+Articus\PathHandler\RouteInjectionFactory:
+ paths:
+ '{{basePathWithoutHost}}':
+{{#apiInfo}}
+{{#apis}}
+{{#operations}}
+ - {{package}}\{{classname}}
+{{/operations}}
+{{/apis}}
+{{/apiInfo}}
+
+Articus\PathHandler\Handler\PluginManager:
+ abstract_factories:
+ - Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory
+
+#Articus\PathHandler\Consumer\PluginManager:
+# factories:
+# invokables:
+
+#Articus\PathHandler\Attribute\PluginManager:
+# factories:
+# invokables:
+
+#Articus\PathHandler\Producer\PluginManager:
+# factories:
+# invokables:
+
+Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory:
+{{#apiInfo}}
+{{#apis}}
+{{#operations}}
+ {{package}}\{{classname}}: []
+{{/operations}}
+{{/apis}}
+{{/apiInfo}}
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/Factory.php.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/Factory.php.mustache
index 68787c5fd6c..bee7ad98a78 100644
--- a/modules/openapi-generator/src/main/resources/php-mezzio-ph/Factory.php.mustache
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/Factory.php.mustache
@@ -23,20 +23,13 @@ class Factory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): Application
{
- $errorMiddleware = $container->get(Middleware\InternalServerError::class);
- if (!($errorMiddleware instanceof Middleware\InternalServerError)) {
- throw new \LogicException(\sprintf(
- 'Invalid error middleware: expecting %s, not %s.',
- Middleware\InternalServerError::class,
- \is_object($errorMiddleware) ? \get_class($errorMiddleware) : \gettype($errorMiddleware)
- ));
- }
+ $errorMiddleware = self::getErrorMiddleware($container);
$pipeline = new MiddlewarePipe();
$runner = new RequestHandlerRunner(
$pipeline,
$container->get(EmitterInterface::class),
$container->get(ServerRequestInterface::class),
- function(\Throwable $error) use ($errorMiddleware) : ResponseInterface
+ static function(\Throwable $error) use ($errorMiddleware) : ResponseInterface
{
return $errorMiddleware->handleError($error);
}
@@ -55,4 +48,9 @@ class Factory implements FactoryInterface
return $application;
}
+
+ protected static function getErrorMiddleware(ContainerInterface $container): Middleware\InternalServerError
+ {
+ return $container->get(Middleware\InternalServerError::class);
+ }
}
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/README.md.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/README.md.mustache
index 584fd156879..a8047005901 100644
--- a/modules/openapi-generator/src/main/resources/php-mezzio-ph/README.md.mustache
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/README.md.mustache
@@ -5,9 +5,9 @@ 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.2
+- PHP: >=7.3
- [Laminas Mezzio](https://docs.mezzio.dev/mezzio/): >=3.2
-- [Path Handler](https://github.com/Articus/PathHandler): >=0.6
+- [Path Handler](https://github.com/Articus/PathHandler): >=0.7
## How to use
All you have to do to start development is:
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/api.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/api.mustache
index d44e206de6f..ec0d1df137b 100644
--- a/modules/openapi-generator/src/main/resources/php-mezzio-ph/api.mustache
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/api.mustache
@@ -43,13 +43,7 @@ class {{classname}}
* @PHA\Consumer(name=PHConsumer\Json::class, mediaRange="{{{mediaType}}}")
{{/consumes}}
{{^isPrimitiveType}}
-{{#isContainer}}
- * TODO check if attribute is valid and can handle your container type
- * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":"{{{dataType}}}","objectAttr":"bodyData"})
-{{/isContainer}}
-{{^isContainer}}
- * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":{{{dataType}}}::class,"objectAttr":"bodyData"})
-{{/isContainer}}
+ * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":{{dataType}}::class,"objectAttr":"bodyData"})
{{/isPrimitiveType}}
{{/bodyParam}}
{{#produces}}
@@ -61,13 +55,10 @@ class {{classname}}
* @throws PHException\HttpCode 501 if the method is not implemented
{{#returnType}}
*
-{{#returnContainer}}
- * TODO check if generated return container type is valid
-{{/returnContainer}}
- * @return {{{returnType}}}
+ * @return {{returnType}}
{{/returnType}}
*/
- public function {{operationId}}(ServerRequestInterface $request){{#returnType}}: {{#returnContainer}}array{{/returnContainer}}{{^returnContainer}}{{returnType}}{{/returnContainer}}{{/returnType}}
+ public function {{operationId}}(ServerRequestInterface $request){{#returnType}}: {{returnType}}{{/returnType}}
{
//TODO implement method
{{#vendorExtensions}}
@@ -78,7 +69,7 @@ class {{classname}}
{{/vendorExtensions}}
{{#bodyParam}}
{{^isPrimitiveType}}
- /** @var {{{dataType}}} $bodyData */
+ /** @var {{dataType}} $bodyData */
$bodyData = $request->getAttribute("bodyData");
{{/isPrimitiveType}}
{{/bodyParam}}
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
index a768982234a..de46c4b20ea 100644
--- 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
@@ -5,13 +5,13 @@
"version": "{{artifactVersion}}",
"type": "project",
"require": {
- "php": "^7.2",
+ "php": "^7.3 || ^8.0",
"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",
+ "articus/path-handler": "^0.7",
+ "articus/data-transfer": "^0.5",
+ "articus/openapi-generator-common": "^0.2",
"doctrine/annotations": "^1.10",
"psr/simple-cache": "^1.0",
"laminas/laminas-config": "^3.4",
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
index 1f106812353..71371becf21 100644
--- a/modules/openapi-generator/src/main/resources/php-mezzio-ph/config.yml
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/config.yml
@@ -9,10 +9,11 @@
# router:
# cache:
# directory: ./data/cache/PathHandler
-# #Enable handler metadata cache
-# metadata:
-# cache:
-# directory: ./data/cache/PathHandler
+
+#Enable handler metadata cache
+#Articus\PathHandler\MetadataProvider\Annotation:
+# cache:
+# directory: ./data/cache/PathHandler
#Enable data transfer metadata cache for DTOs
#Articus\DataTransfer\MetadataProvider\Annotation:
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
index c5174147c23..548c898fb9c 100644
--- 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
@@ -16,6 +16,10 @@ Articus\DataTransfer\Strategy\PluginManager:
factories:
Date: OpenAPIGenerator\Common\Strategy\Factory\MutableDate
DateTime: OpenAPIGenerator\Common\Strategy\Factory\MutableDateTime
+ ObjectList: OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectList
+ ObjectMap: OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectMap
+ ScalarList: OpenAPIGenerator\Common\Strategy\Factory\ScalarList
+ ScalarMap: OpenAPIGenerator\Common\Strategy\Factory\ScalarMap
Articus\DataTransfer\Validator\PluginManager:
invokables:
@@ -24,3 +28,7 @@ Articus\DataTransfer\Validator\PluginManager:
QueryStringScalarArray: OpenAPIGenerator\Common\Validator\QueryStringScalarArray
abstract_factories:
- Articus\DataTransfer\Validator\Factory\Laminas
+
+validators:
+ invokables:
+ Count: Laminas\Validator\IsCountable
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/list_item_type.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/list_item_type.mustache
new file mode 100644
index 00000000000..25467661433
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/list_item_type.mustache
@@ -0,0 +1,8 @@
+{{#items
+}}{{^isContainer
+}}{{#isPrimitiveType}}"{{dataType}}"{{/isPrimitiveType
+}}{{^isPrimitiveType}}{{dataType}}::class{{/isPrimitiveType
+}}{{/isContainer
+}}{{#isContainer
+}}{{dataType}}::class{{/isContainer
+}}{{/items}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/map_item_type.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/map_item_type.mustache
new file mode 100644
index 00000000000..a58e19beca5
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/map_item_type.mustache
@@ -0,0 +1,8 @@
+{{#additionalProperties
+}}{{^isContainer
+}}{{#isPrimitiveType}}"{{dataType}}"{{/isPrimitiveType
+}}{{^isPrimitiveType}}{{dataType}}::class{{/isPrimitiveType
+}}{{/isContainer
+}}{{#isContainer
+}}{{dataType}}::class{{/isContainer
+}}{{/additionalProperties}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/model.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model.mustache
index 57f70bfc767..fd2a8cc6208 100644
--- a/modules/openapi-generator/src/main/resources/php-mezzio-ph/model.mustache
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model.mustache
@@ -5,23 +5,9 @@ namespace {{package}};
use Articus\DataTransfer\Annotation as DTA;
-/**
-{{#description}}
- * {{description}}
-{{/description}}
- */
-class {{classname}}
-{
-{{#vars}}
- /**
-{{#description}}
- * {{description}}
-{{/description}}
- * @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}}|null
- */
- public ${{name}};
-{{/vars}}
-}{{/model}}{{/models}}
+{{#vendorExtensions
+}}{{#internal.ze-ph.fromContainer}}{{>model_container}}{{/internal.ze-ph.fromContainer
+}}{{^internal.ze-ph.fromContainer}}{{>model_object}}{{/internal.ze-ph.fromContainer
+}}{{/vendorExtensions
+}}{{^vendorExtensions}}{{>model_object}}{{/vendorExtensions
+}}{{/model}}{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_container.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_container.mustache
new file mode 100644
index 00000000000..bbecf5ed190
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_container.mustache
@@ -0,0 +1,59 @@
+/**
+{{#vars
+}}{{#isArray
+}} * @DTA\Strategy(name="{{#isPrimitiveType}}ScalarList{{/isPrimitiveType}}{{^isPrimitiveType}}ObjectList{{/isPrimitiveType}}", options={"type":{{>list_item_type}}})
+{{#minItems}}{{^maxItems
+}} * @DTA\Validator(name="Count", options={"min":{{minItems}}}, blocker=true)
+{{/maxItems}}{{/minItems
+}}{{^minItems}}{{#maxItems
+}} * @DTA\Validator(name="Count", options={"max":{{maxItems}}}, blocker=true)
+{{/maxItems}}{{/minItems
+}}{{#minItems}}{{#maxItems
+}} * @DTA\Validator(name="Count", options={"min":{{minItems}},"max":{{maxItems}}}, blocker=true)
+{{/maxItems}}{{/minItems
+}} * @DTA\Validator(name="Collection", options={"validators":{
+{{#isPrimitiveType
+}} * {"name":"Scalar", "options":{"type":{{>list_item_type}}}}
+{{/isPrimitiveType
+}}{{#isDate
+}} * {"name":"Date"}
+{{/isDate
+}}{{#isDateTime
+}} * {"name":"Date", "options":{"format": \DateTime::RFC3339}}
+{{/isDateTime
+}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime
+}} * {"name":"TypeCompliant", "options":{"type":{{>list_item_type}}}}
+{{/isDateTime}}{{/isDate}}{{/isPrimitiveType
+}} * }})
+{{/isArray
+}}{{#isMap
+}} * @DTA\Strategy(name="{{#isPrimitiveType}}ScalarMap{{/isPrimitiveType}}{{^isPrimitiveType}}ObjectMap{{/isPrimitiveType}}", options={"type":{{>map_item_type}}})
+{{#minProperties}}{{^maxProperties
+}} * @DTA\Validator(name="Count", options={"min":{{minProperties}}}, blocker=true)
+{{/maxProperties}}{{/minProperties
+}}{{^minProperties}}{{#maxProperties
+}} * @DTA\Validator(name="Count", options={"max":{{maxProperties}}}, blocker=true)
+{{/maxProperties}}{{/minProperties
+}}{{#minProperties}}{{#maxProperties
+}} * @DTA\Validator(name="Count", options={"min":{{minProperties}},"max":{{maxProperties}}}, blocker=true)
+{{/maxProperties}}{{/minProperties
+}} * @DTA\Validator(name="Collection", options={"validators":{
+{{#isPrimitiveType
+}} * {"name":"Scalar", "options":{"type":{{>map_item_type}}}}
+{{/isPrimitiveType
+}}{{#isDate
+}} * {"name":"Date"}
+{{/isDate
+}}{{#isDateTime
+}} * {"name":"Date", "options":{"format": \DateTime::RFC3339}}
+{{/isDateTime
+}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime
+}} * {"name":"TypeCompliant", "options":{"type":{{>map_item_type}}}}
+{{/isDateTime}}{{/isDate}}{{/isPrimitiveType
+}} * }})
+{{/isMap
+}}{{/vars
+}} */
+class {{classname}} extends \ArrayObject
+{
+}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_normal_var.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_normal_var.mustache
index 33c6e46337a..fe568901f9b 100644
--- a/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_normal_var.mustache
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_normal_var.mustache
@@ -1,64 +1,45 @@
-{{^isPrimitiveType}}
-{{^isContainer}}
-{{^isDate}}
-{{^isDateTime}}
- * @DTA\Strategy(name="Object", options={"type":{{dataType}}::class})
- * @DTA\Validator(name="TypeCompliant", options={"type":{{dataType}}::class})
-{{/isDateTime}}
-{{/isDate}}
-{{#isDate}}
- * @DTA\Strategy(name="Date")
+{{#isContainer
+}} * @DTA\Strategy(name="Object", options={"type":{{internal.ze-ph.containerDataType}}::class})
+ * @DTA\Validator(name="TypeCompliant", options={"type":{{internal.ze-ph.containerDataType}}::class})
+{{/isContainer
+}}{{^isContainer
+}}{{#isPrimitiveType
+}} * @DTA\Validator(name="Scalar", options={"type":"{{dataType}}"})
+{{/isPrimitiveType
+}}{{#isDate
+}} * @DTA\Strategy(name="Date")
* @DTA\Validator(name="Date")
-{{/isDate}}
-{{#isDateTime}}
- * @DTA\Strategy(name="DateTime")
+{{/isDate
+}}{{#isDateTime
+}} * @DTA\Strategy(name="DateTime")
* @DTA\Validator(name="Date", options={"format": \DateTime::RFC3339})
-{{/isDateTime}}
-{{/isContainer}}
-{{#isContainer}}
- * 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":"TypeCompliant", "options":{"type":{{#items}}{{dataType}}{{/items}}::class}}
- * }})
-{{/isContainer}}
-{{/isPrimitiveType}}
-{{#isPrimitiveType}}
-{{#isContainer}}
-{{#items}}
- * TODO check validator and strategy are correct and can handle container item type
- * @DTA\Validator(name="Collection", options={"validators":{
- * {"name":"Scalar", "options":{"type":"{{dataType}}"}}
- * }})
-{{/items}}
-{{/isContainer}}
-{{^isContainer}}
- * @DTA\Validator(name="Scalar", options={"type":"{{dataType}}"})
-{{/isContainer}}
-{{/isPrimitiveType}}
-{{#hasValidation}}
-{{#minLength}}
-{{#maxLength}}
- * @DTA\Validator(name="StringLength", options={"min":{{minLength}}, "max":{{maxLength}}})
-{{/maxLength}}
-{{/minLength}}
-{{^minLength}}
-{{#maxLength}}
- * @DTA\Validator(name="StringLength", options={"max":{{maxLength}}})
-{{/maxLength}}
-{{/minLength}}
-{{#minLength}}
-{{^maxLength}}
- * @DTA\Validator(name="StringLength", options={"min":{{minLength}}})
-{{/maxLength}}
-{{/minLength}}
-{{#minimum}}
- * @DTA\Validator(name="GreaterThan", options={"min":{{minimum}}{{^exclusiveMinimum}}, "inclusive":true{{/exclusiveMinimum}}})
-{{/minimum}}
-{{#maximum}}
- * @DTA\Validator(name="LessThan", options={"max":{{maximum}}{{^exclusiveMaximum}}, "inclusive":true{{/exclusiveMaximum}}})
-{{/maximum}}
-{{#pattern}}
- * @DTA\Validator(name="Regex", options={"pattern":"{{{pattern}}}"})
-{{/pattern}}
-{{/hasValidation}}
\ No newline at end of file
+{{/isDateTime
+}}{{^isPrimitiveType
+}}{{^isDate
+}}{{^isDateTime
+}} * @DTA\Strategy(name="Object", options={"type":{{dataType}}::class})
+ * @DTA\Validator(name="TypeCompliant", options={"type":{{dataType}}::class})
+{{/isDateTime
+}}{{/isDate
+}}{{/isPrimitiveType
+}}{{/isContainer
+}}{{#hasValidation
+}}{{#minLength}}{{#maxLength
+}} * @DTA\Validator(name="StringLength", options={"min":{{minLength}}, "max":{{maxLength}}})
+{{/maxLength}}{{/minLength
+}}{{^minLength}}{{#maxLength
+}} * @DTA\Validator(name="StringLength", options={"max":{{maxLength}}})
+{{/maxLength}}{{/minLength
+}}{{#minLength}}{{^maxLength
+}} * @DTA\Validator(name="StringLength", options={"min":{{minLength}}})
+{{/maxLength}}{{/minLength
+}}{{#minimum
+}} * @DTA\Validator(name="GreaterThan", options={"min":{{minimum}}{{^exclusiveMinimum}}, "inclusive":true{{/exclusiveMinimum}}})
+{{/minimum
+}}{{#maximum
+}} * @DTA\Validator(name="LessThan", options={"max":{{maximum}}{{^exclusiveMaximum}}, "inclusive":true{{/exclusiveMaximum}}})
+{{/maximum
+}}{{#pattern
+}} * @DTA\Validator(name="Regex", options={"pattern":"{{{pattern}}}"})
+{{/pattern
+}}{{/hasValidation}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_object.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_object.mustache
new file mode 100644
index 00000000000..2e7d61fde45
--- /dev/null
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_object.mustache
@@ -0,0 +1,24 @@
+/**
+{{#description
+}} * {{description}}
+{{/description
+}} */
+class {{classname}}
+{
+{{#vars
+}} /**
+{{#description
+}} * {{description}}
+{{/description
+}} * @DTA\Data(field="{{baseName}}"{{^required}}, nullable=true{{/required}})
+{{#vendorExtensions
+}}{{#internal.ze-ph.fromQuery}}{{>model_query_var}}{{/internal.ze-ph.fromQuery
+}}{{^internal.ze-ph.fromQuery}}{{>model_normal_var}}{{/internal.ze-ph.fromQuery
+}}{{/vendorExtensions
+}}{{^vendorExtensions}}{{>model_normal_var}}{{/vendorExtensions
+}} * @var {{dataType}}|null
+ */
+ public ${{name}};
+
+{{/vars
+}}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_query_var.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_query_var.mustache
index 27f0a72c955..deaf0e37049 100644
--- a/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_query_var.mustache
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/model_query_var.mustache
@@ -1,52 +1,51 @@
-{{^isPrimitiveType}}
-{{^isContainer}}
-{{#isDate}}
- * @DTA\Strategy(name="Date")
- * @DTA\Validator(name="Date")
-{{/isDate}}
-{{#isDateTime}}
- * @DTA\Strategy(name="DateTime")
- * @DTA\Validator(name="Date", options={"format": \DateTime::RFC3339})
-{{/isDateTime}}
-{{/isContainer}}
-{{#isContainer}}
- * TODO add validator(s) and strategy for {{dataType}} and collection format {{internal.ze-ph.collectionFormat}}
-{{/isContainer}}
-{{/isPrimitiveType}}
-{{#isPrimitiveType}}
-{{#isContainer}}
- * TODO check validator and strategy are correct and can handle container item type
- * @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="QueryStringScalar", options={"type":"{{dataType}}"})
+{{#isArray
+}}{{#isPrimitiveType
+}} * @DTA\Strategy(name="QueryStringScalarArray", options={"type":{{>list_item_type}}, "format":"{{internal.ze-ph.collectionFormat}}"})
+ * @DTA\Validator(name="QueryStringScalarArray", options={"type":{{>list_item_type}}, "format":"{{internal.ze-ph.collectionFormat}}"{{#minItems}}, "min_items":{{minItems}}{{/minItems}}{{#maxItems}}, "max_items":{{maxItems}}{{/maxItems}}})
+{{/isPrimitiveType
+}}{{^isPrimitiveType
+}} * TODO add validator(s) and strategy for list of {{>list_item_type}} and collection format {{internal.ze-ph.collectionFormat}} inside query string
+{{/isPrimitiveType
+}}{{/isArray
+}}{{#isMap
+}} * TODO add validator(s) and strategy for map of {{>map_item_type}} and collection format {{internal.ze-ph.collectionFormat}} inside query string
+{{/isMap
+}}{{^isContainer
+}}{{#isPrimitiveType
+}} * @DTA\Strategy(name="QueryStringScalar", options={"type":"{{dataType}}"})
* @DTA\Validator(name="QueryStringScalar", options={"type":"{{dataType}}"})
-{{/isContainer}}
-{{/isPrimitiveType}}
-{{#hasValidation}}
-{{#minLength}}
-{{#maxLength}}
- * @DTA\Validator(name="StringLength", options={"min":{{minLength}}, "max":{{maxLength}}})
-{{/maxLength}}
-{{/minLength}}
-{{^minLength}}
-{{#maxLength}}
- * @DTA\Validator(name="StringLength", options={"max":{{maxLength}}})
-{{/maxLength}}
-{{/minLength}}
-{{#minLength}}
-{{^maxLength}}
- * @DTA\Validator(name="StringLength", options={"min":{{minLength}}})
-{{/maxLength}}
-{{/minLength}}
-{{#minimum}}
- * @DTA\Validator(name="GreaterThan", options={"min":{{minimum}}{{^exclusiveMinimum}}, "inclusive":true{{/exclusiveMinimum}}})
-{{/minimum}}
-{{#maximum}}
- * @DTA\Validator(name="LessThan", options={"max":{{maximum}}{{^exclusiveMaximum}}, "inclusive":true{{/exclusiveMaximum}}})
-{{/maximum}}
-{{#pattern}}
- * @DTA\Validator(name="Regex", options={"pattern":"{{{pattern}}}"})
-{{/pattern}}
-{{/hasValidation}}
\ No newline at end of file
+{{/isPrimitiveType
+}}{{#isDate
+}} * @DTA\Strategy(name="Date")
+ * @DTA\Validator(name="Date")
+{{/isDate
+}}{{#isDateTime
+}} * @DTA\Strategy(name="DateTime")
+ * @DTA\Validator(name="Date", options={"format": \DateTime::RFC3339})
+{{/isDateTime
+}}{{^isPrimitiveType
+}}{{^isDate}}{{^isDateTime
+}} * TODO add validator(s) and strategy for {{dataType}} inside query string
+{{/isDateTime}}{{/isDate
+}}{{/isPrimitiveType
+}}{{/isContainer
+}}{{#hasValidation
+}}{{#minLength}}{{#maxLength
+}} * @DTA\Validator(name="StringLength", options={"min":{{minLength}}, "max":{{maxLength}}})
+{{/maxLength}}{{/minLength
+}}{{^minLength}}{{#maxLength
+}} * @DTA\Validator(name="StringLength", options={"max":{{maxLength}}})
+{{/maxLength}}{{/minLength
+}}{{#minLength}}{{^maxLength
+}} * @DTA\Validator(name="StringLength", options={"min":{{minLength}}})
+{{/maxLength}}{{/minLength
+}}{{#minimum
+}} * @DTA\Validator(name="GreaterThan", options={"min":{{minimum}}{{^exclusiveMinimum}}, "inclusive":true{{/exclusiveMinimum}}})
+{{/minimum
+}}{{#maximum
+}} * @DTA\Validator(name="LessThan", options={"max":{{maximum}}{{^exclusiveMaximum}}, "inclusive":true{{/exclusiveMaximum}}})
+{{/maximum
+}}{{#pattern
+}} * @DTA\Validator(name="Regex", options={"pattern":"{{{pattern}}}"})
+{{/pattern
+}}{{/hasValidation}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/php-mezzio-ph/path_handler.yml.mustache b/modules/openapi-generator/src/main/resources/php-mezzio-ph/path_handler.yml.mustache
index dd01611f359..1f9167a0fa4 100644
--- a/modules/openapi-generator/src/main/resources/php-mezzio-ph/path_handler.yml.mustache
+++ b/modules/openapi-generator/src/main/resources/php-mezzio-ph/path_handler.yml.mustache
@@ -1,8 +1,13 @@
dependencies:
factories:
- Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory
+ Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjectionFactory
+ Articus\PathHandler\MetadataProviderInterface: Articus\PathHandler\MetadataProvider\Factory\Annotation
+ Articus\PathHandler\Handler\PluginManager: Articus\PathHandler\Handler\Factory\PluginManager
+ Articus\PathHandler\Consumer\PluginManager: Articus\PathHandler\Consumer\Factory\PluginManager
+ Articus\PathHandler\Attribute\PluginManager: Articus\PathHandler\Attribute\Factory\PluginManager
+ Articus\PathHandler\Producer\PluginManager: Articus\PathHandler\Producer\Factory\PluginManager
-Articus\PathHandler\RouteInjection\Factory:
+Articus\PathHandler\RouteInjectionFactory:
paths:
'{{basePathWithoutHost}}':
{{#apiInfo}}
@@ -12,18 +17,22 @@ Articus\PathHandler\RouteInjection\Factory:
{{/operations}}
{{/apis}}
{{/apiInfo}}
- handlers:
- abstract_factories:
- - Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory
-# consumers:
-# factories:
-# invokables:
-# attributes:
-# factories:
-# invokables:
-# producers:
-# factories:
-# invokables:
+
+Articus\PathHandler\Handler\PluginManager:
+ abstract_factories:
+ - Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory
+
+#Articus\PathHandler\Consumer\PluginManager:
+# factories:
+# invokables:
+
+#Articus\PathHandler\Attribute\PluginManager:
+# factories:
+# invokables:
+
+#Articus\PathHandler\Producer\PluginManager:
+# factories:
+# invokables:
Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory:
{{#apiInfo}}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/FILES b/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/FILES
deleted file mode 100644
index fd268242a0e..00000000000
--- a/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/FILES
+++ /dev/null
@@ -1,36 +0,0 @@
-.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/InlineObject.php
-src/App/DTO/InlineObject1.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/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/VERSION b/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/VERSION
deleted file mode 100644
index d99e7162d01..00000000000
--- a/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-5.0.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/composer.json b/samples/openapi3/server/petstore/php-mezzio-ph/composer.json
deleted file mode 100644
index 54f8e97226c..00000000000
--- a/samples/openapi3/server/petstore/php-mezzio-ph/composer.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "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/src/App/DTO/ApiResponse.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php
deleted file mode 100644
index a08cb2c9275..00000000000
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php
+++ /dev/null
@@ -1,31 +0,0 @@
-getAttribute("bodyData");
- throw new PHException\HttpCode(501, "Not implemented");
- }
- /**
- * 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, 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, 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")
- * 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/json")
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
- *
- * @return \App\DTO\Pet
- */
- public function updatePet(ServerRequestInterface $request): \App\DTO\Pet
- {
- //TODO implement method
- /** @var \App\DTO\Pet $bodyData */
- $bodyData = $request->getAttribute("bodyData");
- throw new PHException\HttpCode(501, "Not implemented");
- }
-}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php
deleted file mode 100644
index c1c1ce75400..00000000000
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php
+++ /dev/null
@@ -1,44 +0,0 @@
-getAttribute("queryData");
- throw new PHException\HttpCode(501, "Not implemented");
- }
-}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php
deleted file mode 100644
index b722a310efb..00000000000
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php
+++ /dev/null
@@ -1,44 +0,0 @@
-getAttribute("queryData");
- throw new PHException\HttpCode(501, "Not implemented");
- }
-}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrder.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrder.php
deleted file mode 100644
index be6af69243a..00000000000
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrder.php
+++ /dev/null
@@ -1,41 +0,0 @@
-getAttribute("bodyData");
- throw new PHException\HttpCode(501, "Not implemented");
- }
-}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogin.php b/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogin.php
deleted file mode 100644
index 577e7c3f562..00000000000
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogin.php
+++ /dev/null
@@ -1,43 +0,0 @@
-getAttribute("queryData");
- throw new PHException\HttpCode(501, "Not implemented");
- }
-}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/.gitignore b/samples/server/petstore/php-mezzio-ph-modern/.gitignore
new file mode 100644
index 00000000000..1ddcdf2a709
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/.gitignore
@@ -0,0 +1,9 @@
+#based on .gitignore generated by https://github.com/zendframework/zend-expressive-skeleton
+.idea
+
+# Composer files
+composer.phar
+vendor/
+
+# Default cache folder
+data/cache/
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator-ignore b/samples/server/petstore/php-mezzio-ph-modern/.openapi-generator-ignore
similarity index 100%
rename from samples/openapi3/server/petstore/php-mezzio-ph/.openapi-generator-ignore
rename to samples/server/petstore/php-mezzio-ph-modern/.openapi-generator-ignore
diff --git a/samples/server/petstore/php-mezzio-ph-modern/.openapi-generator/FILES b/samples/server/petstore/php-mezzio-ph-modern/.openapi-generator/FILES
new file mode 100644
index 00000000000..bc9a68917b6
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/.openapi-generator/FILES
@@ -0,0 +1,71 @@
+.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/Collection.php
+src/App/DTO/Collection1.php
+src/App/DTO/Collection10.php
+src/App/DTO/Collection11.php
+src/App/DTO/Collection12.php
+src/App/DTO/Collection13.php
+src/App/DTO/Collection14.php
+src/App/DTO/Collection15.php
+src/App/DTO/Collection16.php
+src/App/DTO/Collection17.php
+src/App/DTO/Collection18.php
+src/App/DTO/Collection19.php
+src/App/DTO/Collection2.php
+src/App/DTO/Collection20.php
+src/App/DTO/Collection21.php
+src/App/DTO/Collection22.php
+src/App/DTO/Collection23.php
+src/App/DTO/Collection24.php
+src/App/DTO/Collection25.php
+src/App/DTO/Collection26.php
+src/App/DTO/Collection27.php
+src/App/DTO/Collection28.php
+src/App/DTO/Collection29.php
+src/App/DTO/Collection3.php
+src/App/DTO/Collection30.php
+src/App/DTO/Collection31.php
+src/App/DTO/Collection32.php
+src/App/DTO/Collection33.php
+src/App/DTO/Collection34.php
+src/App/DTO/Collection35.php
+src/App/DTO/Collection36.php
+src/App/DTO/Collection4.php
+src/App/DTO/Collection5.php
+src/App/DTO/Collection6.php
+src/App/DTO/Collection7.php
+src/App/DTO/Collection8.php
+src/App/DTO/Collection9.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-modern/.openapi-generator/VERSION b/samples/server/petstore/php-mezzio-ph-modern/.openapi-generator/VERSION
new file mode 100644
index 00000000000..6555596f931
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/.openapi-generator/VERSION
@@ -0,0 +1 @@
+5.2.0-SNAPSHOT
\ No newline at end of file
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/README.md b/samples/server/petstore/php-mezzio-ph-modern/README.md
similarity index 93%
rename from samples/openapi3/server/petstore/php-mezzio-ph/README.md
rename to samples/server/petstore/php-mezzio-ph-modern/README.md
index 584fd156879..fd66369b261 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/README.md
+++ b/samples/server/petstore/php-mezzio-ph-modern/README.md
@@ -5,9 +5,9 @@ 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.2
-- [Laminas Mezzio](https://docs.mezzio.dev/mezzio/): >=3.2
-- [Path Handler](https://github.com/Articus/PathHandler): >=0.6
+- PHP: >=8.0
+- [Laminas Mezzio](https://docs.mezzio.dev/mezzio/): >=3.3
+- [Path Handler](https://github.com/Articus/PathHandler): >=0.7
## How to use
All you have to do to start development is:
diff --git a/samples/server/petstore/php-mezzio-ph-modern/application/config.yml b/samples/server/petstore/php-mezzio-ph-modern/application/config.yml
new file mode 100644
index 00000000000..58056552c5b
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/application/config.yml
@@ -0,0 +1,21 @@
+#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
+#Articus\PathHandler\MetadataProvider\PhpAttribute:
+# cache:
+# directory: ./data/cache/PathHandler
+
+#Enable data transfer metadata cache for DTOs
+#Articus\DataTransfer\MetadataProvider\PhpAttribute:
+# cache:
+# directory: ./data/cache/DataTransfer
diff --git a/samples/server/petstore/php-mezzio-ph-modern/application/config/app.yml b/samples/server/petstore/php-mezzio-ph-modern/application/config/app.yml
new file mode 100644
index 00000000000..0ffd5e8864c
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/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/server/petstore/php-mezzio-ph-modern/application/config/data_transfer.yml
similarity index 69%
rename from samples/openapi3/server/petstore/php-mezzio-ph/application/config/data_transfer.yml
rename to samples/server/petstore/php-mezzio-ph-modern/application/config/data_transfer.yml
index c5174147c23..7bdd139bb9f 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/application/config/data_transfer.yml
+++ b/samples/server/petstore/php-mezzio-ph-modern/application/config/data_transfer.yml
@@ -1,13 +1,13 @@
dependencies:
factories:
Articus\DataTransfer\Service: Articus\DataTransfer\Factory
- Articus\DataTransfer\MetadataProvider\Annotation: Articus\DataTransfer\MetadataProvider\Factory\Annotation
+ Articus\DataTransfer\MetadataProvider\PhpAttribute: Articus\DataTransfer\MetadataProvider\Factory\PhpAttribute
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\ClassMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\PhpAttribute
+ Articus\DataTransfer\FieldMetadataProviderInterface: Articus\DataTransfer\MetadataProvider\PhpAttribute
Articus\DataTransfer\Strategy\PluginManager:
invokables:
@@ -16,6 +16,10 @@ Articus\DataTransfer\Strategy\PluginManager:
factories:
Date: OpenAPIGenerator\Common\Strategy\Factory\MutableDate
DateTime: OpenAPIGenerator\Common\Strategy\Factory\MutableDateTime
+ ObjectList: OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectList
+ ObjectMap: OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectMap
+ ScalarList: OpenAPIGenerator\Common\Strategy\Factory\ScalarList
+ ScalarMap: OpenAPIGenerator\Common\Strategy\Factory\ScalarMap
Articus\DataTransfer\Validator\PluginManager:
invokables:
@@ -24,3 +28,7 @@ Articus\DataTransfer\Validator\PluginManager:
QueryStringScalarArray: OpenAPIGenerator\Common\Validator\QueryStringScalarArray
abstract_factories:
- Articus\DataTransfer\Validator\Factory\Laminas
+
+validators:
+ invokables:
+ Count: Laminas\Validator\IsCountable
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/application/config/path_handler.yml b/samples/server/petstore/php-mezzio-ph-modern/application/config/path_handler.yml
similarity index 53%
rename from samples/openapi3/server/petstore/php-mezzio-ph/application/config/path_handler.yml
rename to samples/server/petstore/php-mezzio-ph-modern/application/config/path_handler.yml
index 25995b20d6f..eb46b1891a3 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/application/config/path_handler.yml
+++ b/samples/server/petstore/php-mezzio-ph-modern/application/config/path_handler.yml
@@ -1,8 +1,13 @@
dependencies:
factories:
- Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory
+ Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjectionFactory
+ Articus\PathHandler\MetadataProviderInterface: Articus\PathHandler\MetadataProvider\Factory\PhpAttribute
+ Articus\PathHandler\Handler\PluginManager: Articus\PathHandler\Handler\Factory\PluginManager
+ Articus\PathHandler\Consumer\PluginManager: Articus\PathHandler\Consumer\Factory\PluginManager
+ Articus\PathHandler\Attribute\PluginManager: Articus\PathHandler\Attribute\Factory\PluginManager
+ Articus\PathHandler\Producer\PluginManager: Articus\PathHandler\Producer\Factory\PluginManager
-Articus\PathHandler\RouteInjection\Factory:
+Articus\PathHandler\RouteInjectionFactory:
paths:
'/v2':
- App\Handler\Pet
@@ -19,18 +24,22 @@ Articus\PathHandler\RouteInjection\Factory:
- 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:
+
+Articus\PathHandler\Handler\PluginManager:
+ abstract_factories:
+ - Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory
+
+#Articus\PathHandler\Consumer\PluginManager:
+# factories:
+# invokables:
+
+#Articus\PathHandler\Attribute\PluginManager:
+# factories:
+# invokables:
+
+#Articus\PathHandler\Producer\PluginManager:
+# factories:
+# invokables:
Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory:
App\Handler\Pet: []
diff --git a/samples/server/petstore/php-mezzio-ph-modern/application/container.php b/samples/server/petstore/php-mezzio-ph-modern/application/container.php
new file mode 100644
index 00000000000..9c54fafcfec
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/application/container.php
@@ -0,0 +1,43 @@
+setService('config', $config);
+$container->setAlias('Config', 'config');
+
+return $container;
diff --git a/samples/server/petstore/php-mezzio-ph-modern/composer.json b/samples/server/petstore/php-mezzio-ph-modern/composer.json
new file mode 100644
index 00000000000..7f03f079e4a
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/composer.json
@@ -0,0 +1,26 @@
+{
+ "name": "git_user_id/git_repo_id",
+ "description": "",
+ "license": "unlicense",
+ "version": "1.0.0",
+ "type": "project",
+ "require": {
+ "php": "^8.0",
+ "ext-yaml": "^2.2",
+ "mezzio/mezzio": "^3.3",
+ "laminas/laminas-diactoros": "^2.5",
+ "articus/path-handler": "^0.7",
+ "articus/data-transfer": "^0.5",
+ "articus/openapi-generator-common": "^0.2",
+ "psr/simple-cache": "^1.0",
+ "laminas/laminas-config": "^3.4",
+ "laminas/laminas-stdlib": "^3.3",
+ "laminas/laminas-validator": "^2.14",
+ "nikic/fast-route": "^1.3"
+ },
+ "autoload": {
+ "psr-4": {
+ "": "src/"
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/server/petstore/php-mezzio-ph-modern/public/index.php b/samples/server/petstore/php-mezzio-ph-modern/public/index.php
new file mode 100644
index 00000000000..7c3de73df16
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/public/index.php
@@ -0,0 +1,11 @@
+get(\Mezzio\Application::class);
+$app->run();
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/ApiResponse.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/ApiResponse.php
new file mode 100644
index 00000000000..bfe65906ea5
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/ApiResponse.php
@@ -0,0 +1,25 @@
+ "int"])]
+ public int|null $code = null;
+
+ #[DTA\Data(field: "type", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $type = null;
+
+ #[DTA\Data(field: "message", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $message = null;
+
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Category.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Category.php
new file mode 100644
index 00000000000..e6b28c29028
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Category.php
@@ -0,0 +1,22 @@
+ "int"])]
+ public int|null $id = null;
+
+ #[DTA\Data(field: "name", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ #[DTA\Validator("Regex", ["pattern" => "/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"])]
+ public string|null $name = null;
+
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection.php
new file mode 100644
index 00000000000..f0e14da6cd8
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection1.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection1.php
new file mode 100644
index 00000000000..c05da2858bd
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection1.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection1 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection10.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection10.php
new file mode 100644
index 00000000000..29e6ccdb347
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection10.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection10 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection11.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection11.php
new file mode 100644
index 00000000000..89b2d0d01f8
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection11.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection11 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection12.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection12.php
new file mode 100644
index 00000000000..e0657b0d467
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection12.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection12 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection13.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection13.php
new file mode 100644
index 00000000000..26f88d9685d
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection13.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection13 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection14.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection14.php
new file mode 100644
index 00000000000..d1e0e11495b
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection14.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection14 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection15.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection15.php
new file mode 100644
index 00000000000..085f17e1e97
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection15.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection15 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection16.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection16.php
new file mode 100644
index 00000000000..1b1523c7d09
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection16.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection16 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection17.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection17.php
new file mode 100644
index 00000000000..eb5b0e828f8
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection17.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection17 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection18.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection18.php
new file mode 100644
index 00000000000..dd55bd5840a
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection18.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection18 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection19.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection19.php
new file mode 100644
index 00000000000..45da36c7301
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection19.php
@@ -0,0 +1,14 @@
+ \App\DTO\Pet::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Pet::class]]
+]])]
+class Collection19 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection2.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection2.php
new file mode 100644
index 00000000000..26176dcc5e5
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection2.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection2 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection20.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection20.php
new file mode 100644
index 00000000000..26b16ef104e
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection20.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection20 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection21.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection21.php
new file mode 100644
index 00000000000..9e0c2429bde
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection21.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection21 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection22.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection22.php
new file mode 100644
index 00000000000..6f7a04ff4bd
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection22.php
@@ -0,0 +1,14 @@
+ \App\DTO\Pet::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Pet::class]]
+]])]
+class Collection22 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection23.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection23.php
new file mode 100644
index 00000000000..608c9ad5020
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection23.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection23 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection24.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection24.php
new file mode 100644
index 00000000000..b876816c2dd
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection24.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection24 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection25.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection25.php
new file mode 100644
index 00000000000..ad3a8102ad3
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection25.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection25 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection26.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection26.php
new file mode 100644
index 00000000000..f8e958fcb40
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection26.php
@@ -0,0 +1,14 @@
+ \App\DTO\Pet::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Pet::class]]
+]])]
+class Collection26 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection27.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection27.php
new file mode 100644
index 00000000000..b53e9e87a72
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection27.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection27 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection28.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection28.php
new file mode 100644
index 00000000000..3b6e05419ef
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection28.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection28 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection29.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection29.php
new file mode 100644
index 00000000000..24a1ee261d8
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection29.php
@@ -0,0 +1,14 @@
+ \App\DTO\Pet::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Pet::class]]
+]])]
+class Collection29 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection3.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection3.php
new file mode 100644
index 00000000000..1833307cd7e
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection3.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection3 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection30.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection30.php
new file mode 100644
index 00000000000..916229afc92
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection30.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection30 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection31.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection31.php
new file mode 100644
index 00000000000..12b771c1c16
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection31.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection31 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection32.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection32.php
new file mode 100644
index 00000000000..e89cbcd4397
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection32.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection32 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection33.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection33.php
new file mode 100644
index 00000000000..91229b175cf
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection33.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection33 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection34.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection34.php
new file mode 100644
index 00000000000..1670c4ee7e3
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection34.php
@@ -0,0 +1,14 @@
+ "int"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "int"]]
+]])]
+class Collection34 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection35.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection35.php
new file mode 100644
index 00000000000..4b1082abc1b
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection35.php
@@ -0,0 +1,14 @@
+ \App\DTO\User::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\User::class]]
+]])]
+class Collection35 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection36.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection36.php
new file mode 100644
index 00000000000..38595c2f5d3
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection36.php
@@ -0,0 +1,14 @@
+ \App\DTO\User::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\User::class]]
+]])]
+class Collection36 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection4.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection4.php
new file mode 100644
index 00000000000..54e2f1a12de
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection4.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection4 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection5.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection5.php
new file mode 100644
index 00000000000..3f32f4513a7
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection5.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection5 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection6.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection6.php
new file mode 100644
index 00000000000..79abc43f339
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection6.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection6 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection7.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection7.php
new file mode 100644
index 00000000000..8574d82b365
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection7.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection7 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection8.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection8.php
new file mode 100644
index 00000000000..c264d8076a1
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection8.php
@@ -0,0 +1,14 @@
+ "string"])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "Scalar", "options" => ["type" => "string"]]
+]])]
+class Collection8 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection9.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection9.php
new file mode 100644
index 00000000000..99cc837d6a5
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Collection9.php
@@ -0,0 +1,14 @@
+ \App\DTO\Tag::class])]
+#[DTA\Validator("Collection", ["validators" => [
+ ["name" => "TypeCompliant", "options" => ["type" => \App\DTO\Tag::class]]
+]])]
+class Collection9 extends \ArrayObject
+{
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/FindPetsByStatusQueryData.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/FindPetsByStatusQueryData.php
new file mode 100644
index 00000000000..178b4949794
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/FindPetsByStatusQueryData.php
@@ -0,0 +1,21 @@
+ "string", "format" => "csv"])]
+ #[DTA\Validator("QueryStringScalarArray", ["type" => "string", "format" => "csv"])]
+ public array|null $status = null;
+
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/FindPetsByTagsQueryData.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/FindPetsByTagsQueryData.php
new file mode 100644
index 00000000000..cbf9e1d0c39
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/FindPetsByTagsQueryData.php
@@ -0,0 +1,21 @@
+ "string", "format" => "csv"])]
+ #[DTA\Validator("QueryStringScalarArray", ["type" => "string", "format" => "csv"])]
+ public array|null $tags = null;
+
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/LoginUserQueryData.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/LoginUserQueryData.php
new file mode 100644
index 00000000000..2c01e944c91
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/LoginUserQueryData.php
@@ -0,0 +1,30 @@
+ "string"])]
+ #[DTA\Validator("QueryStringScalar", ["type" => "string"])]
+ public string|null $password = null;
+
+ /**
+ * The user name for login
+ */
+ #[DTA\Data(field: "username")]
+ #[DTA\Strategy("QueryStringScalar", ["type" => "string"])]
+ #[DTA\Validator("QueryStringScalar", ["type" => "string"])]
+ #[DTA\Validator("Regex", ["pattern" => "/^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$/"])]
+ public string|null $username = null;
+
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Order.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Order.php
new file mode 100644
index 00000000000..8dd384b4475
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Order.php
@@ -0,0 +1,41 @@
+ "int"])]
+ public int|null $id = null;
+
+ #[DTA\Data(field: "petId", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "int"])]
+ public int|null $pet_id = null;
+
+ #[DTA\Data(field: "quantity", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "int"])]
+ public int|null $quantity = null;
+
+ #[DTA\Data(field: "shipDate", nullable: true)]
+ #[DTA\Strategy("DateTime")]
+ #[DTA\Validator("Date", ["format" => \DateTime::RFC3339])]
+ public \DateTime|null $ship_date = null;
+
+ /**
+ * Order Status
+ */
+ #[DTA\Data(field: "status", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $status = null;
+
+ #[DTA\Data(field: "complete", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "bool"])]
+ public bool|null $complete = null;
+
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Pet.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Pet.php
new file mode 100644
index 00000000000..bcd5cdb6e81
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Pet.php
@@ -0,0 +1,43 @@
+ "int"])]
+ public int|null $id = null;
+
+ #[DTA\Data(field: "category", nullable: true)]
+ #[DTA\Strategy("Object", ["type" => \App\DTO\Category::class])]
+ #[DTA\Validator("TypeCompliant", ["type" => \App\DTO\Category::class])]
+ public \App\DTO\Category|null $category = null;
+
+ #[DTA\Data(field: "name")]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $name = null;
+
+ #[DTA\Data(field: "photoUrls")]
+ #[DTA\Strategy("Object", ["type" => \App\DTO\Collection32::class])]
+ #[DTA\Validator("TypeCompliant", ["type" => \App\DTO\Collection32::class])]
+ public \App\DTO\Collection32|null $photo_urls = null;
+
+ #[DTA\Data(field: "tags", nullable: true)]
+ #[DTA\Strategy("Object", ["type" => \App\DTO\Collection33::class])]
+ #[DTA\Validator("TypeCompliant", ["type" => \App\DTO\Collection33::class])]
+ public \App\DTO\Collection33|null $tags = null;
+
+ /**
+ * pet status in the store
+ */
+ #[DTA\Data(field: "status", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $status = null;
+
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Tag.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Tag.php
new file mode 100644
index 00000000000..5fcc6c116b0
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/Tag.php
@@ -0,0 +1,21 @@
+ "int"])]
+ public int|null $id = null;
+
+ #[DTA\Data(field: "name", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $name = null;
+
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/User.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/User.php
new file mode 100644
index 00000000000..c257dfea319
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/DTO/User.php
@@ -0,0 +1,48 @@
+ "int"])]
+ public int|null $id = null;
+
+ #[DTA\Data(field: "username", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $username = null;
+
+ #[DTA\Data(field: "firstName", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $first_name = null;
+
+ #[DTA\Data(field: "lastName", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $last_name = null;
+
+ #[DTA\Data(field: "email", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $email = null;
+
+ #[DTA\Data(field: "password", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $password = null;
+
+ #[DTA\Data(field: "phone", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "string"])]
+ public string|null $phone = null;
+
+ /**
+ * User Status
+ */
+ #[DTA\Data(field: "userStatus", nullable: true)]
+ #[DTA\Validator("Scalar", ["type" => "int"])]
+ public int|null $user_status = null;
+
+}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Factory.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Factory.php
similarity index 71%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Factory.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Factory.php
index 0757bcfbea7..24eb21b492c 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Factory.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Factory.php
@@ -23,23 +23,13 @@ class Factory implements FactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null): Application
{
- $errorMiddleware = $container->get(Middleware\InternalServerError::class);
- if (!($errorMiddleware instanceof Middleware\InternalServerError)) {
- throw new \LogicException(\sprintf(
- 'Invalid error middleware: expecting %s, not %s.',
- Middleware\InternalServerError::class,
- \is_object($errorMiddleware) ? \get_class($errorMiddleware) : \gettype($errorMiddleware)
- ));
- }
+ $errorMiddleware = self::getErrorMiddleware($container);
$pipeline = new MiddlewarePipe();
$runner = new RequestHandlerRunner(
$pipeline,
$container->get(EmitterInterface::class),
$container->get(ServerRequestInterface::class),
- function(\Throwable $error) use ($errorMiddleware) : ResponseInterface
- {
- return $errorMiddleware->handleError($error);
- }
+ static fn(\Throwable $error): ResponseInterface => $errorMiddleware->handleError($error)
);
$application = new Application(
$container->get(MiddlewareFactory::class),
@@ -55,4 +45,9 @@ class Factory implements FactoryInterface
return $application;
}
+
+ protected static function getErrorMiddleware(ContainerInterface $container): Middleware\InternalServerError
+ {
+ return $container->get(Middleware\InternalServerError::class);
+ }
}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/Pet.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/Pet.php
new file mode 100644
index 00000000000..625b36f693a
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/Pet.php
@@ -0,0 +1,56 @@
+ \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("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
+ public function addPet(ServerRequestInterface $request): \App\DTO\Pet
+ {
+ //TODO implement method
+ /** @var \App\DTO\Pet $bodyData */
+ $bodyData = $request->getAttribute("bodyData");
+ throw new PHException\HttpCode(501, "Not implemented");
+ }
+ /**
+ * 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("application/json", PHConsumer\Json::class)]
+ // TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Consumer("application/xml", PHConsumer\Json::class)]
+ #[PHA\Attribute(PHAttribute\Transfer::class, ["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("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
+ public function updatePet(ServerRequestInterface $request): \App\DTO\Pet
+ {
+ //TODO implement method
+ /** @var \App\DTO\Pet $bodyData */
+ $bodyData = $request->getAttribute("bodyData");
+ throw new PHException\HttpCode(501, "Not implemented");
+ }
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetFindByStatus.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetFindByStatus.php
new file mode 100644
index 00000000000..53d217f9969
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetFindByStatus.php
@@ -0,0 +1,36 @@
+ \App\DTO\FindPetsByStatusQueryData::class,
+ "objectAttr" => "queryData",
+ "source" => PHAttribute\Transfer::SOURCE_GET
+ ])]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
+ public function findPetsByStatus(ServerRequestInterface $request): \App\DTO\Collection19
+ {
+ //TODO implement method
+ /** @var \App\DTO\FindPetsByStatusQueryData $queryData */
+ $queryData = $request->getAttribute("queryData");
+ throw new PHException\HttpCode(501, "Not implemented");
+ }
+}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetFindByTags.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetFindByTags.php
new file mode 100644
index 00000000000..a40122909bc
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetFindByTags.php
@@ -0,0 +1,36 @@
+ \App\DTO\FindPetsByTagsQueryData::class,
+ "objectAttr" => "queryData",
+ "source" => PHAttribute\Transfer::SOURCE_GET
+ ])]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
+ public function findPetsByTags(ServerRequestInterface $request): \App\DTO\Collection26
+ {
+ //TODO implement method
+ /** @var \App\DTO\FindPetsByTagsQueryData $queryData */
+ $queryData = $request->getAttribute("queryData");
+ throw new PHException\HttpCode(501, "Not implemented");
+ }
+}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetId.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetPetId.php
similarity index 55%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetId.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetPetId.php
index 625bbf5832c..8da421be678 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetId.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetPetId.php
@@ -3,25 +3,20 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/pet/{petId}")
- */
+#[PHA\Route("/pet/{petId}")]
class PetPetId
{
/**
* Deletes a pet
- * @PHA\Delete()
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Delete()]
public function deletePet(ServerRequestInterface $request)
{
//TODO implement method
@@ -29,17 +24,12 @@ class PetPetId
}
/**
* Find pet by ID
- * @PHA\Get()
- * 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")
- * 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/json")
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
- *
- * @return \App\DTO\Pet
*/
+ #[PHA\Get()]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
public function getPetById(ServerRequestInterface $request): \App\DTO\Pet
{
//TODO implement method
@@ -47,11 +37,8 @@ class PetPetId
}
/**
* Updates a pet in the store with form data
- * @PHA\Post()
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Post()]
public function updatePetWithForm(ServerRequestInterface $request)
{
//TODO implement method
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetIdUploadImage.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetPetIdUploadImage.php
similarity index 58%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetIdUploadImage.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetPetIdUploadImage.php
index 67cc0784caa..886a35c1e32 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/PetPetIdUploadImage.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/PetPetIdUploadImage.php
@@ -3,29 +3,22 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/pet/{petId}/uploadImage")
- */
+#[PHA\Route("/pet/{petId}/uploadImage")]
class PetPetIdUploadImage
{
/**
* uploads an image
- * @PHA\Post()
- * 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/json")
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
- *
- * @return \App\DTO\ApiResponse
*/
+ #[PHA\Post()]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
public function uploadFile(ServerRequestInterface $request): \App\DTO\ApiResponse
{
//TODO implement method
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreInventory.php
similarity index 54%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreInventory.php
index 6d6d3ceb946..bc35720421c 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreInventory.php
@@ -3,31 +3,23 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/store/inventory")
- */
+#[PHA\Route("/store/inventory")]
class StoreInventory
{
/**
* Returns pet inventories by status
- * @PHA\Get()
- * 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/json")
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
- *
- * TODO check if generated return container type is valid
- * @return map[string,int]
*/
- public function getInventory(ServerRequestInterface $request): array
+ #[PHA\Get()]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
+ public function getInventory(ServerRequestInterface $request): \App\DTO\Collection34
{
//TODO implement method
throw new PHException\HttpCode(501, "Not implemented");
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreOrder.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreOrder.php
new file mode 100644
index 00000000000..9399d0e4d3b
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreOrder.php
@@ -0,0 +1,34 @@
+ \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("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
+ public function placeOrder(ServerRequestInterface $request): \App\DTO\Order
+ {
+ //TODO implement method
+ /** @var \App\DTO\Order $bodyData */
+ $bodyData = $request->getAttribute("bodyData");
+ throw new PHException\HttpCode(501, "Not implemented");
+ }
+}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrderOrderId.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreOrderOrderId.php
similarity index 54%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrderOrderId.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreOrderOrderId.php
index 31c53e597eb..ae8313b20ea 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/StoreOrderOrderId.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/StoreOrderOrderId.php
@@ -3,25 +3,20 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/store/order/{orderId}")
- */
+#[PHA\Route("/store/order/{orderId}")]
class StoreOrderOrderId
{
/**
* Delete purchase order by ID
- * @PHA\Delete()
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Delete()]
public function deleteOrder(ServerRequestInterface $request)
{
//TODO implement method
@@ -29,17 +24,12 @@ class StoreOrderOrderId
}
/**
* Find purchase order by ID
- * @PHA\Get()
- * 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")
- * 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/json")
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
- *
- * @return \App\DTO\Order
*/
+ #[PHA\Get()]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
public function getOrderById(ServerRequestInterface $request): \App\DTO\Order
{
//TODO implement method
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/User.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/User.php
similarity index 57%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/User.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/User.php
index 5a48f2ec072..8ad9221e263 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/User.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/User.php
@@ -3,28 +3,23 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/user")
- */
+#[PHA\Route("/user")]
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, mediaRange="application/json")
- * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"})
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Post()]
+ // TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Consumer("application/json", PHConsumer\Json::class)]
+ #[PHA\Attribute(PHAttribute\Transfer::class, ["type" => \App\DTO\User::class, "objectAttr" => "bodyData"])]
public function createUser(ServerRequestInterface $request)
{
//TODO implement method
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserCreateWithArray.php
similarity index 52%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserCreateWithArray.php
index a8a39215bab..304f85782c5 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserCreateWithArray.php
@@ -3,33 +3,27 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/user/createWithArray")
- */
+#[PHA\Route("/user/createWithArray")]
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, 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
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Post()]
+ // TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Consumer("application/json", PHConsumer\Json::class)]
+ #[PHA\Attribute(PHAttribute\Transfer::class, ["type" => \App\DTO\Collection36::class, "objectAttr" => "bodyData"])]
public function createUsersWithArrayInput(ServerRequestInterface $request)
{
//TODO implement method
- /** @var \App\DTO\User[] $bodyData */
+ /** @var \App\DTO\Collection36 $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(501, "Not implemented");
}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserCreateWithList.php
similarity index 52%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserCreateWithList.php
index b34cca7045f..1d415fcee23 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserCreateWithList.php
@@ -3,33 +3,27 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/user/createWithList")
- */
+#[PHA\Route("/user/createWithList")]
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, 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
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Post()]
+ // TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Consumer("application/json", PHConsumer\Json::class)]
+ #[PHA\Attribute(PHAttribute\Transfer::class, ["type" => \App\DTO\Collection36::class, "objectAttr" => "bodyData"])]
public function createUsersWithListInput(ServerRequestInterface $request)
{
//TODO implement method
- /** @var \App\DTO\User[] $bodyData */
+ /** @var \App\DTO\Collection36 $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(501, "Not implemented");
}
diff --git a/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserLogin.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserLogin.php
new file mode 100644
index 00000000000..38a502537f7
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserLogin.php
@@ -0,0 +1,36 @@
+ \App\DTO\LoginUserQueryData::class,
+ "objectAttr" => "queryData",
+ "source" => PHAttribute\Transfer::SOURCE_GET
+ ])]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
+ public function loginUser(ServerRequestInterface $request): string
+ {
+ //TODO implement method
+ /** @var \App\DTO\LoginUserQueryData $queryData */
+ $queryData = $request->getAttribute("queryData");
+ throw new PHException\HttpCode(501, "Not implemented");
+ }
+}
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogout.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserLogout.php
similarity index 70%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogout.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserLogout.php
index 4c0d8b1bb06..7cb7b9a8a2e 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserLogout.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserLogout.php
@@ -3,25 +3,20 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/user/logout")
- */
+#[PHA\Route("/user/logout")]
class UserLogout
{
/**
* Logs out current logged in user session
- * @PHA\Get()
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Get()]
public function logoutUser(ServerRequestInterface $request)
{
//TODO implement method
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserUsername.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserUsername.php
similarity index 51%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserUsername.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserUsername.php
index ce3de984969..68be5f4fc1a 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Handler/UserUsername.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Handler/UserUsername.php
@@ -3,25 +3,20 @@ declare(strict_types=1);
namespace App\Handler;
-use Articus\PathHandler\Annotation as PHA;
+use Articus\PathHandler\PhpAttribute as PHA;
use Articus\PathHandler\Consumer as PHConsumer;
use Articus\PathHandler\Producer as PHProducer;
use Articus\PathHandler\Attribute as PHAttribute;
use Articus\PathHandler\Exception as PHException;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * @PHA\Route(pattern="/user/{username}")
- */
+#[PHA\Route("/user/{username}")]
class UserUsername
{
/**
* Delete user
- * @PHA\Delete()
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Delete()]
public function deleteUser(ServerRequestInterface $request)
{
//TODO implement method
@@ -29,17 +24,12 @@ class UserUsername
}
/**
* Get user by user name
- * @PHA\Get()
- * 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")
- * 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/json")
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
- *
- * @return \App\DTO\User
*/
+ #[PHA\Get()]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/xml", PHProducer\Transfer::class)]
+ // TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Producer("application/json", PHProducer\Transfer::class)]
public function getUserByName(ServerRequestInterface $request): \App\DTO\User
{
//TODO implement method
@@ -47,14 +37,11 @@ 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, mediaRange="application/json")
- * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"})
- * @param ServerRequestInterface $request
- *
- * @throws PHException\HttpCode 501 if the method is not implemented
*/
+ #[PHA\Put()]
+ // TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation
+ #[PHA\Consumer("application/json", PHConsumer\Json::class)]
+ #[PHA\Attribute(PHAttribute\Transfer::class, ["type" => \App\DTO\User::class, "objectAttr" => "bodyData"])]
public function updateUser(ServerRequestInterface $request)
{
//TODO implement method
diff --git a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php b/samples/server/petstore/php-mezzio-ph-modern/src/App/Middleware/InternalServerError.php
similarity index 82%
rename from samples/openapi3/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php
rename to samples/server/petstore/php-mezzio-ph-modern/src/App/Middleware/InternalServerError.php
index f0354421e00..bc6d5969e2a 100644
--- a/samples/openapi3/server/petstore/php-mezzio-ph/src/App/Middleware/InternalServerError.php
+++ b/samples/server/petstore/php-mezzio-ph-modern/src/App/Middleware/InternalServerError.php
@@ -11,17 +11,8 @@ use Laminas\Stdlib\ErrorHandler;
class InternalServerError implements MiddlewareInterface
{
- /**
- * @var callable
- */
- protected $responseGenerator;
-
- /**
- * @param callable $responseGenerator
- */
- public function __construct(callable $responseGenerator)
+ public function __construct(protected \Closure $responseGenerator)
{
- $this->responseGenerator = $responseGenerator;
}
/**
diff --git a/samples/server/petstore/php-mezzio-ph/.openapi-generator/FILES b/samples/server/petstore/php-mezzio-ph/.openapi-generator/FILES
index fc8224fecb8..bc9a68917b6 100644
--- a/samples/server/petstore/php-mezzio-ph/.openapi-generator/FILES
+++ b/samples/server/petstore/php-mezzio-ph/.openapi-generator/FILES
@@ -9,6 +9,43 @@ composer.json
public/index.php
src/App/DTO/ApiResponse.php
src/App/DTO/Category.php
+src/App/DTO/Collection.php
+src/App/DTO/Collection1.php
+src/App/DTO/Collection10.php
+src/App/DTO/Collection11.php
+src/App/DTO/Collection12.php
+src/App/DTO/Collection13.php
+src/App/DTO/Collection14.php
+src/App/DTO/Collection15.php
+src/App/DTO/Collection16.php
+src/App/DTO/Collection17.php
+src/App/DTO/Collection18.php
+src/App/DTO/Collection19.php
+src/App/DTO/Collection2.php
+src/App/DTO/Collection20.php
+src/App/DTO/Collection21.php
+src/App/DTO/Collection22.php
+src/App/DTO/Collection23.php
+src/App/DTO/Collection24.php
+src/App/DTO/Collection25.php
+src/App/DTO/Collection26.php
+src/App/DTO/Collection27.php
+src/App/DTO/Collection28.php
+src/App/DTO/Collection29.php
+src/App/DTO/Collection3.php
+src/App/DTO/Collection30.php
+src/App/DTO/Collection31.php
+src/App/DTO/Collection32.php
+src/App/DTO/Collection33.php
+src/App/DTO/Collection34.php
+src/App/DTO/Collection35.php
+src/App/DTO/Collection36.php
+src/App/DTO/Collection4.php
+src/App/DTO/Collection5.php
+src/App/DTO/Collection6.php
+src/App/DTO/Collection7.php
+src/App/DTO/Collection8.php
+src/App/DTO/Collection9.php
src/App/DTO/FindPetsByStatusQueryData.php
src/App/DTO/FindPetsByTagsQueryData.php
src/App/DTO/LoginUserQueryData.php
diff --git a/samples/server/petstore/php-mezzio-ph/README.md b/samples/server/petstore/php-mezzio-ph/README.md
index 584fd156879..a8047005901 100644
--- a/samples/server/petstore/php-mezzio-ph/README.md
+++ b/samples/server/petstore/php-mezzio-ph/README.md
@@ -5,9 +5,9 @@ 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.2
+- PHP: >=7.3
- [Laminas Mezzio](https://docs.mezzio.dev/mezzio/): >=3.2
-- [Path Handler](https://github.com/Articus/PathHandler): >=0.6
+- [Path Handler](https://github.com/Articus/PathHandler): >=0.7
## How to use
All you have to do to start development is:
diff --git a/samples/server/petstore/php-mezzio-ph/application/config.yml b/samples/server/petstore/php-mezzio-ph/application/config.yml
index 1f106812353..71371becf21 100644
--- a/samples/server/petstore/php-mezzio-ph/application/config.yml
+++ b/samples/server/petstore/php-mezzio-ph/application/config.yml
@@ -9,10 +9,11 @@
# router:
# cache:
# directory: ./data/cache/PathHandler
-# #Enable handler metadata cache
-# metadata:
-# cache:
-# directory: ./data/cache/PathHandler
+
+#Enable handler metadata cache
+#Articus\PathHandler\MetadataProvider\Annotation:
+# cache:
+# directory: ./data/cache/PathHandler
#Enable data transfer metadata cache for DTOs
#Articus\DataTransfer\MetadataProvider\Annotation:
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
index c5174147c23..548c898fb9c 100644
--- a/samples/server/petstore/php-mezzio-ph/application/config/data_transfer.yml
+++ b/samples/server/petstore/php-mezzio-ph/application/config/data_transfer.yml
@@ -16,6 +16,10 @@ Articus\DataTransfer\Strategy\PluginManager:
factories:
Date: OpenAPIGenerator\Common\Strategy\Factory\MutableDate
DateTime: OpenAPIGenerator\Common\Strategy\Factory\MutableDateTime
+ ObjectList: OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectList
+ ObjectMap: OpenAPIGenerator\Common\Strategy\Factory\NoArgObjectMap
+ ScalarList: OpenAPIGenerator\Common\Strategy\Factory\ScalarList
+ ScalarMap: OpenAPIGenerator\Common\Strategy\Factory\ScalarMap
Articus\DataTransfer\Validator\PluginManager:
invokables:
@@ -24,3 +28,7 @@ Articus\DataTransfer\Validator\PluginManager:
QueryStringScalarArray: OpenAPIGenerator\Common\Validator\QueryStringScalarArray
abstract_factories:
- Articus\DataTransfer\Validator\Factory\Laminas
+
+validators:
+ invokables:
+ Count: Laminas\Validator\IsCountable
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
index 25995b20d6f..174f6fc3d26 100644
--- a/samples/server/petstore/php-mezzio-ph/application/config/path_handler.yml
+++ b/samples/server/petstore/php-mezzio-ph/application/config/path_handler.yml
@@ -1,8 +1,13 @@
dependencies:
factories:
- Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjection\Factory
+ Mezzio\Router\RouterInterface: Articus\PathHandler\RouteInjectionFactory
+ Articus\PathHandler\MetadataProviderInterface: Articus\PathHandler\MetadataProvider\Factory\Annotation
+ Articus\PathHandler\Handler\PluginManager: Articus\PathHandler\Handler\Factory\PluginManager
+ Articus\PathHandler\Consumer\PluginManager: Articus\PathHandler\Consumer\Factory\PluginManager
+ Articus\PathHandler\Attribute\PluginManager: Articus\PathHandler\Attribute\Factory\PluginManager
+ Articus\PathHandler\Producer\PluginManager: Articus\PathHandler\Producer\Factory\PluginManager
-Articus\PathHandler\RouteInjection\Factory:
+Articus\PathHandler\RouteInjectionFactory:
paths:
'/v2':
- App\Handler\Pet
@@ -19,18 +24,22 @@ Articus\PathHandler\RouteInjection\Factory:
- 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:
+
+Articus\PathHandler\Handler\PluginManager:
+ abstract_factories:
+ - Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory
+
+#Articus\PathHandler\Consumer\PluginManager:
+# factories:
+# invokables:
+
+#Articus\PathHandler\Attribute\PluginManager:
+# factories:
+# invokables:
+
+#Articus\PathHandler\Producer\PluginManager:
+# factories:
+# invokables:
Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory:
App\Handler\Pet: []
diff --git a/samples/server/petstore/php-mezzio-ph/composer.json b/samples/server/petstore/php-mezzio-ph/composer.json
index 54f8e97226c..c98cf998302 100644
--- a/samples/server/petstore/php-mezzio-ph/composer.json
+++ b/samples/server/petstore/php-mezzio-ph/composer.json
@@ -5,13 +5,13 @@
"version": "1.0.0",
"type": "project",
"require": {
- "php": "^7.2",
+ "php": "^7.3 || ^8.0",
"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",
+ "articus/path-handler": "^0.7",
+ "articus/data-transfer": "^0.5",
+ "articus/openapi-generator-common": "^0.2",
"doctrine/annotations": "^1.10",
"psr/simple-cache": "^1.0",
"laminas/laminas-config": "^3.4",
diff --git a/samples/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php b/samples/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php
index a08cb2c9275..0161f75b2b2 100644
--- a/samples/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php
+++ b/samples/server/petstore/php-mezzio-ph/src/App/DTO/ApiResponse.php
@@ -16,16 +16,19 @@ class ApiResponse
* @var int|null
*/
public $code;
+
/**
* @DTA\Data(field="type", nullable=true)
* @DTA\Validator(name="Scalar", options={"type":"string"})
* @var string|null
*/
public $type;
+
/**
* @DTA\Data(field="message", nullable=true)
* @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
index 7b65c273d40..41a221be1cf 100644
--- a/samples/server/petstore/php-mezzio-ph/src/App/DTO/Category.php
+++ b/samples/server/petstore/php-mezzio-ph/src/App/DTO/Category.php
@@ -16,6 +16,7 @@ class Category
* @var int|null
*/
public $id;
+
/**
* @DTA\Data(field="name", nullable=true)
* @DTA\Validator(name="Scalar", options={"type":"string"})
@@ -23,4 +24,5 @@ class Category
* @var string|null
*/
public $name;
+
}
diff --git a/samples/server/petstore/php-mezzio-ph/src/App/DTO/Collection.php b/samples/server/petstore/php-mezzio-ph/src/App/DTO/Collection.php
new file mode 100644
index 00000000000..0e478eb4bd8
--- /dev/null
+++ b/samples/server/petstore/php-mezzio-ph/src/App/DTO/Collection.php
@@ -0,0 +1,16 @@
+get(Middleware\InternalServerError::class);
- if (!($errorMiddleware instanceof Middleware\InternalServerError)) {
- throw new \LogicException(\sprintf(
- 'Invalid error middleware: expecting %s, not %s.',
- Middleware\InternalServerError::class,
- \is_object($errorMiddleware) ? \get_class($errorMiddleware) : \gettype($errorMiddleware)
- ));
- }
+ $errorMiddleware = self::getErrorMiddleware($container);
$pipeline = new MiddlewarePipe();
$runner = new RequestHandlerRunner(
$pipeline,
$container->get(EmitterInterface::class),
$container->get(ServerRequestInterface::class),
- function(\Throwable $error) use ($errorMiddleware) : ResponseInterface
+ static function(\Throwable $error) use ($errorMiddleware) : ResponseInterface
{
return $errorMiddleware->handleError($error);
}
@@ -55,4 +48,9 @@ class Factory implements FactoryInterface
return $application;
}
+
+ protected static function getErrorMiddleware(ContainerInterface $container): Middleware\InternalServerError
+ {
+ return $container->get(Middleware\InternalServerError::class);
+ }
}
diff --git a/samples/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php b/samples/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php
index c1c1ce75400..917f9f767a3 100644
--- a/samples/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php
+++ b/samples/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByStatus.php
@@ -31,10 +31,9 @@ class PetFindByStatus
*
* @throws PHException\HttpCode 501 if the method is not implemented
*
- * TODO check if generated return container type is valid
- * @return \App\DTO\Pet[]
+ * @return \App\DTO\Collection19
*/
- public function findPetsByStatus(ServerRequestInterface $request): array
+ public function findPetsByStatus(ServerRequestInterface $request): \App\DTO\Collection19
{
//TODO implement method
/** @var \App\DTO\FindPetsByStatusQueryData $queryData */
diff --git a/samples/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php b/samples/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php
index b722a310efb..b74484da909 100644
--- a/samples/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php
+++ b/samples/server/petstore/php-mezzio-ph/src/App/Handler/PetFindByTags.php
@@ -31,10 +31,9 @@ class PetFindByTags
*
* @throws PHException\HttpCode 501 if the method is not implemented
*
- * TODO check if generated return container type is valid
- * @return \App\DTO\Pet[]
+ * @return \App\DTO\Collection26
*/
- public function findPetsByTags(ServerRequestInterface $request): array
+ public function findPetsByTags(ServerRequestInterface $request): \App\DTO\Collection26
{
//TODO implement method
/** @var \App\DTO\FindPetsByTagsQueryData $queryData */
diff --git a/samples/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php b/samples/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php
index c1ca1be83d1..c9150110c44 100644
--- a/samples/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php
+++ b/samples/server/petstore/php-mezzio-ph/src/App/Handler/StoreInventory.php
@@ -24,10 +24,9 @@ class StoreInventory
*
* @throws PHException\HttpCode 501 if the method is not implemented
*
- * TODO check if generated return container type is valid
- * @return array
+ * @return \App\DTO\Collection34
*/
- public function getInventory(ServerRequestInterface $request): array
+ public function getInventory(ServerRequestInterface $request): \App\DTO\Collection34
{
//TODO implement method
throw new PHException\HttpCode(501, "Not implemented");
diff --git a/samples/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php b/samples/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php
index a8a39215bab..8df1e8b18fd 100644
--- a/samples/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php
+++ b/samples/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithArray.php
@@ -20,8 +20,7 @@ class UserCreateWithArray
* @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, 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"})
+ * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Collection36::class,"objectAttr":"bodyData"})
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 501 if the method is not implemented
@@ -29,7 +28,7 @@ class UserCreateWithArray
public function createUsersWithArrayInput(ServerRequestInterface $request)
{
//TODO implement method
- /** @var \App\DTO\User[] $bodyData */
+ /** @var \App\DTO\Collection36 $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(501, "Not implemented");
}
diff --git a/samples/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php b/samples/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php
index b34cca7045f..dae1cc0f264 100644
--- a/samples/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php
+++ b/samples/server/petstore/php-mezzio-ph/src/App/Handler/UserCreateWithList.php
@@ -20,8 +20,7 @@ class UserCreateWithList
* @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, 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"})
+ * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Collection36::class,"objectAttr":"bodyData"})
* @param ServerRequestInterface $request
*
* @throws PHException\HttpCode 501 if the method is not implemented
@@ -29,7 +28,7 @@ class UserCreateWithList
public function createUsersWithListInput(ServerRequestInterface $request)
{
//TODO implement method
- /** @var \App\DTO\User[] $bodyData */
+ /** @var \App\DTO\Collection36 $bodyData */
$bodyData = $request->getAttribute("bodyData");
throw new PHException\HttpCode(501, "Not implemented");
}