When I hit http://localhost:3001/api-docs loads the swagger json docs.
{
swagger: "2.0",
info: {
version: "1.0.0",
title: "Auth-gateway services",
contact: {
name: "swagger docs",
url: "https://www.google.com"
}
},
host: "127.0.0.1:3001",
basePath: "/",
...
}
但是如何为我的API加载http://petstore.swagger.io/之类的UI。
答案 0 :(得分:0)
要通过swagger-ui查看api,请执行以下操作之一。
选项1:使用在线swagger-ui
选项2:在本地设置swagger-ui项目
您必须设置swagger-ui。您可以使用以下提供的说明克隆项目设置。
Windows Users: Please install Python before follow below guidelines
for node-gyp rebuild to run.
1. npm install
2. npm run build
3. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
Development
Use npm run serve to make a new build, watch for changes, and serve the result at http://localhost:8080/.
现在你应该可以看到与online swagger-ui完全相同的内容。
与选项1一样,提供swagger-json url并查看生成的swagger-ui。