75

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?

0

4 Answers 4

110

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

0
43

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

http://swagger.io/

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

6
  • Thanks @dankohn. I'm checking it out.
    – Nam Nguyen
    Commented Sep 5, 2013 at 4:49
  • 11
    Do 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.
    – BillyTom
    Commented 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
  • 6
    Most 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
3

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

1
  • Looks great, did you ever run into any issues while using this? Commented Sep 4, 2023 at 12:27
3

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/

Not the answer you're looking for? Browse other questions tagged or ask your own question.