tsoa.json

Overview

The `tsoa.json` file is a configuration file used by **tsoa**, a TypeScript OpenAPI and routing generation tool. This file defines how tsoa should scan, generate, and output API routes and specifications for the project. It plays a crucial role in automating the creation of OpenAPI-compliant API documentation and route handlers based on TypeScript controller files.

This configuration enables seamless integration between the TypeScript codebase and the OpenAPI ecosystem, facilitating automatic validation, routing, and documentation generation with minimal manual setup.


Configuration Properties

1. entryFile: string


2. noImplicitAdditionalProperties: string


3. controllerPathGlobs: string[]


4. spec: object


5. routes: object


6. ignore: string[]


How This File Interacts with the System


Usage Example

Suppose you have a controller at `src/user/controller.ts`:

import { Controller, Get, Route } from 'tsoa';

@Route('users')
export class UserController extends Controller {
  @Get()
  public async getUsers(): Promise<string[]> {
    return ['Alice', 'Bob'];
  }
}

Implementation Details


Visual Diagram

The following flowchart illustrates how `tsoa.json` configures the workflow of tsoa in the system:

flowchart TD
    A[tsoa.json Configuration] --> B[Scan entryFile: src/app.ts]
    B --> C[Find controllers using controllerPathGlobs]
    C --> D[Parse controller decorators & types]
    D --> E[Generate OpenAPI Spec in src/]
    D --> F[Generate Route Handlers in src/]
    E --> G[OpenAPI Docs & Validation]
    F --> H[API Route Integration in Application]
    I[ignore patterns] -.-> B

Summary

The `tsoa.json` file is a central configuration for integrating tsoa into a TypeScript project. It defines how tsoa identifies API controllers, generates OpenAPI specifications, and creates routing files. This file ensures strong typing, validation, and up-to-date API documentation, streamlining API development and maintenance in the project.