Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express API Documentation Generator

Generate interactive API documentation for your Express.js applications.

Table of Contents

Installation

You can install this package using npm:

npm install express-api-doc-generator

API Documentation Format

Your API documentation should follow a specific format using JSDoc comments:

@route: Specifies the HTTP method and route path.
@description: Provides a description of the API endpoint.
@param: Describes parameters required by the route.
@returns: Explains what the route returns.
@throws: Specifies any errors or exceptions that might occur.

Demo express endpoints

/**
 * @route GET /api/users
 * @description Get a list of users.
 * @returns {Array<User>} List of user objects.
 * @throws {Error} If there's an error while fetching users.
 */
app.get("/api/users", (req, res) => {
  //
});

/**
 * @route POST /api/users
 * @description Create a new user.
 * @param {User} user - The user object to create.
 * @returns {User} The created user.
 * @throws {Error} If there's an error while creating the user.
 */
app.post("/api/users", (req, res) => {
  //
});

Generating Documentation

To generate documentation, use the express-api-doc-generator package. It will extract JSDoc comments from your Express application and create a PDF document with the API documentation.

Example Usage

Here's a minimal example of how to use this package:

const generateDocumentation = require("express-api-doc-generator");
const outputPath = "api-documentation.pdf";

generateDocumentation("./app.js", outputPath)
  .then(() => {
    console.log("API documentation generated successfully.");
  })
  .catch((error) => {
    console.error("Error generating documentation:", error);
  });

Contributing

Contributions are welcome! If you'd like to improve this package or report issues, please open an issue or submit a pull request on GitHub.

About

create api documentation from comments

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages