Root Configuration
The entry point to your API. This file should import (directly or indirectly) all controller files.
Array of glob patterns pointing to controller files. Alternative to Supported glob patterns:
entryFile that allows direct file selection.*- Matches any characters except/**- Matches any characters including/{a,b}- Matchesaorb[abc]- Matches any character in the set
Configuration for OpenAPI specification generation. See Spec Configuration below.
Configuration for route handler generation. See Routes Configuration below.
Controls validation behavior for extra properties in request bodies.
Array of glob patterns for directories/files to ignore during TypeScript scanning.
TypeScript compiler options to use during generation. Merged with options from
tsconfig.json.Default OpenAPI type for TypeScript
number when no type annotation present.Options: "double", "float", "integer", "long"Multer configuration for file uploads.
Spec Configuration
All properties under thespec key in your configuration:
Required Properties
Directory where the OpenAPI specification file will be written.
Version and Format
Major OpenAPI version to generate.Supported values:
2- OpenAPI 2.0 (Swagger)3- OpenAPI 3.0.x3.1- OpenAPI 3.1.x
Generate YAML format instead of JSON.
Base name of the output file (without extension).With
yaml: true, generates openapi.yaml. Otherwise, generates openapi.json.API Metadata
API name. Defaults to
name from package.json.API version. Defaults to
version from package.json.API description. Defaults to
description from package.json.API license. Defaults to
license from package.json.Link to terms of service. Must be a valid URL.
Contact information for the API.
Server Configuration
API host (OpenAPI 2.0 only). Format:
hostname[:port]Base path prepended to all API routes.
Transfer protocols (OpenAPI 2.0 only).Values:
"http", "https", "ws", "wss"Server URLs (OpenAPI 3.x only). Can include variables.
Remove leading slash from basePath in server URLs (OpenAPI 3.x only).Generates:
https://api.example.comv1 instead of https://api.example.com/v1Security Configuration
Security schemes available in the API. Keys are security scheme names.
Default security requirements applied to all endpoints. Can be overridden with Requires JWT authentication on all endpoints unless overridden.
@Security or @NoSecurity decorators.Tags and Organization
Global tag definitions for API organization.
Advanced Options
Handlebars template for generating operation IDs.Available context:
controllerName- Controller class namemethod- Method metadata objectmethod.name- Method name
titleCase- Converts to title casekebabCase- Converts to kebab-case
Custom OpenAPI properties to merge into the generated spec.
Strategy for merging
spec property with generated specification.Add
x-enum-varnames extension for better enum handling in code generators.Generate titles for inline objects in requests/responses. Improves code generation consistency.
Routes Configuration
All properties under theroutes key in your configuration:
Required Properties
Directory where the generated routes file will be written.
Middleware Configuration
Web framework to generate routes for.Options:
"express", "koa", "hapi"Path to custom middleware template. Allows complete customization of generated routes.
Output Configuration
Name of the generated routes file.
Base path prepended to all routes.
Skip writing routes file if content unchanged. Useful for watch mode.
Module Integration
Path to module exporting authentication function.Module must export
expressAuthentication, koaAuthentication, or hapiAuthentication:Path to IoC container module.Module must export
iocContainer:ES Modules Support
Generate imports with Generates:
.js extensions for ES modules.Keep
.ts extensions in imports for TypeScript 5.7+ rewriteRelativeImportExtensions feature.Validation Options
Automatically coerce body parameters to expected types.When enabled, strings are converted to numbers, booleans, etc. when the type signature expects them.
Example Configurations
Minimal Configuration
Complete Configuration
Type Definitions
tsoa exports TypeScript types for configuration:Next Steps
Configuration Guide
Practical examples and best practices
CLI Commands
Learn about CLI commands and flags