Adonis Open Swagger

Basic

Basic Configuration

You can edit config/swagger.ts to customize your API documentation.

config/swagger.ts
import { defineConfig } from "adonis-open-swagger";

/**
 * Configuration for Open Swagger
 */
export default defineConfig({
  /**
   * Enable or disable swagger documentation
   */
  enabled: true,

  /**
   * Path where the documentation will be served
   */
  path: "/docs",

  /**
   * Schema validator to use for automatic schema conversion
   * Choose based on your preferred validation library
   */
  validator: "vinejs", // 'vinejs' | 'zod' | 'typebox'

  /**
   * OpenAPI specification information
   */
  info: {
    title: "VoiceOps",
    version: "1.0.0",
    description: "API documentation for VoiceOPS",
    contact: {
      name: "API Support",
      email: "support@example.com",
    },
    license: {
      name: "MIT",
      url: "https://opensource.org/licenses/MIT",
    },
  },

  /**
   * Servers configuration
   */
  servers: [
    {
      url: "http://localhost:3333",
      description: "Development server",
    },
  ],
});

Options

enabled

Enable or disable swagger documentation.

path

Path where the documentation will be served. Example: /docs

validator

Schema validator to use for automatic schema conversion.

namedescription
vinejsUse VineJS for schema validation. VineJS Docs
typeboxUse TypeBox for schema validation. TypeBox Docs
zodUse Zod for schema validation. Zod Docs

info

OpenAPI specification information.

namedescription
titleTitle of the API
versionVersion of the API
descriptionDescription of the API
contactContact information for the API
licenseLicense information for the API

servers

Servers configuration.

namedescription
urlURL of the server
descriptionDescription of the server

Last updated on