{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1553","labels_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1553/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1553/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1553/events","html_url":"https://github.com/swagger-api/swagger-core/issues/1553","id":119024742,"number":1553,"title":"Embedded Jetty with Jersey and Swagger - no web.xml","user":{"login":"JennyMu","id":16031782,"avatar_url":"https://avatars.githubusercontent.com/u/16031782?v=3","gravatar_id":"","url":"https://api.github.com/users/JennyMu","html_url":"https://github.com/JennyMu","followers_url":"https://api.github.com/users/JennyMu/followers","following_url":"https://api.github.com/users/JennyMu/following{/other_user}","gists_url":"https://api.github.com/users/JennyMu/gists{/gist_id}","starred_url":"https://api.github.com/users/JennyMu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JennyMu/subscriptions","organizations_url":"https://api.github.com/users/JennyMu/orgs","repos_url":"https://api.github.com/users/JennyMu/repos","events_url":"https://api.github.com/users/JennyMu/events{/privacy}","received_events_url":"https://api.github.com/users/JennyMu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-26T11:17:11Z","updated_at":"2015-12-03T10:25:58Z","closed_at":null,"body":"I am using Jetty in a project to implement a web server. Currently, I programmatically add one servlet to support a RESTful API using Jersey. This all works fine.\r\nHowever I would also like to incorporate swagger for documentation of the API. For now I have a small example server which just produces text services. However swagger is not producing any documentation and I am not sure if I am using it correctly. \r\n\r\nBean Config Use:\r\n\r\n```java\r\nprivate static class Bootstrap extends HttpServlet {\r\n        @Override\r\n        public void init(ServletConfig config) throws ServletException {\r\n            super.init(config);\r\n            BeanConfig beanConfig = new BeanConfig();\r\n            beanConfig.setVersion(\"1.0.2\");\r\n            beanConfig.setSchemes(new String[]{\"http\"});\r\n            beanConfig.setHost(\"localhost:2008\");\r\n            beanConfig.setBasePath(\"/api\");\r\n            beanConfig.setResourcePackage(\"io.swagger.resources\");\r\n            beanConfig.setScan(true);\r\n        }\r\n    }\r\n```\r\nMain method which launches the jetty server:\r\n```java\r\npublic static void main(String[] args) {  \r\n        int port = 2008;  \r\n        Server jettyServer = new Server(port);\r\n        ServletHolder servletHolder =\r\n            new ServletHolder(\r\n                org.glassfish.jersey.servlet.ServletContainer.class);  \r\n        servletHolder.setInitParameter(\r\n        \t\"com.sun.jersey.config.property.resourceConfigClass\",\r\n        \t\"com.sun.jersey.api.core.PackagesResourceConfig\");  \r\n      \r\n        \r\n        servletHolder.setInitParameter(\r\n            ServerProperties.PROVIDER_PACKAGES,\r\n            \"rest.service, io.swagger.jaxrs.listing\"\r\n        );\r\n        ServletContextHandler context = \r\n            new ServletContextHandler(ServletContextHandler.SESSIONS);\r\n\r\n        context.setContextPath(\"/\");\r\n        context.addServlet(servletHolder, \"/*\");\r\n      \r\n\r\n        ServletHolder swaggerServlet = new ServletHolder(new \r\n\t\tBootstrap());\r\n        context.addServlet(swaggerServlet, \"/*\");\r\n        \r\n        jettyServer.setHandler(context);\r\n           \r\n      try {\r\n        \tjettyServer.start();  \r\n        \tjettyServer.join();  \r\n        } catch (Exception ex) {\r\n            System.exit(1);  \r\n        }  \r\n    }  \r\n```\r\n\r\nFinally my service is (very simple, just for testing for now)\r\n```java\r\npackage rest.service;\r\n\r\nimport javax.ws.rs.GET;\r\nimport javax.ws.rs.Path;\r\nimport javax.ws.rs.Produces;\r\nimport javax.ws.rs.core.MediaType;\r\nimport io.swagger.annotations.*;\r\n\r\n\r\n// Plain old Java Object\r\n\r\n// The class registers its methods for the HTTP GET request using the @GET annotation. \r\n// Using the @Produces annotation, it defines that it can deliver several MIME types,\r\n// text, XML and HTML. \r\n\r\n// The browser requests per default the HTML MIME type.\r\n\r\n//Sets the path to base URL + /hello\r\n@Api(value = \"myService\",\r\n     description = \"My Config Service API\",\r\n     produces = \"text/html\",\r\n     consumes = \"text/html\")\r\n@Path(\"api/hello\")\r\npublic class PlainTextSvc {\r\n\r\n  // This method is called if TEXT_PLAIN is request\r\n  @GET\r\n  @Produces(MediaType.TEXT_PLAIN)\r\n  public String sayPlainTextHello() {\r\n    return \"Hello Jersey from Plain Text Service\";\r\n  }\r\n\r\n  // This method is called if XML is request\r\n  @GET\r\n  @Produces(MediaType.TEXT_XML)\r\n  public String sayXMLHello() {\r\n    return \"<?xml version=\\\"1.0\\\"?>\" + \"<hello> Hello Jersey\" + \"</hello>\";\r\n  }\r\n\r\n  // This method is called if HTML is request\r\n  @GET\r\n  @Produces(MediaType.TEXT_HTML)\r\n  public String sayHtmlHello() {\r\n    return \"<html> \" + \"<title>\" + \"Hello Jersey\" + \"</title>\"\r\n        + \"<body><h1>\" + \"Hello Jersey\" + \"</body></h1>\" + \"</html> \";\r\n  }\r\n\r\n} \r\n```\r\n\r\nWhen I try to access http://localhost:2008/api/hello or  http://localhost:2008/api I get \r\nHTTP ERROR: 405\r\n\r\nProblem accessing /swagger.json. Reason:\r\n\r\n    HTTP method GET is not supported by this URL\r\n\r\n\r\nThis topic has probably been covered before so apologies in advance. \r\n"},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-core/issues/comments/161584971","html_url":"https://github.com/swagger-api/swagger-core/issues/1553#issuecomment-161584971","issue_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/1553","id":161584971,"user":{"login":"JennyMu","id":16031782,"avatar_url":"https://avatars.githubusercontent.com/u/16031782?v=3","gravatar_id":"","url":"https://api.github.com/users/JennyMu","html_url":"https://github.com/JennyMu","followers_url":"https://api.github.com/users/JennyMu/followers","following_url":"https://api.github.com/users/JennyMu/following{/other_user}","gists_url":"https://api.github.com/users/JennyMu/gists{/gist_id}","starred_url":"https://api.github.com/users/JennyMu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JennyMu/subscriptions","organizations_url":"https://api.github.com/users/JennyMu/orgs","repos_url":"https://api.github.com/users/JennyMu/repos","events_url":"https://api.github.com/users/JennyMu/events{/privacy}","received_events_url":"https://api.github.com/users/JennyMu/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T10:25:58Z","updated_at":"2015-12-03T10:25:58Z","body":"No, everything is under /api/. Is this a problem?"}}