在 Debian 上“调试 Swagger 接口”通常分几种场景,我按最常见用法给你说明,你可以对号入座。
如果你的服务在 Debian 上运行,例如:
http://ip:8080/swagger-ui.htmlhttp://ip:8000/docshttp://ip:3000/api-docs在浏览器直接打开即可。
⚠️ 如果打不开:
curl http://localhost:8080/swagger-ui.html
ss -lntp | grep 8080
或
netstat -lntp | grep 8080
sudo ufw status
开放端口:
sudo ufw allow 8080
curl -X GET "http://localhost:8080/api/users" \
-H "Authorization: Bearer token"
带 JSON:
curl -X POST "http://localhost:8080/api/login" \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"123456"}'
sudo apt install httpie
http GET http://localhost:8080/api/users
http POST http://localhost:8080/api/login username=admin password=123456
curl http://localhost:8080/v3/api-docs
或
curl http://localhost:8080/swagger/v1/swagger.json
确认:
Access to fetch blocked by CORS
curl -i http://localhost:8080/v3/api-docs
看 HTTP 状态码。
sudo apt install mitmproxy
mitmproxy
浏览器设代理,看请求/响应。
常见命令:
journalctl -u your-service -f
或:
tail -f /var/log/your-app.log
✅ 最实用:
我可以直接给你针对性命令。