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?
4 Answers
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.
Swagger isn't for generating docs, it's for making APIs. So you are going to need to learn a full system to get that feature.
I found a couple more here that I haven't fully looked into yet which seem promising:
Docco here JSDoc here and an article on Documentor for Node
Swagger is an amazing project for auto generating API documentation. It includes an Express module.
-
-
11Do these auto generate based on routes configured in express? Commented Dec 22, 2014 at 21:00
-
1@lostintranslation AFAIK they don't. Swagger documentation is saved in yml files.– BillyTomCommented Jun 3, 2016 at 11:49
-
@UbaidAzad I updated the link to swagger.io, it should be visible on the answer once the edit is peer reviewed. Commented May 14, 2018 at 18:14
-
6Most of these tools require generating a new project and or completely scaffolding, very useful for the beginning of a project, their generation seems useless for a project that already exists. Commented May 14, 2019 at 17:15
I found this library to be very useful when it comes to keeping your documentation and route declaration logic close together:
-
Looks great, did you ever run into any issues while using this? Commented Sep 4, 2023 at 12:27
If you use Postman while developing you might already have a Postman collection containing the most relevant calls. If that is the case Postman has a docs feature https://learning.postman.com/docs/publishing-your-api/documenting-your-api/