How to change basePath for Springfox Swagger 2.0

前端 未结 3 1603
Happy的楠姐
Happy的楠姐 2021-02-05 03:16

I\'m running a service, where Swagger UI is accessible at:

http://serviceURL/swagger-ui.html

However, it is behind a proxy, such as:

         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 03:38

    @Bean
    public Docket newsApi(ServletContext servletContext) {
        return new Docket(DocumentationType.SWAGGER_2).pathProvider(new RelativePathProvider(servletContext) {
            @Override
            public String getApplicationBasePath() {
                return "/serviceName" + super.getApplicationBasePath();
            }
        }).host("proxyURL");
    }
    

提交回复
热议问题