Swagger interface has wrong base path

I am using grape gem and SwaggerUI standalone installation . My API documentation is at http://example.com/api/v1/docs/ . SwaggerUI discovers all resources but sends all requests to http://example.com/v1/foo (missing "api /" from url). Why is this?

+3


source to share


2 answers


For documentation, if anyone is experiencing the same problem: There is a parameter for the grape-swagger method add_swagger_documentation

called base_path

. In my case, I had to specify



base_path: '/api'

      

+1


source


Had the same problem using maven with spring-boot ans swagger-ui 2.4.0. A possible incompatibility with other packages such as Thymelear regarding resource URLs could be causing this problem.

As a workaround, I could overcome the broken links by reassigning the url like this:



@Configuration
public class CustomResourceMapping extends WebMvcConfigurerAdapter  { 
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addRedirectViewController(
        "/configuration/ui", 
        "/swagger-resources/configuration/ui");
        registry.addRedirectViewController(
        "/configuration/security", 
        "/swagger-resources/configuration/security");
    }
}

      

0


source







All Articles