Reputation: 1504
I am using the grape-swagger gem and the standalone installation of SwaggerUI. My API documentation is situated at http://example.com/api/v1/docs/. SwaggerUI discovers all resources, but sends all requests to http://example.com/v1/foo (missing 'api/' from the URL). Why is that?
Upvotes: 3
Views: 5278
Reputation: 3631
Had the same problem using maven with spring-boot ans swagger-ui 2.4.0. Probable incompatibilities with other packages like thymeleaf regarding resources urls might be responsible for the problem.
As a workaround, I could overcome the broken links by remapping 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");
}
}
Upvotes: 0
Reputation: 1504
For documentation if somebody experiences the same problem: There is a paramater for the grape-swagger method add_swagger_documentation
called base_path
. In my case, I had to specify
base_path: '/api'
Upvotes: 1