{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-core/issues/2099","repository_url":"https://api.github.com/repos/swagger-api/swagger-core","labels_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/2099/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/2099/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/2099/events","html_url":"https://github.com/swagger-api/swagger-core/issues/2099","id":203331347,"node_id":"MDU6SXNzdWUyMDMzMzEzNDc=","number":2099,"title":"Using swagger with multiple API applications, swagger.json documents get mixed up","user":{"login":"kriegerkl","id":19669343,"node_id":"MDQ6VXNlcjE5NjY5MzQz","avatar_url":"https://avatars3.githubusercontent.com/u/19669343?v=4","gravatar_id":"","url":"https://api.github.com/users/kriegerkl","html_url":"https://github.com/kriegerkl","followers_url":"https://api.github.com/users/kriegerkl/followers","following_url":"https://api.github.com/users/kriegerkl/following{/other_user}","gists_url":"https://api.github.com/users/kriegerkl/gists{/gist_id}","starred_url":"https://api.github.com/users/kriegerkl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kriegerkl/subscriptions","organizations_url":"https://api.github.com/users/kriegerkl/orgs","repos_url":"https://api.github.com/users/kriegerkl/repos","events_url":"https://api.github.com/users/kriegerkl/events{/privacy}","received_events_url":"https://api.github.com/users/kriegerkl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2017-01-26T09:58:42Z","updated_at":"2019-04-04T11:55:50Z","closed_at":null,"author_association":"NONE","body":"We are running two separate Jersey APIs in the same server context, il.e. two separate classes extending com.sun.jersey.api.core.PackagesResourceConfig are configured in Tomcat 7's web.xml to be two accessible under two separate base paths. Simplified it's:\r\n\r\n<servlet>\r\n   <servlet-name>Api1</servlet-name>\r\n   <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>\r\n   <init-param>\r\n      <param-name>javax.ws.rs.Application</param-name>\r\n      <param-value>api1.server.config.Api1ServerConfig</param-value>\r\n   </init-param>\r\n</servlet>\r\n\r\n<servlet-mapping>\r\n   <servlet-name>Api1</servlet-name>\r\n   <url-pattern>/api1/*</url-pattern>\r\n</servlet-mapping>\r\n\r\n<servlet>\r\n   <servlet-name>Api2</servlet-name>\r\n   <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>\r\n   <init-param>\r\n      <param-name>javax.ws.rs.Application</param-name>\r\n      <param-value>api2.server.config.Api2ServerConfig</param-value>\r\n   </init-param>\r\n</servlet>\r\n\r\n<servlet-mapping>\r\n   <servlet-name>Api2</servlet-name>\r\n   <url-pattern>/api2/*</url-pattern>\r\n</servlet-mapping>  \r\n\r\nThe two APIs do not share any model classes or other code and are completely separate in every aspect incl security, filter chains etc.\r\nThere are two separate application.wadl files (and their corresponding XSD schema) generated by Jersey, each describing only the resources from their respective API.\r\n\r\nWe are using swagger in the first API, configuring it using BeanConfig:\r\n\r\nBeanConfig bc = new BeanConfig();\r\nbc.setVersion(\"1.0\");\r\nbc.setTitle(\" API1 Documentation\");\r\nbc.setSchemes(new String[]{\"https\"});\r\nbc.setBasePath(\"/appRoot/api1\");\r\nbc.setResourcePackage(\"api1.resource\");\r\nbc.setScan(true);\r\n\r\nNow we try to add Swagger to the second API as well, by declaring this in our Api2ServerConfig:\r\n\r\nBeanConfig bc = new BeanConfig();\r\nbc.setVersion(\"1.0\");\r\nbc.setTitle(\" API2 Documentation\");\r\nbc.setSchemes(new String[]{\"https\"});\r\nbc.setBasePath(\"/appRoot/api2\");\r\nbc.setResourcePackage(\"api2.resource\");\r\nbc.setScan(true);\r\n\r\nUnfortunately while this results in two separate swagger.json documents under\r\n/appRot/api1/swagger.json and /appRoot/api2/swagger.json, the two APIs are not treated separately as we had hoped.\r\n\r\nThe contents of whichever swagger document we access first after starting the server are fine. If we access /appRoot/api1/swagger.json, it contains all the paths and types of API1 and nothing from API2's realm. If however we next access /appRoot/api2/swagger.json, it lists both its own resources AND every tag, path and type definition from API1. Vice versa, if /appRoot/api2/swagger.json is accessed first and then appRoot/api1/swagger.json, API2's document is correct, but itself is now leaking into API1's swagger.json. The title and basePath are correct in both documents.\r\n\r\nIt is the same problem like in #1359.\r\nIt is not possible to have 2 BeanConfigs with 2 different BasePath."},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-core/issues/comments/479866994","html_url":"https://github.com/swagger-api/swagger-core/issues/2099#issuecomment-479866994","issue_url":"https://api.github.com/repos/swagger-api/swagger-core/issues/2099","id":479866994,"node_id":"MDEyOklzc3VlQ29tbWVudDQ3OTg2Njk5NA==","user":{"login":"frantuma","id":15786658,"node_id":"MDQ6VXNlcjE1Nzg2NjU4","avatar_url":"https://avatars3.githubusercontent.com/u/15786658?v=4","gravatar_id":"","url":"https://api.github.com/users/frantuma","html_url":"https://github.com/frantuma","followers_url":"https://api.github.com/users/frantuma/followers","following_url":"https://api.github.com/users/frantuma/following{/other_user}","gists_url":"https://api.github.com/users/frantuma/gists{/gist_id}","starred_url":"https://api.github.com/users/frantuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frantuma/subscriptions","organizations_url":"https://api.github.com/users/frantuma/orgs","repos_url":"https://api.github.com/users/frantuma/repos","events_url":"https://api.github.com/users/frantuma/events{/privacy}","received_events_url":"https://api.github.com/users/frantuma/received_events","type":"User","site_admin":false},"created_at":"2019-04-04T11:55:50Z","updated_at":"2019-04-04T11:55:50Z","author_association":"CONTRIBUTOR","body":"Generally in Swagger Core 2.0, you can achieve this using contexts and context ids, please check [wiki Context section](https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---Integration-and-Configuration#context), specifically the last example."}}
{"actor":{"display_login":"frantuma"}}