Swaggervel
Swaggervel copied to clipboard
Class 'Swagger\Swagger' not found
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
Pull from master at the moment. This will be fixed soon.
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 That's awesome. I've been a little snowed in on the day job. Please send a pull request?
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 :).
@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.
I am still getting this error, any fix?
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).
oops i was using 2.0 branch, after switching to dev-master ("jlapp/swaggervel": "master-dev") its working very well.
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?
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
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)
@yuichimori same issue with me. using fresh install of laravel 5.2
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
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 .
@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.
I'm facing the same issue as @yuichimori . This is a recent problem because some weeks ago it went all good
Thanks very much. I will check other tools
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 .
/docs works for me, but api-docs generates a NotFoundHttpException.
@chenshuiluke See if my commit a75bbbcb3b2d4030ea50be6cc0979da35b768a8d helps you.
@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 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.