Swaggervel icon indicating copy to clipboard operation
Swaggervel copied to clipboard

Class 'Swagger\Swagger' not found

Open klimentLambevski opened this issue 9 years ago • 22 comments

I installed swaggervel in my project but when i go to /api-docs i get this error

FatalErrorException in routes.php line 39:
Class 'Swagger\Swagger' not found
in C:\projects\laraveltest\laravel\vendor\jlapp\swaggervel\src\Jlapp\Swaggervel\routes.php line 39

Also i get error when i visit /docs

NotFoundHttpException in C:\projects\laraveltest\laravel\vendor\laravel\framework\src\Illuminate\Foundation\Application.php line 879:
Cannot find C:\projects\laraveltest\laravel\storage/docs/api-docs.json

klimentLambevski avatar Jul 27 '15 21:07 klimentLambevski

Pull from master at the moment. This will be fixed soon.

slampenny avatar Jul 31 '15 22:07 slampenny

The problem was with Swagger-php, right? I forked and updated this awesome package to use Swagger-php 2.0 (and Swagger-spec 2.0). It is here: https://github.com/tralves/Swaggervel.

tralves avatar Aug 12 '15 18:08 tralves

@tralves That's awesome. I've been a little snowed in on the day job. Please send a pull request?

slampenny avatar Aug 13 '15 15:08 slampenny

Sure! I'd like you to take a look at the Swaggervel/routes..php. I removed a bunch of code that seemed to generate multiple doc files. I didn't know if it was needed, nor how to implement using Swagger-php 2.0, so I just deleted it :).

tralves avatar Aug 13 '15 16:08 tralves

@slampenny I am facing the issue that @klimentLambevski has... what was the work around to this? I have pulled from master. When i visit the /docs or api-docs links an error is thrown as given above.

scripta55 avatar Oct 12 '15 11:10 scripta55

I am still getting this error, any fix?

vivex avatar Nov 17 '15 02:11 vivex

I don't understand how you are getting this error, when the code in the master version has changed (https://github.com/slampenny/Swaggervel/blob/master/src/Jlapp/Swaggervel/routes.php#L39).

tralves avatar Nov 17 '15 03:11 tralves

oops i was using 2.0 branch, after switching to dev-master ("jlapp/swaggervel": "master-dev") its working very well.

vivex avatar Nov 17 '15 03:11 vivex

I am using dev-master but when I visit "http://my-laravel-project/api-docs" I get this error. NotFoundHttpException in RouteCollection.php line 161: any help?

mo-ry avatar Feb 02 '16 04:02 mo-ry

when I visit /docs I get this error. NotFoundHttpException in Application.php line 879: Cannot find /home/ubuntu/workspace/my-application/storage/docs/api-docs.json

mo-ry avatar Feb 02 '16 05:02 mo-ry

Can you see the /docs and /api-docs when you list the app's routes (php artisan route:list)?

Did you follow this instruction correctly (from the documentation)?

Add Jlapp\Swaggervel\SwaggervelServiceProvider to your providers array in app/config/app.php above your routes provider (to avoid catch all routes)

tralves avatar Feb 02 '16 11:02 tralves

@yuichimori same issue with me. using fresh install of laravel 5.2

thecodingwhale avatar Feb 02 '16 15:02 thecodingwhale

I installed Laravel 5.2.13 and add Jlapp\Swaggervel\SwaggervelServiceProvider like below.

App\Providers\EventServiceProvider::class,
Jlapp\Swaggervel\SwaggervelServiceProvider::class,
App\Providers\RouteServiceProvider::class,

But I still get the same error. I only see api/docs and docs/{page?}. When I visit api/docs I get this error.

Required @SWG\Info() not found

mo-ry avatar Feb 03 '16 04:02 mo-ry

I settled to use ApiDocs instead. Time was against me on this. On 3 Feb 2016 06:28, "yuichimori" [email protected] wrote:

I installed Laravel 5.2.13 and add Jlapp\Swaggervel\SwaggervelServiceProvider like below.

App\Providers\EventServiceProvider::class, Jlapp\Swaggervel\SwaggervelServiceProvider::class, App\Providers\RouteServiceProvider::class,

But I still get the same error. I only see api/docs and docs/{page?}. When I visit api/docs I get this error.

Required @SWG\Info() not found

— Reply to this email directly or view it on GitHub https://github.com/slampenny/Swaggervel/issues/43#issuecomment-178999612 .

scripta55 avatar Feb 04 '16 08:02 scripta55

@yuichimori That's a swagger-php error. Maybe you are following the project documentation (found here) which is wrong!

I used mostly the examples found here: https://github.com/zircote/swagger-php/tree/master/Examples

The code for @SWG\Info() is here: https://github.com/zircote/swagger-php/blob/master/Examples/petstore.swagger.io/swagger-v2.php

However, I would advise not to use the swagger php annotations. In my case, I actually managed to document my api with these annotations, but:

  • it was very, very hard;
  • poor (actually none) documentation. Had to do everything based on the examples, and even search the source code of the package in order to figure some things out. Basically a trial and error process.
  • the syntax is awful. It is very wordy and hard to read. It would be nice if I could use those annotations as documentation for the code, but they are very hard to read, even for me, who created them in the first place! Ended up with huge blocks of comments in my code that I hated to have to scroll through.
  • Hard to test. I had to change the annotations, generate the json, and paste it into swagger editor and then see the error. Then repeat...

The main advantage of having the documentation along with the code so that you could keep code and docs in sync simply disappeared in the middle of all these disadvantages.

So in my case, when the api had some changes and another developer coming along, we just quit using swagger-php annotations and just use swagger editor to generate the .json. I still use this package to serve the swagger-ui though.

I hope it helps.

tralves avatar Feb 04 '16 11:02 tralves

I'm facing the same issue as @yuichimori . This is a recent problem because some weeks ago it went all good

mikylucky avatar Feb 04 '16 17:02 mikylucky

Thanks very much. I will check other tools

mo-ry avatar Feb 05 '16 06:02 mo-ry

http://apidocjs.com/ check this out if all else fails or delays on swagger On 5 Feb 2016 08:12, "yuichimori" [email protected] wrote:

Thanks very much. I will check other tools

— Reply to this email directly or view it on GitHub https://github.com/slampenny/Swaggervel/issues/43#issuecomment-180216811 .

scripta55 avatar Feb 05 '16 06:02 scripta55

/docs works for me, but api-docs generates a NotFoundHttpException.

chenshuiluke avatar Feb 13 '16 19:02 chenshuiluke

@chenshuiluke See if my commit a75bbbcb3b2d4030ea50be6cc0979da35b768a8d helps you.

DSpeichert avatar Feb 13 '16 21:02 DSpeichert

@DSpeichert, @chenshuiluke that commit will break the package if you are using the updated version of Swaggervel (i.e. the one that's in master). Currently, Swaggervel uses Swagger-php 2.0.

tralves avatar Feb 14 '16 21:02 tralves

@tralves Of course it will. That pull request (#64) is targeted for the 2.0 branch, which is supposed to use swagger-php 1.X but instead uses * as the version.

DSpeichert avatar Feb 14 '16 23:02 DSpeichert