我有一个简单的启动应用程序,其中添加了 open api swagger 依赖项
springdoc-openapi-ui
以及这些属性
springdoc.swagger-ui.disable-swagger-default-url=true
springdoc.swagger-ui.configUrl=/v3/api-docs/swagger-config
springdoc.swagger-ui.path=/swagger-ui.html
我收到这些错误(调用 http://localhost:8080/swagger-ui/index.html 时):
No API definition provided.
这是我的控制器:
@RestController
public class HelloWorld {
@GetMapping("sayHi")
public String sayHi(){
return "Hi Beno";
}
}
有什么想法吗?
当使用不同的端点来服务 OpenAPI 配置时,您需要设置两个属性
// This will set UI to fetch the config's URL from "somePath"
springdoc.swagger-ui.configUrl=somePath
// You also need to serve the config file from the endpoint at "somePath"
springdoc.api-docs.path=somePath
由于您已将路径设置为
springdoc.swagger-ui.path=/swagger-ui.html
您需要访问该网站: http://localhost:8080/swagger-ui.html