tsoa.json


Overview

`tsoa.json` is a configuration file used by the **tsoa** framework, a TypeScript tool for generating OpenAPI specifications and routing controllers automatically. This JSON file defines key settings that control how tsoa scans the source code, generates API documentation, and creates routing files within the project.

The file’s primary purpose is to configure tsoa's behavior including:

This configuration enables seamless integration of tsoa into the build and documentation workflow, ensuring consistent API spec generation and routing setup.


Configuration Properties

entryFile: string


noImplicitAdditionalProperties: string


controllerPathGlobs: string[]


spec: { outputDirectory: string, specVersion: number }


routes: { routesDir: string }


ignore: string[]


Usage Example

{
  "entryFile": "src/app.ts",
  "noImplicitAdditionalProperties": "throw-on-extras",
  "controllerPathGlobs": ["src/**/controller.ts"],
  "spec": {
    "outputDirectory": "src",
    "specVersion": 3
  },
  "routes": {
    "routesDir": "src"
  },
  "ignore": ["**/node_modules/**", "**/dist/**"]
}

This configuration tells tsoa to:


Implementation Details


Interaction with Other Parts of the System


Visual Diagram

Below is a flowchart illustrating the main configuration properties and their relationships in the `tsoa.json` file and how tsoa uses them.

flowchart TD
    subgraph tsoa.json Configuration
        EF[entryFile: "src/app.ts"]
        NI[noImplicitAdditionalProperties: "throw-on-extras"]
        CPG[controllerPathGlobs: ["src/**/controller.ts"]]
        IGN[ignore: ["**/node_modules/**", "**/dist/**"]]
        SPEC[spec]
        ROUTES[routes]
    end

    SPEC -->|outputDirectory: "src"| SPEC_OUT[Spec Output Directory]
    SPEC -->|specVersion: 3| SPEC_VER[Spec Version]

    ROUTES -->|routesDir: "src"| ROUTES_OUT[Routes Output Directory]

    EF -->|Start scanning| CONTROLLERS[Controller Files Found]
    CPG --> CONTROLLERS
    IGN -.->|Exclude| CONTROLLERS

    CONTROLLERS -->|Generate| ROUTES_OUT
    CONTROLLERS -->|Generate| SPEC_OUT

    NI -->|Validation Rules| CONTROLLERS

Summary

`tsoa.json` is a concise yet powerful configuration file that governs how the tsoa framework scans your TypeScript project, validates API inputs, generates OpenAPI specs, and outputs route files. Proper configuration ensures automatic and consistent API documentation and routing, greatly simplifying backend development and maintenance.


**End of Documentation**