Skip to content

[BUG] PHPSlim Auth middleware TypeError #2640

@ybelenko

Description

@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
  1. Generate server stubs with any spec file with secured endpoints
  2. Make HTTP request to any secured endpoint
  3. App throws Exception with message
How about extending AbstractAuthenticator class by OpenAPIServer\\Auth\\OAuthAuthenticator?
  1. Overwrite AbstractAuthenticator with your own OAuthAuthenticator class.
  2. Generate new Composer autoload with composer dump-autoload
  3. Make the same HTTP request to any secured endpoint.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions