SpringCloudGateway和springdoc openapi集成

ifsvaxew  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(823)

我能够将SpringCloudGateway与SpringDocOpenAPI集成在一个小型应用程序中,该应用程序的体系结构面向微服务。但是现在,当我打开swagger ui来测试我的控制器(studentcontroller)的端点时,我意识到控制器根级别的@requestmapping没有包含在要测试的端点的url中。路由定义如下:

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

学生控制器如下:

@RestController
@RequestMapping("/api/v1")
@Tag(name = "Students")
public class StudentQueryController {

    @GetMapping("/message")
    public String dummyGet() {
        return "Student Service Dummy GET";
    }
}

在 swagger 的用户界面中,我希望得到如下url“http://localhost:8060/students/api/v1/message“,但我得到了”http://localhost:8060/api/v1/message”。
有人能帮我解决这个问题吗?提前谢谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题