can we move some swagger configuration from web.xml

前端 未结 2 725
攒了一身酷
攒了一身酷 2020-12-20 10:05

In swagger 1.2.9-1.2.3 or old versions we have config reader com.wordnik.swagger.jaxrs.ConfigReader class, we can extend this class and we can declare swagger

2条回答
  •  生来不讨喜
    2020-12-20 11:10

    There's a thread explaining how to do this on the Swagger google group.

    Basically, in Swagger 1.3, you need to use the SwaggerConfig class, like so:

    SwaggerConfig config = new SwaggerConfig();
    config.setBasePath(yourBasePathVariable);
    ConfigFactory.setConfig(config);
    

    However, you need this to occur after Swagger loads and sets the default basePath, because otherwise (if your basePath gets set first) it will be overwritten.

提交回复
热议问题