首页 > 解决方案 > 如何在浏览器中访问 swagger api 文档

问题描述

我正在使用 Node Js Express js 和 swagger,我用 swagger 编写了我的 api 文档,几个月前我曾经访问过。

 Now i do not remember the URL which i used to add to browser to read documentation, which i have written in swagger. Please help me finding that URL.

标签: node.jsexpressswagger

解决方案


最后我得到了网址,它是 http://localhost:6106/api-docs/ 我从这个页面得到了提示 https://www.npmjs.com/package/swagger-ui-express

Express setup app.js

const express = require('express');
const app = express();
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');

app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

谢谢大家


推荐阅读