Hi Guys, 

Happy new year. I have a committed the problematic code here 
<https://github.com/rhycce/swaggersample.git> 
(https://github.com/rhycce/swaggersample.git) 
as requested. I would be grateful if you could check it out and help me 
resolve it.

This is the current output I have from swagger when I run it. As you can 
see, there is no documentation included from the portions annotated @Api, 
@ApiParam, etc only the annotations described within the @Info section.

{
  "swagger": "2.0",
  "info": {
    "description": "Servlet that handles basic CRUD operations to the user 
profile data source",
    "version": "1.0.0",
    "title": "User Profile Servlet",
    "termsOfService": "XYZ",
    "contact": {
      "name": "XYZ",
      "url": "XYZ",
      "email": "XYZ"
    },
    "license": {
      "name": "XYZ",
      "url": "XYZ"
    }
  },
  "host": "localhost:7000",
  "basePath": "/",
  "tags": [
    {
      "name": "users",
      "description": "CRUD operations on user datatype"
    }
  ],
  "schemes": [
    "http",
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ]
}



Thanks a lot. All help appreciated.

On Tuesday, 27 December 2016 17:46:10 UTC-5, Ron wrote:
>
> At this point, I’d ask that you provide a sample app that reproduces it – 
> would be difficult to try and debug it otherwise.
>
>  
>
>  
>
>  
>
> *From: *<[email protected] <javascript:>> on behalf of janet 
> vanderpuye <[email protected] <javascript:>>
> *Reply-To: *"[email protected] <javascript:>" <
> [email protected] <javascript:>>
> *Date: *Tuesday, 27 December 2016 at 14:36
> *To: *Swagger <[email protected] <javascript:>>
> *Subject: *Re: Cant locate swagger.json on java + embedded jetty + 
> httpservlet + swagger integration
>
>  
>
> Yeah, that is what I have now. I have commented out the part where I use 
> the multipackages. When I use one package, it partially works. I get only 
> the data within the @Info annotations but nothing from the @API annotations.
>
> On Tuesday, 27 December 2016 17:05:29 UTC-5, Ron wrote: 
>
> For the ‘resource scanning’ that is.
>
>  
>
>  
>
> *From: *<[email protected]> on behalf of Ron Ratovsky <
> [email protected]>
> *Reply-To: *"[email protected]" <
> [email protected]>
> *Date: *Tuesday, 27 December 2016 at 14:04
> *To: *"[email protected]" <[email protected]>
> *Subject: *Re: Cant locate swagger.json on java + embedded jetty + 
> httpservlet + swagger integration
>
>  
>
> Okay, since you mentioned using two packages isn’t working, what happens 
> if you only set com.coreservices.servlet for the resource packing?
>
>  
>
>  
>
>  
>
> *From: *<[email protected]> on behalf of janet vanderpuye <
> [email protected]>
> *Reply-To: *"[email protected]" <
> [email protected]>
> *Date: *Tuesday, 27 December 2016 at 13:06
> *To: *Swagger <[email protected]>
> *Subject: *Re: Cant locate swagger.json on java + embedded jetty + 
> httpservlet + swagger integration
>
>  
>
> Maybe. Here is what I have so far. 
>
>  
>
> Main.java
>
> 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;
>
>  
>
>  
>
>  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");
>
>         
> swaggerServlet.setInitParameter("swagger.resource.package","com.coreservices.servlets");
>
>         swaggerServlet.setInitParameter("swagger.api.basepath", "
> http://localhost:7000";);
>
>  
>
>         // Swagger api declaration
>
>         servletContextHandler.addServlet(ApiDeclarationServlet.class, 
> "/api/*");
>
>         server.start();
>
>  
>
> ProfileServlet.java /**custom httpservlet class**/
>
> import io.swagger.annotations.*;
>
> import org.apache.log4j.Logger;
>
>  
>
> import javax.servlet.ServletException;
>
> import javax.servlet.http.HttpServlet;
>
> import javax.servlet.http.HttpServletRequest;
>
> import javax.servlet.http.HttpServletResponse;
>
>  
>
> /**
>
>  * Created on 12/21/2016.
>
>  */
>
> @SwaggerDefinition(
>
>    info = @Info(
>
>            title = "User Profile Servlet",
>
>            version = "1.0.0",
>
>            description = "Servlet that handles basic CRUD operations to 
> the user profile data source",
>
>            contact = @Contact(name = "XYZ", email = "XYZ", url = "XYZ"),
>
>            termsOfService = "XYZ",
>
>            license = @License(name = "XYZ", url = "XYZ")
>
>    ),
>
>         basePath = "/",
>
>         consumes = {"application/json"},
>
>         produces = {"application/json"},
>
>         schemes = {SwaggerDefinition.Scheme.HTTP, 
> SwaggerDefinition.Scheme.HTTPS},
>
>         tags = {@Tag(name = "users", description = "CRUD operations on 
> user datatype")}
>
> )
>
> @Api(value = "/user", description = "performs CRUD operations on a user 
> profile")
>
> public class ProfileServlet extends HttpServlet {
>
>     Logger logger = Logger.getLogger(ProfileServlet.class.getSimpleName());
>
>  
>
>     @ApiOperation(httpMethod = "GET", value = "Returns a [list of the] 
> user profile datatype", notes = "", response = UserDatatype.class, nickname 
> = "getUser", tags = ("User"))
>
>     @ApiResponses(value = {
>
>             @ApiResponse(code = 200, message = "Succssful retrieval of 
> user profiles", response = UserDatatype.class),
>
>             @ApiResponse(code = 500, message = "Internal server error")
>
>     })
>
>     @ApiImplicitParams({
>
>             @ApiImplicitParam(name = "id", value = "profile id", required 
> = false, dataType = "String", paramType = "query"),
>
>             @ApiImplicitParam(name = "firstname", value = "First name of 
> user", required = false, dataType = "String", paramType = "query"),
>
>             @ApiImplicitParam(name = "lastname", value = "Last name of 
> user", required = false, dataType = "String", paramType = "query"),
>
>             @ApiImplicitParam(name = "phone", value = "phone number of 
> user", required = false, dataType = "String", paramType = "query"),
>
>             @ApiImplicitParam(name = "signup", value = "Sign up date of 
> user, in dd-MM-yyyy forma", required = false, dataType = "java.sql.Date", 
> paramType = "query")
>
>     })
>
>     @Override
>
>     protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
> throws ServletException, IOException {
>
>         RpcLogTemplate logTemplate = new 
> RpcLogTemplate(req.getRemoteHost(),req.getParameter("client"), 
> req.getParameter("clientapp"), Config.localhost, Config.SERVICE_INSTANCE, 
> Config.SERVICE_APP, req.getParameterMap(), req.getRequestURI(),  new 
> Date().getTime() );
>
>         logger.debug("Received request: GET");
>
>         logger.debug("Request URI: " + req.getRequestURI());
>
>         logger.debug("Request servlet path: " + req.getServletPath());
>
>         handleGet(req, resp, logTemplate);
>
>         logTemplate.setResponseTimestamp(new Date().getTime());
>
>         logTemplate.setResponseCode(Integer.toString(resp.getStatus()));
>
>         Main.loggerService.addLog(logTemplate);
>
>     }
>
> }
>
>
> Finally the dependencies in my pom file
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <project xmlns="http://maven.apache.org/POM/4.0.0";
>
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>
>          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
> http://maven.apache.org/xsd/maven-4.0.0.xsd";>
>
>     <modelVersion>4.0.0</modelVersion>
>
>  
>
>     <groupId>com.coreservice.dataservice</groupId>
>
>     <artifactId>ServiceUserProfile</artifactId>
>
>     <version>1.0-SNAPSHOT</version>
>
>     <packaging>jar</packaging>
>
>     <properties>
>
>         <jetty.version>9.4.0.v20161208</jetty.version>
>
>     </properties>
>
>     <dependencies>
>
>         <dependency>
>
>             <groupId>log4j</groupId>
>
>             <artifactId>log4j</artifactId>
>
>             <version>1.2.17</version>
>
>         </dependency>
>
>         <!--Jetty dependencies start -->
>
>         <dependency>
>
>             <groupId>org.eclipse.jetty</groupId>
>
>             <artifactId>jetty-server</artifactId>
>
>             <version>${jetty.version}</version>
>
>         </dependency>
>
>         <dependency>
>
>             <groupId>org.eclipse.jetty</groupId>
>
>             <artifactId>jetty-servlet</artifactId>
>
>             <version>${jetty.version}</version>
>
>         </dependency>
>
>         <dependency>
>
>             <groupId>io.swagger</groupId>
>
>             <artifactId>swagger-annotations</artifact
>
>

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

Reply via email to