Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Problems with new "api-docs" path to the documentation description #113

Closed
vbauer opened this issue Dec 9, 2012 · 7 comments
Closed

Problems with new "api-docs" path to the documentation description #113

vbauer opened this issue Dec 9, 2012 · 7 comments

Comments

@vbauer
Copy link

vbauer commented Dec 9, 2012

I have an application which has worked good with old version of swagger-ui (1.3), but after updating to 1.7 I have a problems with UI availability:

  1. I open http://localhost:8080/restapi/ (there is my swagger-ui static files)
  2. I try to open my API (http://localhost:8080/rest/api-docs.json) using Swagger UI
  3. First request is normal (http://localhost:8080/rest/api-docs.json - 200 OK)
  4. After that swagger tries to receive information about REST services but fails:
    GET http://localhost:8080/rest/api-docs/auth?api_key=special-key 404 Not Found
    GET http://localhost:8080/rest/api-docs/tags?api_key=special-key 404 Not Found
    ...

Summary:
It seems for me, that Swagger UI uses incorrect URL to get rest services:
http://localhost:8080/rest/api-docs/... instead of http://localhost:8080/rest/...
When I try to open service documentation manually it works fine:
GET http://localhost:8080/rest/auth?api_key=special-key - 200 OK

Additional information:
web.xml config:

    <servlet>
        <servlet-name>jersey-serlvet</servlet-name>
        <servlet-class>com.simba.rest.servlet.ApplicationSpringServlet</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>com.simba.rest;com.wordnik.swagger.jaxrs.listing</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
            <param-value>
                com.sun.jersey.api.container.filter.GZIPContentEncodingFilter,
                com.sun.jersey.api.container.filter.PostReplaceFilter
            </param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
            <param-value>
                com.sun.jersey.api.container.filter.GZIPContentEncodingFilter
            </param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-value>true</param-value>
        </init-param>
        <init-param>
            <param-name>api.version</param-name>
            <param-value>0.1</param-value>
        </init-param>
        <init-param>
            <param-name>swagger.version</param-name>
            <param-value>1.2.0</param-value>
        </init-param>
        <init-param>
            <param-name>swagger.api.basepath</param-name>
            <param-value>http://localhost:8080/rest</param-value>
        </init-param>
        <init-param>
            <param-name>swagger.security.filter</param-name>
            <param-value>com.simba.rest.filter.RestApiAuthorizationFilter</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>jersey-serlvet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

Many thanks for any useful information!

@fehguy
Copy link
Contributor

fehguy commented Dec 9, 2012

Hi @vbauer, two things for you to do when upgrading (and i need to make an upgrade guide)...

  1. Your implementation classes should no longer extend JavaHelp or Help
  2. You should use swagger.version = 1.1 (since we're still on 1.1 for the specification, although 1.2 for the implementation.

The new version will automatically put your documentation under /api-docs.json/{path} instead of "eating" the GET method on /{path}

Try #1 (don't forget #2) and post back how it goes.

@vbauer
Copy link
Author

vbauer commented Dec 9, 2012

Many thanks for rapidly answer!

  1. I removed "extends JavaHelp" from my basic class for rest services
  2. I tried to use "1.1" and "1.1.0" as "swagger.version" parameter

But it doesn't work, I have the same problem..

The result of root documentation request:

{"apiVersion":"0.1","swaggerVersion":"1.1","basePath":"http://localhost:8080/rest","apis":[{"path":"/api-docs/auth","description":""},{"path":"/api-docs/tags","description":""},{"path":"/api-docs/users","description":""},{"path":"/api-docs/permissions","description":""},{"path":"/api-docs/directories","description":""},{"path":"/api-docs/files","description":""},{"path":"/api-docs/likes","description":""},{"path":"/api-docs/links","description":""},{"path":"/api-docs/roles","description":""},{"path":"/api-docs/resources","description":""},{"path":"/api-docs/avatars","description":""},{"path":"/api-docs/images","description":""},{"path":"/api-docs/indexer","description":""},{"path":"/api-docs/comments","description":""}]}

And yes, at now request to the service documentation returns error:
GET http://localhost:8080/rest/auth?api_key=special-key - 405 Method Not Allowed

@fehguy
Copy link
Contributor

fehguy commented Dec 9, 2012

Can you join #swagger on irc.freenode.net? Something is odd, we should see .{format} in the path for each api:

"path":"/api-docs/auth"

should be

"path":"/api-docs.{format}/auth"

unless you wrote a bootstrap servlet to set the format string to ""

@vbauer
Copy link
Author

vbauer commented Dec 9, 2012

Yes, I wrote bootstrap servlet to set the format string to ""

@fehguy
Copy link
Contributor

fehguy commented Dec 9, 2012

ok, that should be no problem then (it's one of our samples). Can you hit the resources directly? Like this:

http://localhost:8080/rest/api-docs/auth
http://localhost:8080/rest/api-docs/tags

etc...

@vbauer
Copy link
Author

vbauer commented Dec 9, 2012

HTTP ERROR 404

Problem accessing /rest/api-docs/tags. Reason:

Not Found

And the same situation with all services

@vbauer
Copy link
Author

vbauer commented Dec 9, 2012

Everything is fine if do the same things as there:
https://github.com/wordnik/swagger-core/wiki/Java-JAX-RS (Other configurations)

@vbauer vbauer closed this as completed Dec 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants