I was able to integrate Spring Cloud Gateway with the Springdoc OpenAPI in an small application with an architecture oriented to microservices. But now, when I open the Swagger UI to test the endpoint of my controller (StudentController) I realized that the @RequestMapping at the root level of the controller is not included in the URL of the endpoint to test. The routes definition are the following:
routes:
- id: students-service
uri: lb://STUDENTS-SERVICE
predicates:
- Path=/students/**
filters:
- RewritePath=/students/(?<path>.*), /$\{path}
- id: openapi
uri: http://localhost:${server.port}
predicates:
- Path=/v3/api-docs/**
filters:
- RewritePath=/v3/api-docs/(?<path>.*), /$\{path}/v3/api-docs
And the StudentController is the following:
@RestController
@RequestMapping("/api/v1")
@Tag(name = "Students")
public class StudentQueryController {
@GetMapping("/message")
public String dummyGet() {
return "Student Service Dummy GET";
}
}
In the Swagger UI I expected to get the URL like "http://localhost:8060/students/api/v1/message", but I got "http://localhost:8060/api/v1/message".
Someone would be kind to help me with this issue, please? Thanks in advance.