node.js - 如何在浏览器中访问 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.
解决方案
最后我得到了网址,它是 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));
谢谢大家
推荐阅读
- r - 带有 geom_raster ggplot2 的辅助轴
- python - Pip 错误:ModuleNotFoundError:没有名为“pip”的模块
- javascript - 在 React 高阶组件中传播 props
- bevy - 有没有办法访问 Bevy 中的相机缓冲区?
- reactjs - 如何使用 react-native-gl-image-filters 库包含/调整裁剪的相机图像?
- python - 视图 mysiteapp.views.addpost 没有返回 HttpResponse 对象。它返回 None 而不是
- android - 使用 allinone sdk 进行支付交易时发生 Paytm “networkError”
- powershell - 在 Powershell 中更改导出的 CSV 文件中的条目和列
- python - 清除字段后,文本输入字段会导致 chrome selenium 崩溃
- python - 在 self.__init__() 方法中使用 getpass() 失败,但在功能上使用时工作正常。为什么是这样?