Class 'Swagger\Swagger' not found #43

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

Comments

Projects
None yet
10 participants
@klimentLambevski

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

This comment has been minimized.

Show comment
Hide comment
@slampenny

slampenny Jul 31, 2015

Owner

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

Owner

slampenny commented Jul 31, 2015

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

@tralves

This comment has been minimized.

Show comment
Hide comment
@tralves

tralves Aug 12, 2015

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@slampenny

slampenny Aug 13, 2015

Owner

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

Owner

slampenny commented Aug 13, 2015

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

@tralves

This comment has been minimized.

Show comment
Hide comment
@tralves

tralves Aug 13, 2015

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@scripta55

scripta55 Oct 12, 2015

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

@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

This comment has been minimized.

Show comment
Hide comment
@vivex

vivex Nov 17, 2015

I am still getting this error, any fix?

vivex commented Nov 17, 2015

I am still getting this error, any fix?

@tralves

This comment has been minimized.

Show comment
Hide comment
@tralves

tralves Nov 17, 2015

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@vivex

vivex Nov 17, 2015

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

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

This comment has been minimized.

Show comment
Hide comment
@mo-ry

mo-ry 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 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

This comment has been minimized.

Show comment
Hide comment
@mo-ry

mo-ry 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

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

This comment has been minimized.

Show comment
Hide comment
@tralves

tralves Feb 2, 2016

Contributor

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)

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

This comment has been minimized.

Show comment
Hide comment
@thecodingwhale

thecodingwhale Feb 2, 2016

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

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

@mo-ry

This comment has been minimized.

Show comment
Hide comment
@mo-ry

mo-ry 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

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

This comment has been minimized.

Show comment
Hide comment
@scripta55

scripta55 Feb 4, 2016

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

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

This comment has been minimized.

Show comment
Hide comment
@tralves

tralves Feb 4, 2016

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@mikylucky

mikylucky Feb 4, 2016

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

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

@mo-ry

This comment has been minimized.

Show comment
Hide comment
@mo-ry

mo-ry Feb 5, 2016

Thanks very much. I will check other tools

mo-ry commented Feb 5, 2016

Thanks very much. I will check other tools

@scripta55

This comment has been minimized.

Show comment
Hide comment
@scripta55

scripta55 Feb 5, 2016

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

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

This comment has been minimized.

Show comment
Hide comment
@chenshuiluke

chenshuiluke Feb 13, 2016

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

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

@DSpeichert

This comment has been minimized.

Show comment
Hide comment
@DSpeichert

DSpeichert Feb 13, 2016

@chenshuiluke See if my commit a75bbbc helps you.

@chenshuiluke See if my commit a75bbbc helps you.

@tralves

This comment has been minimized.

Show comment
Hide comment
@tralves

tralves Feb 14, 2016

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@DSpeichert

DSpeichert Feb 14, 2016

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment