Adonis Open Swagger

Routes

Configure which routes to document

Route configuration controls which API endpoints appear in your documentation. Use include and exclude patterns to precisely define what gets documented.

What are Route Patterns?

Route patterns are glob-style strings that match against your application's routes. They determine which endpoints Adonis Open Swagger will scan and include in your API documentation.

Configuration

Define route scanning options in your config/swagger.ts file:

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

export default defineConfig({
  routes: {
    autoScan: true,
    include: ["/users/v1/*", "/public/v1/*"],
    exclude: ["/docs*", "/health*"],
  },
});

Routes Properties

The routes object supports the following properties:

autoScan (optional)

Automatically scan for routes in your application. When enabled, Adonis Open Swagger will discover routes based on your include/exclude patterns.

{
  routes: {
    autoScan: true;
  }
}

include (optional)

Array of glob patterns specifying which routes to include in the documentation. Only routes matching these patterns will be scanned.

{
  routes: {
    include: ["/users/v1/*", "/public/v1/*"];
  }
}

exclude (optional)

Array of glob patterns specifying which routes to exclude from the documentation. Routes matching these patterns will be ignored, even if they match an include pattern.

{
  routes: {
    exclude: ["/docs*", "/health*"];
  }
}

Last updated on