-------------------------------------------- On Wed, 12/28/16, Shyju Karayi <[email protected]> wrote:
Subject: Re: Swagger Relative Basepath To: "Swagger" <[email protected]> Cc: [email protected] Date: Wednesday, December 28, 2016, 5:02 AM HiI have created a class as you mentioned and implemented doFilter method, but this method is not invoking while server starts. I have added the below config in web.xml <filter> <filter-name>apidoc-config</filter-name> <filter-class>com.test.servlet.SwaggerConfigFilter</filter-class> </filter> <filter-mapping> <filter-name>apidoc-config</filter-name> <url-pattern>/api-docs/*</url-pattern> </filter-mapping> and On Tuesday, April 29, 2014 at 12:59:00 PM UTC-5, Alexander Denissov wrote:If you need to dynamically figure out the basepath based on the external hostname where your app is deployed, you can write a servlet filter that will figure it out and then set it in the Swagger configuration. Inside the filter doFilter() method you can write: String contextPathUrl = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), filterConfig. getServletContext(). getContextPath()). toExternalForm();ConfigFactory.config(). setBasePath(contextPathUrl);Make sure this is done only once (remember state in a private static boolean) and apply filter mapping in your web.xml<filter> <filter-name>apidoc-config</fi lter-name> <filter-class>my.ApiDocConfigF ilter</filter-class> </filter> <filter-mapping> <filter-name>apidoc-config</fi lter-name> <url-pattern>/api-docs/*</url- pattern> </filter-mapping> -- 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. riasul entuziasm starnit de dubla alegere a lui Alexandru I.Cuza pretutindeni unde traiau romani nu putea in nici un fel sa ascunda situatia complexa in care se gasea noul stat. -- 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.
