Node.js 或 Express.js REST API 文档生成器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18626191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 15:30:36  来源:igfitidea点击:

Node.js or Express.js REST API document generator

node.jsexpress

提问by Nam Nguyen

I'm working on a restAPI using Express.js and I'm wondering if there is a way for me to generate API documents that allow a user to view API definitions or possibly even try out the API call?

我正在使用 Express.js 处理 restAPI,我想知道是否有办法生成允许用户查看 API 定义甚至可能尝试 API 调用的 API 文档?

采纳答案by Dan Kohn

Swagger is an amazing project for auto generating API documentation. It includes an Express module.

Swagger 是一个很棒的自动生成 API 文档的项目。它包括一个 Express 模块。

http://swagger.io/

http://swagger.io/

https://github.com/wordnik/swagger-node-express

https://github.com/wordnik/swagger-node-express

回答by blamb

What you are looking for is a good JavaScript documentation generator. I found a decent one here http://apidocjs.com/example/. This will allow you to use just Express as OP asked.

您正在寻找的是一个好的 JavaScript 文档生成器。我在这里找到了一个不错的http://apidocjs.com/example/。这将允许您按照 OP 的要求仅使用 Express。

Swagger isn't for generatingdocs, it's for makingAPIs. So you are going to need to learn a full system to get that feature.

Swagger 不是用于生成文档,而是用于制作API。因此,您将需要学习一个完整的系统才能获得该功能。

I found a couple more here that I haven't fully looked into yet which seem promising:
Docco hereJSDoc hereand an article on Documentor for Node

我在这里找到了一些我还没有完全研究过的东西,它们看起来很有希望:
Docco hereJSDoc here一篇关于 Documentor for Node 的文章

回答by Marcos Pereira

I found this library to be very useful when it comes to keeping your documentation and route declaration logic close together:

我发现这个库在将文档和路由声明逻辑紧密结合在一起时非常有用:

https://www.npmjs.com/package/swagger-jsdoc

https://www.npmjs.com/package/swagger-jsdoc