Jsdoc Open ApiInstallation

Installation

Last updated:

Installation

Install jsdoc-open-api using your preferred package manager:

npm install @visulima/jsdoc-open-api

Optional Dependencies

The CLI requires additional packages:

npm install commander cli-progress

These are listed as optionalDependencies and may install automatically depending on your package manager.

For Webpack/Next.js

If using the Webpack plugin:

npm install webpack

Import

import jsdocOpenApi from "@visulima/jsdoc-open-api";
import { SwaggerCompilerPlugin } from "@visulima/jsdoc-open-api";

CommonJS

const jsdocOpenApi = require("@visulima/jsdoc-open-api");
const { SwaggerCompilerPlugin } = require("@visulima/jsdoc-open-api");

Subpath Imports

// CLI utilities
import { initCommand, generateCommand } from "@visulima/jsdoc-open-api/cli";

// Commander.js integration
import { program } from "@visulima/jsdoc-open-api/cli/commander";

Requirements

  • Node.js: 22.x or higher
  • Package Manager: npm, yarn, pnpm, or bun
  • Build Tools: Webpack 5.x (for plugin usage)

CLI Setup

After installation, the CLI is available:

# Using npx
npx jsdoc-open-api --help

# Using pnpm
pnpm exec jsdoc-open-api --help

# Using yarn
yarn jsdoc-open-api --help

Initialize configuration:

npx jsdoc-open-api init

This creates .openapirc.js:

module.exports = {
    definition: {
        openapi: "3.0.0",
        info: {
            title: "My API",
            version: "1.0.0",
        },
    },
    sources: ["./src/routes/**/*.js"],
    output: "./swagger.json",
};

Verification

Verify your installation by generating a simple spec:

// test-generation.js
import jsdocOpenApi from "@visulima/jsdoc-open-api";

const spec = await jsdocOpenApi({
    definition: {
        openapi: "3.0.0",
        info: {
            title: "Test API",
            version: "1.0.0",
        },
    },
    sources: ["./src/**/*.js"],
});

console.log("Paths:", Object.keys(spec.paths || {}));

Run it:

node test-generation.js
Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues