-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Can't get Swagger + Servlet to work. My APIs are not listed. #463
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
Comments
If you are using the reflection scanner, you might need to add a dependency on the reflections api v0.9.9-RC1. For maven: <dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC1</version>
</dependency> The version before this (included with swagger-core) is broken and cannot handle the vfs urls that are returned by JBoss. Perhaps Tomcat returns the same vfs style urls when Swagger tries to get the package to scan. |
Hi Shodow Man, Thanks. A Reflection jar has been deployed. There is no error when I built my project or when Tomcat ran. Just Swagger is not showing my APIs. On Thursday, February 13, 2014 6:28 PM, Shadow Man [email protected] wrote: If you are using the reflection scanner, you might need to add a dependency on the reflections api v0.9.9-RC1. |
@HelenGao, I think we should continue this discussion in the google group (since you left a message there as well). If we'll find an actual issue, you're more than welcome to open a new one. |
I am facing the same issue. I used java jersey swagger.API is not listing. can any one provide solution for java jaxrs swagger? |
Can you provide a few more details? What have you done so far? On Fri, Feb 21, 2014 at 1:38 PM, poonkothai408425
|
Hi Shadow man and webon, Thanks a lot for your help. But I still can't get Swagger + Servlet to work. My APIs are still not listed. https://localhost:8443/MyServer/api-docs only displays {"apiVersion":"1.0.0","swaggerVersion":"1.2"}. I am not sure if the conflict of jar files below is the reason. I downloaded and built scala-servlet, then copied all jars from scala-servlet\target\lib to my Tomcat webapps\MyServer\WEB-INF\lib. One of the files I copied was servlet-api-2.5.jar. But Tomcat couldn't load this jar because a similar file already exist. The existing jar is servelt-api.jar from Tomcat 7. The error message is below. catalina log - INFO: validateJarFile(C:\Eclipse\Slingshot Trunk\server\webapps\vault\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class Your input would be much appreciated. Helen |
@HelenGao - I believe Tony is helping you work this out in the mailing list. Can I close the issue here? |
Sure. Thanks. On Sunday, March 23, 2014 4:51 AM, webron [email protected] wrote: @HelenGao - I believe Tony is helping you work this out in the mailing list. Can I close the issue here? |
Hello I have issue using reflections ClasspathHelper.forPackage for scan -> on local WLP it works fine but deployed on WAS it returns zero results... Anyone help ? |
@to-kra - can you open a new issue or even just send the question to the google group. It'd be difficult to track this way. |
@webron I found a problem in BeanConfig, which scans classes by package. Reflections ClassHelper.forPackage(..) does not count with possibility that classes can be inside of jars like in WEB-INF/lib, as our deployed app has modules compiled into jars placed into WEB-INF/lib. I extended BeanConfig and changed method classes() where i do also fallback to ClasspathHelper.forWebInfLib(..) which can find such jar-ed classes. Now everything works fine ! |
@to-kra - great, thanks for the update! |
Facing similar issue as @HelenGao. Can you share what was the solution for it. or atleast a link to mailing thread. |
@to-kra |
Hi.
I followed Swagger Servlet Quickstart guide, and expected to see MyRESTServlet listed under https://localhost:8443/myServer/api-docs. But all it displays is {"apiVersion":"1.0.0","swaggerVersion":"1.2"}.
I annotated my HttpServlet as below:
@Api(value = "/myPath", description = "My REST servlet!")
public class MyRESTServlet extends HttpServlet
{
…
I added two Swagger servlets in my Tomcat web.xml as instructed by Swagger as below, but not sure if I am supposed to make any changes. For example, what does the paramter swagger.api.basepath means when it's set to http://localhost:8002?
Here is what the Swagger instruction says https://github.com/wordnik/swagger-core/wiki/Servlet-Quickstart: Swagger scans all classes with an @Api annotation on them. Each @Api resource will appear as an Api Declaration in swagger. The annotation is done as follows:
import com.wordnik.swagger.annotations.*;
@Api(value = "/sample/users", description = "gets some data from a servlet")
public class SampleServlet extends HttpServlet {
...
Swagger will list your api under /sample/users as well with the description specified.
I am not sure if this is the right venue for this type of question. Thank you in advance.
The text was updated successfully, but these errors were encountered: