[BUG] PHPSlim Auth middleware TypeError
Created by: ybelenko
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
Current generator requires AbstractAuthenticator
user implementation when schema contains security definitions. When implementation class is provided app throws TypeError.
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
Any spec file file with secured endpoints can reproduce the bug. https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
Command line used for generation
bin/php-slim-server-petstore.sh
Steps to reproduce
- Generate server stubs with any spec file with secured endpoints
- Make HTTP request to any secured endpoint
- App throws Exception with message
How about extending AbstractAuthenticator class by OpenAPIServer\\Auth\\OAuthAuthenticator?
- Overwrite
AbstractAuthenticator
with your ownOAuthAuthenticator
class. - Generate new Composer autoload with
composer dump-autoload
- Make the same HTTP request to any secured endpoint.
- App throws error
[10-Apr-2019 17:42:41 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to OpenAPIServer\Auth\AbstractAuthenticator::__construct()
must implement interface Psr\Container\ContainerInterface, array given, called in
/Applications/MAMP/htdocs/openapi-generator/samples/server/petstore/php-slim/lib/SlimRouter.php on line 650 and defined in
/Applications/MAMP/htdocs/openapi-generator/samples/server/petstore/php-slim/lib/Auth/AbstractAuthenticator.php:70
Suggest a fix
Will fix it myself.