Dwex Logo
OpenAPI

Introduction

API documentation with OpenAPI and Scalar UI

OpenAPI Documentation

Dwex provides first-class support for OpenAPI (formerly Swagger) specification through the @dwex/openapi package. Generate beautiful, interactive API documentation with Scalar UI automatically from your code.

Features

  • Auto-generation: Automatically generates OpenAPI specs from your decorators
  • Scalar UI: Beautiful, modern API documentation interface
  • Type-Safe: Full TypeScript support with decorators
  • Customizable: Optional decorators for detailed control
  • NestJS-like: Familiar API for developers coming from NestJS

Installation

bun add @dwex/openapi

Quick Start

Setup OpenAPI documentation in your application:

main.ts
import { DwexFactory } from "@dwex/core";
import { DocumentBuilder, OpenApiModule } from "@dwex/openapi";
import { AppModule } from "./app.module";

const app = await DwexFactory.create(AppModule);

// Create OpenAPI configuration
const config = new DocumentBuilder()
  .setTitle("My API")
  .setDescription("API documentation")
  .setVersion("1.0")
  .addServer("http://localhost:9929")
  .addBearerAuth()
  .build();

// Generate OpenAPI document
const document = OpenApiModule.createDocument(app, config);

// Setup API documentation at /docs
OpenApiModule.setup("/docs", app, document);

await app.listen(9929);

Visit http://localhost:9929/docs to see your API documentation!

Next Steps