slampenny / Swaggervel

Swagger for Laravel
492 stars 176 forks source link

Class 'Swagger\Swagger' not found #43

Open klimentLambevski opened 9 years ago

klimentLambevski commented 9 years ago

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
slampenny commented 9 years ago

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

tralves commented 9 years ago

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.

slampenny commented 9 years ago

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

tralves commented 9 years ago

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 :).

scripta55 commented 8 years ago

@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.

vivex commented 8 years ago

I am still getting this error, any fix?

tralves commented 8 years ago

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).

vivex commented 8 years ago

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

mo-ry commented 8 years ago

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 commented 8 years ago

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

tralves commented 8 years ago

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)

thecodingwhale commented 8 years ago

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

mo-ry commented 8 years ago

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

scripta55 commented 8 years ago

I settled to use ApiDocs instead. Time was against me on this. On 3 Feb 2016 06:28, "yuichimori" notifications@github.com 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 .

tralves commented 8 years ago

@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:

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.

mikylucky commented 8 years ago

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

mo-ry commented 8 years ago

Thanks very much. I will check other tools

scripta55 commented 8 years ago

http://apidocjs.com/ check this out if all else fails or delays on swagger On 5 Feb 2016 08:12, "yuichimori" notifications@github.com 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 .

chenshuiluke commented 8 years ago

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

DSpeichert commented 8 years ago

@chenshuiluke See if my commit a75bbbcb3b2d4030ea50be6cc0979da35b768a8d helps you.

tralves commented 8 years ago

@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.

DSpeichert commented 8 years ago

@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.