Our team had some issues setting up swagger. We've been adding swagger to multiple services and for a strange reason, one service was not loading the swagger-ui.html. After some testing, we realize there was a conflict with some endpoint that were mapping to the root of the site:
1 2 3 4 5 6 7 8 | @RestController public class ReportController { @RequestMapping (method = RequestMethod.GET, value = "/{reportId}" ) public ResponseEntity getReport( @PathVariable String reportId) { .... } } |
After googling a lot, we ended up just making our request mapping more specific to a certain type of ids. In our case we are using mongo ids for the reports. It means ids can only have number or letters in lowercase.
1 2 3 4 5 6 7 8 | @RestController public class ReportController { @RequestMapping (method = RequestMethod.GET, value = "/{reportId:^[0-9a-f]+$}" ) public ResponseEntity getReport( @PathVariable String reportId) { .... } } |
Now because swagger-ui.html contains a dot (.) and a dash (-), the request is not being caught by this endpoint anymore.