You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置springdoc-openapi-starter-webmvc-ui使用自定义fake_api.yml

解决Swagger UI加载自定义YAML文件的配置方案

1. 修改application.properties配置

关闭springdoc自动生成API文档的功能,同时指定Swagger UI加载自定义文件的路径:

springdoc.api-docs.enabled=false
springdoc.swagger-ui.url=/fake_api.yml
  • springdoc.api-docs.enabled=false:禁用自动生成的API文档,避免它覆盖你放在static目录下的自定义yaml文件
  • springdoc.swagger-ui.url=/fake_api.yml:明确指定Swagger UI要加载的自定义API文件路径

2. 确认自定义文件的可访问性

确保fake_api.yml放在src/main/resources/static目录下,启动应用后直接访问http://localhost:8080/fake_api.yml,应该能看到你手写的yaml原始内容,而非自动生成的JSON响应。

3. 验证配置效果

重启应用后打开http://localhost:8080/swagger-ui/index.html,Swagger UI将加载你自定义的API文档,不再显示"No operations defined in spec!"提示。

内容的提问来源于stack exchange,提问作者Chris Curvey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 14:54:51