Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Class 'Swagger\Swagger' not found #43

Open
klimentLambevski opened this issue Jul 27, 2015 · 22 comments
Open

Class 'Swagger\Swagger' not found #43

klimentLambevski opened this issue Jul 27, 2015 · 22 comments

Comments

@klimentLambevski
Copy link

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
Copy link
Owner

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

@tralves
Copy link
Contributor

tralves commented Aug 12, 2015

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
Copy link
Owner

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

@tralves
Copy link
Contributor

tralves commented Aug 13, 2015

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
Copy link

@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
Copy link

vivex commented Nov 17, 2015

I am still getting this error, any fix?

@tralves
Copy link
Contributor

tralves commented Nov 17, 2015

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
Copy link

vivex commented Nov 17, 2015

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

@mo-ry
Copy link

mo-ry commented Feb 2, 2016

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
Copy link

mo-ry commented Feb 2, 2016

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
Copy link
Contributor

tralves commented Feb 2, 2016

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
Copy link

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

@mo-ry
Copy link

mo-ry commented Feb 3, 2016

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
Copy link

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
#43 (comment)
.

@tralves
Copy link
Contributor

tralves commented Feb 4, 2016

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

@mikylucky
Copy link

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

@mo-ry
Copy link

mo-ry commented Feb 5, 2016

Thanks very much. I will check other tools

@scripta55
Copy link

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
#43 (comment)
.

DSpeichert added a commit to DSpeichert/Swaggervel that referenced this issue Feb 12, 2016
@chenshuiluke
Copy link

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

@DSpeichert
Copy link

@chenshuiluke See if my commit a75bbbc helps you.

@tralves
Copy link
Contributor

tralves commented Feb 14, 2016

@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
Copy link

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants