npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

openapi-express-ts

v1.0.1

Published

OpenAPI documentation generator for Express Typescript applications

Readme

openapi-express-ts

A TypeScript library for generating OpenAPI documentation from Express class controllers.

Installation

npm install openapi-express-ts

TypeScript Configuration

Ensure your tsconfig.json has the following options enabled:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

Features

  • TypeScript decorators for Express controllers and routes
  • Automatic OpenAPI 3.0.0 documentation generation
  • Support for route parameters, request body, and responses
  • Customize API documentation with descriptions, tags, and schemas
  • Built-in Swagger UI integration
  • Type-safe parameter and response definitions
  • Automatic request/response schema generation from TypeScript types

Usage

Basic Example

import { Controller, Get, Post } from 'openapi-express-ts';
import express from 'express';
import * as swaggerUi from 'swagger-ui-express';

// Define your data types
class User {
  id: number;
  name: string;
  email: string;
}

class CreateUserDto {
  name: string;
  email: string;
}

// Create a controller with decorators
@Controller('/users', {
  description: 'User management endpoints',
  tags: ['Users']
})
class UserController {
  @Get('/')
  getUsers(): User[] {
    // Implementation
    return [];
  }

  @Post('/')
  createUser(body: CreateUserDto): User {
    // Implementation
    return { id: 1, ...body };
  }
}

// Set up Express app with Swagger UI
const app = express();

const apiDoc = generateOpenAPISpec({
  title: 'User Management API',
  version: '1.0.0',
  description: 'API for managing users in the system',
  servers: [
    {
      url: 'http://localhost:3000',
      description: 'Development server'
    }
  ]
});

Available Decorators

@Controller(path: string, options?: ControllerMetadata)

Marks a class as an Express controller with a base path.

interface ControllerMetadata {
  description?: string;  // Controller description in OpenAPI docs
  tags?: string[];      // OpenAPI tags for grouping endpoints
}

Route Decorators

  • @Get(path: string, options?: RouteMetadata)
  • @Post(path: string, options?: RouteMetadata)
  • @Put(path: string, options?: RouteMetadata)
  • @Delete(path: string, options?: RouteMetadata)
  • @Patch(path: string, options?: RouteMetadata)

Each route decorator accepts a path and optional metadata:

interface RouteMetadata {
  description?: string;  // Route description in OpenAPI docs
  summary?: string;      // Brief summary of the route
  tags?: string[];      // Additional OpenAPI tags
}

OpenAPI Configuration

When generating the OpenAPI documentation, you can configure various aspects:

interface OpenAPIOptions {
  title: string;         // API name
  version: string;       // API version
  description?: string;  // API description
  base?: string          // application base prefix url e.g `/api/v1`
  servers?: Array<{      // Server configurations
    url: string;
    description?: string;
  }>;
}

Best Practices

  1. Use TypeScript interfaces to define request/response types
  2. Group related endpoints using controller tags
  3. Provide clear descriptions for endpoints and parameters
  4. Use meaningful HTTP status codes in @ApiResponse decorators
  5. Configure servers array for different environments

License

MIT