From fe5aa8c89cbc8d66345336521a78822b90cdce39 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 10 Apr 2019 23:14:20 +0500 Subject: [PATCH 1/4] Fix AbstractAuthenticator constructor TypeError --- .../src/main/resources/php-slim-server/SlimRouter.mustache | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache b/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache index 9bba236a7583..565bfb848ff9 100644 --- a/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache +++ b/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache @@ -125,6 +125,9 @@ class SlimRouter { $this->slimApp = new App($container); + // middlewares requires Psr\Container\ContainerInterface instead of array + $container = $this->slimApp->getContainer(); + {{#hasAuthMethods}} $authPackage = '{{authPackage}}'; $basicAuthenticator = function (ServerRequestInterface &$request, TokenSearch $tokenSearch) use ($authPackage) { From 821fa40afc677523fdfb3781c3d48802f7236b56 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Wed, 10 Apr 2019 23:18:17 +0500 Subject: [PATCH 2/4] Refresh samples --- samples/server/petstore/php-slim/lib/SlimRouter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/server/petstore/php-slim/lib/SlimRouter.php b/samples/server/petstore/php-slim/lib/SlimRouter.php index 4d30e8f40a8e..66feee12ae89 100644 --- a/samples/server/petstore/php-slim/lib/SlimRouter.php +++ b/samples/server/petstore/php-slim/lib/SlimRouter.php @@ -586,6 +586,9 @@ public function __construct($container = []) { $this->slimApp = new App($container); + // middlewares requires Psr\Container\ContainerInterface instead of array + $container = $this->slimApp->getContainer(); + $authPackage = 'OpenAPIServer\Auth'; $basicAuthenticator = function (ServerRequestInterface &$request, TokenSearch $tokenSearch) use ($authPackage) { $message = "How about extending AbstractAuthenticator class by {$authPackage}\BasicAuthenticator?"; From 108ced76b0284f9ce161262f8e9723d9d2367bc7 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Sat, 13 Apr 2019 06:26:11 +0500 Subject: [PATCH 3/4] Remove container argument reassign --- .../main/resources/php-slim-server/SlimRouter.mustache | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache b/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache index 565bfb848ff9..9ab1ed336f9c 100644 --- a/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache +++ b/modules/openapi-generator/src/main/resources/php-slim-server/SlimRouter.mustache @@ -116,16 +116,16 @@ class SlimRouter /** * Class constructor * - * @param ContainerInterface|array $container Either a ContainerInterface or an associative array of app settings + * @param ContainerInterface|array $settings Either a ContainerInterface or an associative array of app settings * * @throws InvalidArgumentException When no container is provided that implements ContainerInterface * @throws Exception When implementation class doesn't exists */ - public function __construct($container = []) + public function __construct($settings = []) { - $this->slimApp = new App($container); + $this->slimApp = new App($settings); - // middlewares requires Psr\Container\ContainerInterface instead of array + // middlewares requires Psr\Container\ContainerInterface $container = $this->slimApp->getContainer(); {{#hasAuthMethods}} From ff349bf9a93a5f4916e3a1c8d6d394391b400d76 Mon Sep 17 00:00:00 2001 From: Yuriy Belenko Date: Sat, 13 Apr 2019 06:26:37 +0500 Subject: [PATCH 4/4] Refresh samples --- samples/server/petstore/php-slim/lib/SlimRouter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/server/petstore/php-slim/lib/SlimRouter.php b/samples/server/petstore/php-slim/lib/SlimRouter.php index 66feee12ae89..94fc95ef8a31 100644 --- a/samples/server/petstore/php-slim/lib/SlimRouter.php +++ b/samples/server/petstore/php-slim/lib/SlimRouter.php @@ -577,16 +577,16 @@ class SlimRouter /** * Class constructor * - * @param ContainerInterface|array $container Either a ContainerInterface or an associative array of app settings + * @param ContainerInterface|array $settings Either a ContainerInterface or an associative array of app settings * * @throws InvalidArgumentException When no container is provided that implements ContainerInterface * @throws Exception When implementation class doesn't exists */ - public function __construct($container = []) + public function __construct($settings = []) { - $this->slimApp = new App($container); + $this->slimApp = new App($settings); - // middlewares requires Psr\Container\ContainerInterface instead of array + // middlewares requires Psr\Container\ContainerInterface $container = $this->slimApp->getContainer(); $authPackage = 'OpenAPIServer\Auth';