Hi, thanks for the feedback. I will create the ticket for the multiple packages. I did look at the servlet sample you linked here. I followed that example and updated to the latest code i posted above. The only difference now between my implemetation and that sample was I did not use a web.xml to specify the mapping. I only have that one custom servlet which has both the @Api annotation and the @Info annotation. The @info annotation is picked up and displayed but nothing shows up for the @Api contents.
On Monday, 26 December 2016 14:23:08 UTC-5, Ron wrote: > > If scanning multiple packages isn’t working for you, you should open a > ticket on the project. We may have some basic bugs with servlet > implementation as that’s less commonly used. > > > > The scanning should definitely pick up anything that has the @Api > annotations on it. The only reason it wouldn’t is if they are not in the > package you’ve set to be scanned. > > Have you had a look at the servlet sample? > > > > > > > > *From: *<[email protected] <javascript:>> on behalf of janet > vanderpuye <[email protected] <javascript:>> > *Reply-To: *"[email protected] <javascript:>" < > [email protected] <javascript:>> > *Date: *Friday, 23 December 2016 at 12:25 > *To: *Swagger <[email protected] <javascript:>> > *Subject: *Re: Cant locate swagger.json on java + embedded jetty + > httpservlet + swagger integration > > > > Thanks Ron. > > > > Last night I double-checked and made sure I had no jersey > resources/dependencies in my code. I also looked through the github project > link you posted and imitated his dependencies and method calls without > using the web.xml ( I really want to avoid web.xml as a number of the > existing projects I have run as jars with embedded jetty's and no web.xml). > The two things I'm faced with now are: > > 1. Adding multiple packages(separated by a comma or semi-colon) as a > resource through the Servlet.setInitParam() method does not work. Multiple > packages delimited by a comma or otherwise result in the default > *{"swagger":"2.0","info":{"version":"1.0.0","title":""}} > *response. > 2. Secondly, I think I still have an issue in how Swagger scans my > project. When I do get the swagger.json to display my annotations, it only > captures the information in the @Info annotation on my servlet. Anything > withing the @Api, @ApiOperation, @ApiResponses, @ApiModel are effectively > ignored. Unless I'm mistaken, all of these are supposed to show up in the > swagger.json output right? Or do I have to browse to another path to view > those annotations too? I seen some posts use the path > http://<host>:<port>/swagger-api/<servlet_name> but that does not work for > me > > Here is what my code for the swagger servlet initialization and > configuration looks like now. The custom servlet class I posted above > remains largely the same. > > import org.apache.log4j.Logger; > import org.eclipse.jetty.server.Server; > import org.eclipse.jetty.servlet.ServletContextHandler; > import org.eclipse.jetty.servlet.ServletHolder; > import io.swagger.servlet.listing.ApiDeclarationServlet; > import io.swagger.servlet.config.DefaultServletConfig; > . > . > . > logger.info("Initializing user profile server..."); > new UserDao(); > Server server = new Server(Integer.parseInt(properties.getProperty(Config > .JETTY_SERVICE_PORT))); > ServletContextHandler servletContextHandler = new ServletContextHandler( > ServletContextHandler.SESSIONS); > servletContextHandler.setContextPath("/"); > server.setHandler(servletContextHandler); > > > //Custom servlet > ServletHolder apiservlet = servletContextHandler.addServlet( > ProfileServlet.class, "/user/*"); > apiservlet.setInitOrder(3); > logger.info("User profile server initialized."); > > > // Swagger servlet reader > ServletHolder swaggerServlet = servletContextHandler.addServlet( > DefaultServletConfig.class, "/swagger-core"); > swaggerServlet.setInitOrder(2); > swaggerServlet.setInitParameter("api.version", "1.0.0"); > //swaggerServlet.setInitParameter("swagger.resource.package", > "com.coreservices.servlets,com.coreservices.datatypes"); NOTE::THIS DOES > NOT WORK > swaggerServlet.setInitParameter("swagger.resource.package", > "com.coreservices.servlets"); > swaggerServlet.setInitParameter("swagger.api.basepath", " > http://localhost:7000"); > > > // Swagger api declaration > servletContextHandler.addServlet(ApiDeclarationServlet.class, "/api/*"); > return server; > } > > > > Thanks once again for the help. > > > > > > On Thursday, 22 December 2016 17:57:48 UTC-5, Ron wrote: > > Huh, I misread it as you using jersey. You need to use a different > dependency then and a different set up process. > > We don’t really have documentation for it, but there’s a sample - > https://github.com/swagger-api/swagger-samples/tree/master/java/java-servlet > > > > > > > > > > *From: *<[email protected]> on behalf of janet vanderpuye < > [email protected]> > *Reply-To: *"[email protected]" < > [email protected]> > *Date: *Thursday, 22 December 2016 at 14:39 > *To: *Swagger <[email protected]> > *Subject: *Re: Cant locate swagger.json on java + embedded jetty + > httpservlet + swagger integration > > > > Oh ok. Maybe I need to read up a bit on Jax-rs but I believe application > was built using only servlets. I had only the Bootstrap class and > ProfileServlets class, which were written using HttpServlets. Unless one of > the default package imports was built on Jax-rs. Thanks for the tip, I will > double check for that. > > On Thursday, 22 December 2016 17:30:02 UTC-5, Ron wrote: > > What I’m saying is that you can’t use swagger-core for both jax-rs > resources and servlets in a single app. > > > > > > > > *From: *<[email protected]> on behalf of janet vanderpuye < > [email protected]> > *Reply-To: *"[email protected]" < > [email protected]> > *Date: *Thursday, 22 December 2016 at 14:26 > *To: *Swagger <[email protected]> > *Subject: *Re: Cant locate swagger.json on java + embedded jetty + > httpservlet + swagger integration > > > > Ok thanks. > > > > On a quick scan > > -- You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
