L5-Swagger: Possible bug on 5.6.8? php artisan l5-swagger:generate fails. Call to undefined function OpenApi\scan()

  • L5-Swagger Version: #.#.# (composer show | grep l5-swagger)
  • PHP Version (php -v): 7.1.19
  • OS:Debian GNU/Linux 9

Description:

Hi, is this a possible bug as I am not able to generate l5 docs after vup from 5.6.7 -> 5.6.8

Steps To Reproduce:

5.6.8

# php artisan l5-swagger:generate
Regenerating docs

   Symfony\Component\Debug\Exception\FatalThrowableError  : Call to undefined function OpenApi\scan()

  at /var/www/proj/vendor/darkaonline/l5-swagger/src/Generator.php:117
    113|      */
    114|     protected function scanFilesForDocumentation()
    115|     {
    116|         if ($this->isOpenApi()) {
  > 117|             $this->swagger = \OpenApi\scan(
    118|                 $this->appDir,
    119|                 ['exclude' => $this->excludedDirs]
    120|             );
    121|         }

  Exception trace:

  1   L5Swagger\Generator::scanFilesForDocumentation()
      /var/www/proj/vendor/darkaonline/l5-swagger/src/Generator.php:66

  2   L5Swagger\Generator::generateDocs()
      /var/www/proj/vendor/darkaonline/l5-swagger/src/Console/GenerateDocsCommand.php:32

  Please use the argument -v to see more details.

5.6.7

  - Updating darkaonline/l5-swagger (5.6.8 => 5.6.7): Loading from cache

All good

root@e7e0dc7da41f:/var/www/proj# php artisan l5-swagger:generate
Regenerating docs

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 34 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Install swagger-php 2.0 will fix it : “require”: { “zircote/swagger-php”: “~2.0”, }

Same problem. I follow @thanhnho1102 comment by running this composer require zircote/swagger-php:2.0.*. In my case, it will downgrade swagger-php from 3.* to 2.0.* and fix my problem.

Same problem with “darkaonline/l5-swagger”: “5.5.*”, “zircote/swagger-php”: “3.x-dev”

In Generator.php line 24:
Call to undefined function Swagger\scan()

Needs change to OpenApi\scan()

What annotations are you using, “OAS” or “OA”?

@kevincobain2000 I had the same issue. I resolved in this way: ./vendor/bin/swagger app/Http/ --output storage/api-docs/api-docs.json

then access the url: http://localhost/angular-laravel/public/api/documentation

I have installed in composer json:

 "require": {
        "php": "^7.1.3",
        "barryvdh/laravel-cors": "^0.11.0",
        "darkaonline/l5-swagger": "5.7.*",
        "fideloper/proxy": "^4.0",
        "folklore/graphql": "^1.1",
        "laravel/framework": "5.6.*",
        "laravel/tinker": "^1.0",
        "zircote/swagger-php": "2.*"
    },

@AshrafHefny as I pointed here from now only 5.7.* will support OpenApi.

please fix support for 5.5.* since the 5.6.* branch requires a newer php version

@AshrafHefny Yes, well it depends if you’re using Swagger or OpenAPI. If Swagger then SWG tags should work but if you’re with OpenAPI then all annotations should be OA due to swagger-php last update.

@kevincobain2000, @ejbogantes I was using @SWG annotation, I changed it to @OA annotation and now it works. But you should know that you’ll change almost every @SWG annotation to new @OA annotation including (type, enum, maxItems, minItems, collectionFormat, …, etc)

No, it is not major. Swagger-php for OpenApi is not released yet and annotations are in work. We are using OpenApi on our own risk for now.

Same issue here, the @OAS was changed to @OA which causes errors in a project here. This should not have been done in a patch release, this is a major change…