你这个问题里 “debian swagger” 有点模糊,我给你把几种最常见的情况都说明一下,你可以对照看看你指的是哪一种。
Swagger(现在叫 OpenAPI)通常用来:
它本身不是 Debian 专属工具,但在 Debian 上一样可以用。
如果你只是想在 Debian 上查看 / 使用 Swagger 文档:
docker run -p 8080:8080 swaggerapi/swagger-ui
浏览器访问:
http://localhost:8080
sudo apt update
sudo apt install -y git npm
git clone https://github.com/swagger-api/swagger-ui.git
cd swagger-ui
npm install
npm run build
部署(如用 nginx):
sudo cp -r dist /var/www/html/swagger
用于编写 swagger.yaml
docker run -p 8081:8080 swaggerapi/swagger-editor
访问:
http://localhost:8081
pip install fastapi uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.get("/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}
运行:
uvicorn main:app --reload
访问:
http://localhost:8000/docs
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.x.x</version>
</dependency>
访问:
http://localhost:8080/swagger-ui.html
npm install swagger-ui-express swagger-jsdoc
❌ Swagger 不是一个系统服务
❌ 不需要 apt install swagger
✅ 它是一个 API 规范 + 工具集
你可以补充一下你的场景,比如:
我可以直接给你一份针对你项目的完整配置示例。