以下是在Debian上部署Swagger的最佳实践:
sudo apt install docker.io
,再docker pull swaggerapi/swagger-ui
,然后docker run -p 80:80 -d swaggerapi/swagger-ui
;也可使用npm安装(适用于Node.js环境),命令是sudo apt install nodejs npm
,再npm install -g swagger-ui-express
。swagger.yaml
或swagger.json
配置文件,定义API端点等信息。若用Spring Boot项目,可在pom.xml
添加依赖,如springdoc-openapi-starter-webmvc-ui
,并在配置类中设置文档生成规则。