在 Debian 上排查 Swagger(OpenAPI)相关错误,通常要结合你用的具体技术栈(Swagger UI、Springfox、springdoc-openapi、FastAPI、Node 等)。下面按通用排查思路 + 常见场景来说明。
在 Debian 上常见有:
不同场景排查重点不同。
journalctl -u your-service -f
# 或
tail -f /var/log/your-app.log
重点关注:
curl -I http://localhost:8080/swagger-ui.html
curl -I http://localhost:8080/v3/api-docs
看:
/v3/api-docs 是否 200依赖
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
</dependency>
常见错误
访问 /swagger-ui.html 404
→ 用 /swagger-ui/index.html
空白页
→ 检查:
springdoc.api-docs.path=/v3/api-docs
springdoc.swagger-ui.path=/swagger-ui.html
启动报错 Failed to load API definition
→ 注解写错(@Schema、@Operation)
⚠️ Springfox 已不维护,常见问题:
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
uvicorn main:app --reload
访问:
/docs
/openapi.json
错误排查:
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(spec));
常见错误:
ufw status
location /swagger-ui/ {
proxy_pass http://127.0.0.1:8080;
}
getenforce
/v3/api-docs 是否返回 JSON如果你能告诉我:
我可以直接帮你定位到具体原因和修复命令。