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

@sklv-labs/ts-core

v0.1.0

Published

Core TypeScript package for sklv-labs

Readme

@sklv-labs/ts-nestjs-openapi

A comprehensive OpenAPI package for NestJS applications with support for both Swagger UI and Scalar API Reference. This package provides a clean, type-safe API for setting up OpenAPI documentation in your NestJS projects.

Features

  • 🎯 Dual UI Support - Choose between Swagger UI or Scalar API Reference
  • 🔒 Authentication Support - Built-in support for Bearer token and Cookie authentication
  • 🎨 Theme Customization - Multiple themes available for both UI providers
  • 📦 Type-Safe - Full TypeScript support with comprehensive type definitions
  • 🚀 Easy Setup - Simple API for both synchronous and asynchronous configuration
  • 🛠️ NestJS Native - Built on top of @nestjs/swagger with seamless integration

Installation

npm install @sklv-labs/ts-nestjs-openapi

Peer Dependencies

This package requires the following peer dependencies:

npm install @nestjs/common@^11.1.11 @nestjs/core@^11.1.11 @nestjs/swagger@^11.2.4

For Scalar support (optional):

npm install @scalar/nestjs-api-reference@^1.0.13 @scalar/[email protected]

Note: This package requires Node.js 24 LTS or higher.

Quick Start

Basic Setup with Swagger UI

// app.module.ts
import { Module } from '@nestjs/common';
import { OpenApiModule } from '@sklv-labs/ts-nestjs-openapi';

@Module({
  imports: [
    OpenApiModule.forRoot({
      title: 'My API',
      description: 'API Documentation',
      version: '1.0',
      path: 'api/docs',
    }),
  ],
})
export class AppModule {}

// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { OpenApiModule } from '@sklv-labs/ts-nestjs-openapi';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  
  OpenApiModule.setup(app, {
    title: 'My API',
    description: 'API Documentation',
    version: '1.0',
  });
  
  await app.listen(3000);
}
bootstrap();

Setup with Scalar

// app.module.ts
import { Module } from '@nestjs/common';
import { OpenApiModule } from '@sklv-labs/ts-nestjs-openapi';

@Module({
  imports: [
    OpenApiModule.forRoot({
      title: 'My API',
      description: 'API Documentation',
      version: '1.0',
      ui: 'scalar',
      path: 'api/docs',
      scalar: {
        theme: 'default',
      },
    }),
  ],
})
export class AppModule {}

Async Configuration

// app.module.ts
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { OpenApiModule } from '@sklv-labs/ts-nestjs-openapi';

@Module({
  imports: [
    ConfigModule.forRoot(),
    OpenApiModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        title: config.get('API_TITLE', 'My API'),
        description: config.get('API_DESCRIPTION', 'API Documentation'),
        version: config.get('API_VERSION', '1.0'),
        path: config.get('API_DOCS_PATH', 'api/docs'),
      }),
    }),
  ],
})
export class AppModule {}

Configuration Options

OpenApiModuleOptions

Base configuration options shared by all UI providers:

interface OpenApiModuleOptionsBase {
  /**
   * Base path for the API documentation (e.g., 'api/docs')
   * @default 'api/docs'
   */
  path?: string;

  /**
   * API title (required)
   */
  title: string;

  /**
   * API description
   */
  description?: string;

  /**
   * API version
   * @default '1.0'
   */
  version?: string;

  /**
   * Authentication configuration
   */
  auth?: {
    bearer?: {
      name?: string;
      description?: string;
    };
    cookie?: {
      name?: string;
      description?: string;
    };
  };
}

Swagger UI Options

interface OpenApiModuleOptionsWithSwaggerUI extends OpenApiModuleOptionsBase {
  /**
   * UI provider set to 'swagger-ui' or omitted (defaults to 'swagger-ui')
   */
  ui?: 'swagger-ui';

  /**
   * Swagger UI specific options
   */
  swaggerUI?: {
    theme?: 'dracula' | 'gruvbox' | 'nord-dark' | 'one-dark' | 'sepia' | 'universal-dark' | 'monokai';
    swaggerOptions?: {
      explorer?: boolean;
      jsonDocumentUrl?: string;
      [key: string]: unknown;
    };
  };
}

Scalar Options

interface OpenApiModuleOptionsWithScalar extends OpenApiModuleOptionsBase {
  /**
   * UI provider set to 'scalar'
   */
  ui: 'scalar';

  /**
   * Scalar specific options
   */
  scalar?: {
    theme?: 'alternate' | 'default' | 'moon' | 'purple' | 'solarized' | 'bluePlanet' | 'saturn' | 'kepler' | 'mars' | 'deepSpace' | 'laserwave' | 'none';
    scalarOptions?: {
      [key: string]: unknown;
    };
  };
}

Authentication

Bearer Token Authentication

OpenApiModule.forRoot({
  title: 'My API',
  auth: {
    bearer: {
      name: 'access-token',
      description: 'JWT access token',
    },
  },
});

Cookie Authentication

OpenApiModule.forRoot({
  title: 'My API',
  auth: {
    cookie: {
      name: 'refresh-token',
      description: 'Refresh token stored in cookie',
    },
  },
});

Both Bearer and Cookie

OpenApiModule.forRoot({
  title: 'My API',
  auth: {
    bearer: {
      name: 'access-token',
      description: 'JWT access token',
    },
    cookie: {
      name: 'refresh-token',
      description: 'Refresh token',
    },
  },
});

Decorators

ApiUuidProperty

A convenience decorator for UUID properties in DTOs:

import { ApiUuidProperty } from '@sklv-labs/ts-nestjs-openapi';

export class GetUserDto {
  @ApiUuidProperty()
  id: string;
}

This is equivalent to:

import { ApiProperty } from '@nestjs/swagger';

export class GetUserDto {
  @ApiProperty({
    example: '0c168cb5-d5e0-459c-9265-71b5aada4a7e',
    format: 'uuid',
    type: 'string',
  })
  id: string;
}

API Reference

OpenApiModule

forRoot(options: OpenApiModuleOptions): DynamicModule

Synchronously configure the OpenAPI module.

forRootAsync<TFactoryArgs>(options: OpenApiModuleAsyncOptions<TFactoryArgs>): DynamicModule

Asynchronously configure the OpenAPI module with dependency injection support.

setup(app: INestApplication, options: OpenApiModuleOptions): void

Setup OpenAPI UI for the given NestJS application. This should be called in your main.ts after app initialization.

Type Exports

The package exports all types for use in your application:

import type {
  OpenApiModuleOptions,
  OpenApiModuleOptionsWithSwaggerUI,
  OpenApiModuleOptionsWithScalar,
  OpenApiModuleAsyncOptions,
  OpenApiAuthConfig,
  ScalarOptions,
  OpenApiUIOptions,
  UIProvider,
} from '@sklv-labs/ts-nestjs-openapi';

Development

# Build
npm run build

# Lint
npm run lint

# Format
npm run format

# Test
npm run test

# Type check
npm run type-check

License

MIT © sklv-labs