tsoa.json

Overview

The `tsoa.json` file is a configuration file used by **tsoa**, a TypeScript framework for building OpenAPI-compliant REST APIs and generating routes and swagger specifications automatically. This file defines the main settings and options for tsoa's code generation and runtime behavior in the project.

Specifically, it configures how tsoa should locate source files, generate API specifications, handle additional properties in models, configure routes, and exclude certain folders. This file is essential for integrating tsoa's automated workflow into the project's build and development process.


Detailed Explanation of Configuration Properties

Since `tsoa.json` is a JSON configuration file and does not contain classes or functions, this section explains all top-level properties and their meanings.

entryFile: string


noImplicitAdditionalProperties: string


controllerPathGlobs: string[]


spec: { outputDirectory: string, specVersion: number }


routes: { routesDir: string }


ignore: string[]


Important Implementation Details and Algorithms


Interaction with Other Parts of the System


Usage Example

If you add a new controller at `src/user/controller.ts`, tsoa will automatically detect it due to the glob pattern `"src/**/controller.ts"`. When running tsoa commands (such as `tsoa routes` or `tsoa spec`), it will:


Visual Diagram

Below is a flowchart illustrating the main configuration properties and their roles in the tsoa processing workflow:

flowchart TD
    A[tsoa.json Configuration]
    A --> B[entryFile: src/index.ts]
    A --> C[controllerPathGlobs: "src/**/controller.ts"]
    A --> D[noImplicitAdditionalProperties: "throw-on-extras"]
    A --> E[spec]
    A --> F[routes]
    A --> G[ignore]

    E --> E1[outputDirectory: src]
    E --> E2[specVersion: 3]

    F --> F1[routesDir: src]

    B --> H[Application Entry Point]
    C --> I[Controller Files]
    I --> J[Route Generation]
    J --> F1

    I --> K[OpenAPI Spec Generation]
    K --> E1

    D --> L[Validation Rules]
    L --> M[Strict Model Validation]

    G --> N[Excluded Paths]

Summary

The `tsoa.json` file is a critical configuration artifact for the tsoa framework, defining how the TypeScript API source code is parsed, how routes and OpenAPI specs are generated, and what validation rules are enforced. Proper configuration ensures seamless integration between code, API documentation, and runtime routes, enhancing developer productivity and API quality.