diff --git a/bin/configs/php-ze-ph.yaml b/bin/configs/php-ze-ph.yaml index b3416dc196be..009f17a0e432 100644 --- a/bin/configs/php-ze-ph.yaml +++ b/bin/configs/php-ze-ph.yaml @@ -1,4 +1,4 @@ generatorName: php-ze-ph outputDir: samples/server/petstore/php-ze-ph -inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/php-ze-ph diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/README.md.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/README.md.mustache index 973240bb44ed..1cc1e36e9c29 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/README.md.mustache +++ b/modules/openapi-generator/src/main/resources/php-ze-ph/README.md.mustache @@ -5,7 +5,7 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project. ## Overview This server stub aims to provide light, yet comprehensive structure for your API project using: -- PHP: >=7.1 +- PHP: >=7.2 - [Zend Expressive](https://zendframework.github.io/zend-expressive): >=3.2 - [Path Handler](https://github.com/Articus/PathHandler): >=0.4 diff --git a/modules/openapi-generator/src/main/resources/php-ze-ph/composer.json.mustache b/modules/openapi-generator/src/main/resources/php-ze-ph/composer.json.mustache index c603ff4ac436..8306bc621e18 100644 --- a/modules/openapi-generator/src/main/resources/php-ze-ph/composer.json.mustache +++ b/modules/openapi-generator/src/main/resources/php-ze-ph/composer.json.mustache @@ -5,7 +5,7 @@ "version": "{{artifactVersion}}", "type": "project", "require": { - "php": "^7.1", + "php": "^7.2", "ext-yaml": "^2.0", "zendframework/zend-expressive": "^3.2", "zendframework/zend-diactoros": "^2.1", diff --git a/samples/server/petstore/php-ze-ph/.openapi-generator/FILES b/samples/server/petstore/php-ze-ph/.openapi-generator/FILES index ea6de5a097c9..d2b3e5a4d233 100644 --- a/samples/server/petstore/php-ze-ph/.openapi-generator/FILES +++ b/samples/server/petstore/php-ze-ph/.openapi-generator/FILES @@ -7,67 +7,18 @@ application/config/path_handler.yml application/container.php composer.json public/index.php -src/App/DTO/AdditionalPropertiesAnyType.php -src/App/DTO/AdditionalPropertiesArray.php -src/App/DTO/AdditionalPropertiesBoolean.php -src/App/DTO/AdditionalPropertiesClass.php -src/App/DTO/AdditionalPropertiesInteger.php -src/App/DTO/AdditionalPropertiesNumber.php -src/App/DTO/AdditionalPropertiesObject.php -src/App/DTO/AdditionalPropertiesString.php -src/App/DTO/Animal.php src/App/DTO/ApiResponse.php -src/App/DTO/ArrayOfArrayOfNumberOnly.php -src/App/DTO/ArrayOfNumberOnly.php -src/App/DTO/ArrayTest.php -src/App/DTO/BigCat.php -src/App/DTO/BigCatAllOf.php -src/App/DTO/Capitalization.php -src/App/DTO/Cat.php -src/App/DTO/CatAllOf.php src/App/DTO/Category.php -src/App/DTO/ClassModel.php -src/App/DTO/Client.php -src/App/DTO/Dog.php -src/App/DTO/DogAllOf.php -src/App/DTO/EnumArrays.php -src/App/DTO/EnumClass.php -src/App/DTO/EnumTest.php -src/App/DTO/FileSchemaTestClass.php -src/App/DTO/FormatTest.php -src/App/DTO/HasOnlyReadOnly.php -src/App/DTO/MapTest.php -src/App/DTO/MixedPropertiesAndAdditionalPropertiesClass.php -src/App/DTO/Model200Response.php -src/App/DTO/ModelReturn.php -src/App/DTO/Name.php -src/App/DTO/NumberOnly.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/OuterComposite.php -src/App/DTO/OuterEnum.php src/App/DTO/Pet.php -src/App/DTO/ReadOnlyFirst.php -src/App/DTO/SpecialModelName.php src/App/DTO/Tag.php -src/App/DTO/TypeHolderDefault.php -src/App/DTO/TypeHolderExample.php src/App/DTO/User.php -src/App/DTO/XmlItem.php src/App/Factory.php -src/App/Handler/AnotherFakeDummy.php -src/App/Handler/Fake.php -src/App/Handler/FakeBodyWithFileSchema.php -src/App/Handler/FakeBodyWithQueryParams.php -src/App/Handler/FakeClassnameTest.php -src/App/Handler/FakeCreateXmlItem.php -src/App/Handler/FakeInlineAdditionalProperties.php -src/App/Handler/FakeJsonFormData.php -src/App/Handler/FakeOuterBoolean.php -src/App/Handler/FakeOuterComposite.php -src/App/Handler/FakeOuterNumber.php -src/App/Handler/FakeOuterString.php -src/App/Handler/FakePetIdUploadImageWithRequiredFile.php -src/App/Handler/FakeTestQueryParamters.php src/App/Handler/Pet.php src/App/Handler/PetFindByStatus.php src/App/Handler/PetFindByTags.php diff --git a/samples/server/petstore/php-ze-ph/README.md b/samples/server/petstore/php-ze-ph/README.md index 973240bb44ed..1cc1e36e9c29 100644 --- a/samples/server/petstore/php-ze-ph/README.md +++ b/samples/server/petstore/php-ze-ph/README.md @@ -5,7 +5,7 @@ Generated by the [OpenAPI Generator](https://openapi-generator.tech) project. ## Overview This server stub aims to provide light, yet comprehensive structure for your API project using: -- PHP: >=7.1 +- PHP: >=7.2 - [Zend Expressive](https://zendframework.github.io/zend-expressive): >=3.2 - [Path Handler](https://github.com/Articus/PathHandler): >=0.4 diff --git a/samples/server/petstore/php-ze-ph/application/config/path_handler.yml b/samples/server/petstore/php-ze-ph/application/config/path_handler.yml index 786a0330ced8..08762d5415aa 100644 --- a/samples/server/petstore/php-ze-ph/application/config/path_handler.yml +++ b/samples/server/petstore/php-ze-ph/application/config/path_handler.yml @@ -1,20 +1,6 @@ Articus\PathHandler\RouteInjection\Factory: paths: '/v2': - - App\Handler\AnotherFakeDummy - - App\Handler\Fake - - App\Handler\FakeBodyWithFileSchema - - App\Handler\FakeBodyWithQueryParams - - App\Handler\FakeCreateXmlItem - - App\Handler\FakeInlineAdditionalProperties - - App\Handler\FakeJsonFormData - - App\Handler\FakeOuterBoolean - - App\Handler\FakeOuterComposite - - App\Handler\FakeOuterNumber - - App\Handler\FakeOuterString - - App\Handler\FakeTestQueryParamters - - App\Handler\FakePetIdUploadImageWithRequiredFile - - App\Handler\FakeClassnameTest - App\Handler\Pet - App\Handler\PetFindByStatus - App\Handler\PetFindByTags @@ -43,20 +29,6 @@ Articus\PathHandler\RouteInjection\Factory: # invokables: Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory: - App\Handler\AnotherFakeDummy: [] - App\Handler\Fake: [] - App\Handler\FakeBodyWithFileSchema: [] - App\Handler\FakeBodyWithQueryParams: [] - App\Handler\FakeCreateXmlItem: [] - App\Handler\FakeInlineAdditionalProperties: [] - App\Handler\FakeJsonFormData: [] - App\Handler\FakeOuterBoolean: [] - App\Handler\FakeOuterComposite: [] - App\Handler\FakeOuterNumber: [] - App\Handler\FakeOuterString: [] - App\Handler\FakeTestQueryParamters: [] - App\Handler\FakePetIdUploadImageWithRequiredFile: [] - App\Handler\FakeClassnameTest: [] App\Handler\Pet: [] App\Handler\PetFindByStatus: [] App\Handler\PetFindByTags: [] diff --git a/samples/server/petstore/php-ze-ph/composer.json b/samples/server/petstore/php-ze-ph/composer.json index 99c78857b2f3..f22fd4929557 100644 --- a/samples/server/petstore/php-ze-ph/composer.json +++ b/samples/server/petstore/php-ze-ph/composer.json @@ -5,7 +5,7 @@ "version": "1.0.0", "type": "project", "require": { - "php": "^7.1", + "php": "^7.2", "ext-yaml": "^2.0", "zendframework/zend-expressive": "^3.2", "zendframework/zend-diactoros": "^2.1", diff --git a/samples/server/petstore/php-ze-ph/src/App/DTO/AdditionalPropertiesAnyType.php b/samples/server/petstore/php-ze-ph/src/App/DTO/AdditionalPropertiesAnyType.php deleted file mode 100644 index 0cce3aa9a5f3..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/DTO/AdditionalPropertiesAnyType.php +++ /dev/null @@ -1,18 +0,0 @@ -process($request); - ErrorHandler::stop(true); - if (!($result instanceof Response)) { - throw new \RuntimeException(sprintf( - 'Invalid response: expecting %s, got %s', - Response::class, - is_object($result)? get_class($result) : gettype($result) - )); - } - } - catch (\Exception $error) { - $result = (new \Zend\Diactoros\Response())->withStatus(500, 'Internal server error'); - error_log((string)$error); - } - return $result; - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/AnotherFakeDummy.php b/samples/server/petstore/php-ze-ph/src/App/Handler/AnotherFakeDummy.php deleted file mode 100644 index ee20ba08d24a..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/AnotherFakeDummy.php +++ /dev/null @@ -1,39 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/Fake.php b/samples/server/petstore/php-ze-ph/src/App/Handler/Fake.php deleted file mode 100644 index 76880c68f6da..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/Fake.php +++ /dev/null @@ -1,75 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } - /** - * Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - * @PHA\Post() - * @param ServerRequestInterface $request - * - * @throws PHException\HttpCode 501 if the method is not implemented - */ - public function testEndpointParameters(ServerRequestInterface $request) - { - //TODO implement method - throw new PHException\HttpCode(501, "Not implemented"); - } - /** - * To test enum parameters - * @PHA\Get() - * @param ServerRequestInterface $request - * - * @throws PHException\HttpCode 501 if the method is not implemented - */ - public function testEnumParameters(ServerRequestInterface $request) - { - //TODO implement method - throw new PHException\HttpCode(501, "Not implemented"); - } - /** - * Fake endpoint to test group parameters (optional) - * @PHA\Delete() - * @param ServerRequestInterface $request - * - * @throws PHException\HttpCode 501 if the method is not implemented - */ - public function testGroupParameters(ServerRequestInterface $request) - { - //TODO implement method - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithFileSchema.php b/samples/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithFileSchema.php deleted file mode 100644 index 47ce029df6e1..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithFileSchema.php +++ /dev/null @@ -1,34 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithQueryParams.php b/samples/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithQueryParams.php deleted file mode 100644 index 9844c5978164..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeBodyWithQueryParams.php +++ /dev/null @@ -1,34 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeClassnameTest.php b/samples/server/petstore/php-ze-ph/src/App/Handler/FakeClassnameTest.php deleted file mode 100644 index 74991195dce0..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeClassnameTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeCreateXmlItem.php b/samples/server/petstore/php-ze-ph/src/App/Handler/FakeCreateXmlItem.php deleted file mode 100644 index ec96b29c8ef0..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeCreateXmlItem.php +++ /dev/null @@ -1,45 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeInlineAdditionalProperties.php b/samples/server/petstore/php-ze-ph/src/App/Handler/FakeInlineAdditionalProperties.php deleted file mode 100644 index bb6868c68e3e..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeInlineAdditionalProperties.php +++ /dev/null @@ -1,36 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeJsonFormData.php b/samples/server/petstore/php-ze-ph/src/App/Handler/FakeJsonFormData.php deleted file mode 100644 index ed3e0f6d2efe..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeJsonFormData.php +++ /dev/null @@ -1,30 +0,0 @@ -getAttribute("bodyData"); - throw new PHException\HttpCode(501, "Not implemented"); - } -} diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeOuterNumber.php b/samples/server/petstore/php-ze-ph/src/App/Handler/FakeOuterNumber.php deleted file mode 100644 index 595690de8977..000000000000 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/FakeOuterNumber.php +++ /dev/null @@ -1,33 +0,0 @@ -getAttribute("queryData"); throw new PHException\HttpCode(501, "Not implemented"); } } diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/PetFindByTags.php b/samples/server/petstore/php-ze-ph/src/App/Handler/PetFindByTags.php index 0126ada37c0a..b722a310efb0 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/PetFindByTags.php +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/PetFindByTags.php @@ -18,6 +18,11 @@ class PetFindByTags /** * Finds Pets by tags * @PHA\Get() + * @PHA\Attribute(name=PHAttribute\Transfer::class, options={ + * "type":\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(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 @@ -32,6 +37,8 @@ class PetFindByTags public function findPetsByTags(ServerRequestInterface $request): array { //TODO implement method + /** @var \App\DTO\FindPetsByTagsQueryData $queryData */ + $queryData = $request->getAttribute("queryData"); throw new PHException\HttpCode(501, "Not implemented"); } } diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrder.php b/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrder.php index 23623764409a..567e312fea5a 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrder.php +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrder.php @@ -18,6 +18,8 @@ class StoreOrder /** * Place an order for a pet * @PHA\Post() + * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation + * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\Order::class,"objectAttr":"bodyData"}) * TODO check if producer is valid, if it has correct priority and if it can be moved to class annotation * @PHA\Producer(name=PHProducer\Transfer::class, mediaType="application/xml") diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrderOrderId.php b/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrderOrderId.php index 28aa169a0c89..31c53e597eb3 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrderOrderId.php +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/StoreOrderOrderId.php @@ -11,7 +11,7 @@ use Psr\Http\Message\ServerRequestInterface; /** - * @PHA\Route(pattern="/store/order/{order_id}") + * @PHA\Route(pattern="/store/order/{orderId}") */ class StoreOrderOrderId { diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/User.php b/samples/server/petstore/php-ze-ph/src/App/Handler/User.php index 9d3d8ceb9e37..db151a05c60a 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/User.php +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/User.php @@ -18,6 +18,8 @@ class User /** * Create user * @PHA\Post() + * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation + * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"}) * @param ServerRequestInterface $request * diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithArray.php b/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithArray.php index 8ac24b28f2f6..4a2204fb7c0d 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithArray.php +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithArray.php @@ -18,6 +18,8 @@ class UserCreateWithArray /** * Creates list of users with given input array * @PHA\Post() + * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation + * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") * TODO check if attribute is valid and can handle your container type * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":"\App\DTO\User[]","objectAttr":"bodyData"}) * @param ServerRequestInterface $request diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithList.php b/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithList.php index 27ccafbb5d22..f61d9e4061eb 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithList.php +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/UserCreateWithList.php @@ -18,6 +18,8 @@ class UserCreateWithList /** * Creates list of users with given input array * @PHA\Post() + * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation + * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") * TODO check if attribute is valid and can handle your container type * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":"\App\DTO\User[]","objectAttr":"bodyData"}) * @param ServerRequestInterface $request diff --git a/samples/server/petstore/php-ze-ph/src/App/Handler/UserLogin.php b/samples/server/petstore/php-ze-ph/src/App/Handler/UserLogin.php index 2322e8f2317f..577e7c3f5629 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/UserLogin.php +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/UserLogin.php @@ -18,6 +18,11 @@ class UserLogin /** * Logs user into the system * @PHA\Get() + * @PHA\Attribute(name=PHAttribute\Transfer::class, options={ + * "type":\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(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 @@ -31,6 +36,8 @@ class UserLogin 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/server/petstore/php-ze-ph/src/App/Handler/UserUsername.php b/samples/server/petstore/php-ze-ph/src/App/Handler/UserUsername.php index 290bfeb9731d..1888015fea9b 100644 --- a/samples/server/petstore/php-ze-ph/src/App/Handler/UserUsername.php +++ b/samples/server/petstore/php-ze-ph/src/App/Handler/UserUsername.php @@ -48,6 +48,8 @@ public function getUserByName(ServerRequestInterface $request): \App\DTO\User /** * Updated user * @PHA\Put() + * TODO check if consumer is valid, if it has correct priority and if it can be moved to class annotation + * @PHA\Consumer(name=PHConsumer\Json::class, mediaType="application/json") * @PHA\Attribute(name=PHAttribute\Transfer::class, options={"type":\App\DTO\User::class,"objectAttr":"bodyData"}) * @param ServerRequestInterface $request *