在 Debian 系统上“导入 Swagger”通常指两种情况之一:
下面分别说明常见做法。
sudo apt update
sudo apt install docker.io -y
sudo systemctl enable --now docker
docker run -p 8080:8080 \
-e SWAGGER_JSON=/foo/swagger.json \
-v /path/to/swagger.json:/foo/swagger.json \
swaggerapi/swagger-ui
浏览器访问:
http://<debian-ip>:8080
sudo apt install nginx git -y
git clone https://github.com/swagger-api/swagger-ui.git
sudo cp -r swagger-ui/dist/* /var/www/html/
把你的 swagger.json 放到:
/var/www/html/swagger.json
修改:
nano /var/www/html/swagger-initializer.js
改为:
url: "/swagger.json"
访问:
http://<debian-ip>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.3.0</version>
</dependency>
访问:
http://localhost:8080/swagger-ui.html
npm install swagger-ui-express
const swaggerUi = require('swagger-ui-express');
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(require('./swagger.json')));
pip install fastapi uvicorn
FastAPI 自带 Swagger:
http://localhost:8000/docs
swagger.json 或 openapi.yaml如果你能说明:
我可以给你更精确的命令。