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

nestjs-api-describe

v1.0.0

Published

Composite decorators for standardizing OpenAPI documentation and input validation in NestJS APIs

Readme

nestjs-api-describe

CI npm

Composite decorators for standardizing OpenAPI documentation and input validation in NestJS APIs.

Installation

pnpm add nestjs-api-describe

Peer dependencies

pnpm add @nestjs/common @nestjs/swagger class-validator class-transformer reflect-metadata

Quick Start

ControllerDescribe

A composite method decorator that combines HTTP method, Swagger documentation, auth metadata, and error responses in a single declaration.

import { Controller } from '@nestjs/common';
import { ControllerDescribe } from 'nestjs-api-describe';

@Controller('users')
export class UsersController {
  @ControllerDescribe({
    method: 'GET',
    path: ':id',
    summary: 'Get user by ID',
    description: 'Returns a single user by their unique identifier',
    responseType: UserResponseDto,
    errors: [404],
  })
  findOne(@Param('id') id: string) {
    return this.usersService.findOne(id);
  }

  @ControllerDescribe({
    method: 'POST',
    summary: 'Register a new user',
    responseType: UserResponseDto,
    isPublic: true,
    errors: [409],
  })
  register(@Body() dto: CreateUserDto) {
    return this.usersService.create(dto);
  }
}

Options

| Option | Type | Required | Default | Description | | -------------- | ---------------- | -------- | ------- | ---------------------------------------- | | method | HttpMethod | yes | | GET, POST, PUT, PATCH, DELETE | | path | string | no | '' | Route path | | summary | string | yes | | Swagger operation summary | | description | string | no | | Swagger operation description | | responseType | Type<unknown> | yes | | Response DTO class for Swagger | | isPublic | boolean | no | false | If true, skips auth decorators | | errors | number[] | no | [] | Additional HTTP error status codes |

Non-public routes automatically include 401 and 403 error responses and @ApiBearerAuth().

DtoDescribe

A composite property decorator that combines Swagger @ApiProperty, class-validator validators, and class-transformer transforms.

import { DtoDescribe } from 'nestjs-api-describe';

export class CreateUserDto {
  @DtoDescribe({
    description: 'User email address',
    type: 'email',
    example: '[email protected]',
  })
  email!: string;

  @DtoDescribe({
    description: 'Display name',
    type: 'string',
    minLength: 2,
    maxLength: 50,
  })
  name!: string;

  @DtoDescribe({
    description: 'User age',
    type: 'int',
    min: 0,
    max: 150,
  })
  age!: number;

  @DtoDescribe({
    description: 'User preferences',
    type: 'object',
    required: false,
  })
  preferences?: Record<string, unknown>;
}

Options

| Option | Type | Required | Default | Description | | ------------ | ---------------- | -------- | ------- | ---------------------------------- | | description| string | yes | | Swagger property description | | type | DtoType | yes | | Field type (see supported types) | | example | unknown | no | | Swagger example value | | required | boolean | no | true | Adds IsNotEmpty or IsOptional | | enum | object | no | | Enum object (for type: 'enum') | | isArray | boolean | no | | Marks as array in Swagger | | nested | Type<unknown> | no | | Nested DTO class | | minLength | number | no | | Min string length | | maxLength | number | no | | Max string length | | min | number | no | | Min numeric value | | max | number | no | | Max numeric value | | pattern | RegExp | no | | Regex pattern validation |

Supported types

| Type | Validators applied | | ------------ | ----------------------------------------- | | string | IsString, Length, Transform(trim) | | number | IsNumber, Min, Max | | int | IsInt, Min, Max | | boolean | IsBoolean | | uuid | IsUUID | | email | IsEmail, Transform(lowercase + trim) | | date | IsDate, Type(() => Date) | | dateString | IsDateString | | url | IsUrl | | enum | IsEnum | | nested | ValidateNested, Type(() => nested) | | array | IsArray, ValidateNested (if nested) | | object | IsObject |

ApiDescribeModule

Optional NestJS dynamic module for global configuration.

import { Module } from '@nestjs/common';
import { ApiDescribeModule } from 'nestjs-api-describe';

@Module({
  imports: [
    ApiDescribeModule.forRoot({
      defaultErrors: [400, 500],
      customErrorDescriptions: {
        400: 'Validation failed',
        500: 'Something went wrong',
      },
    }),
  ],
})
export class AppModule {}

License

MIT