tsoa.json


Overview

The `tsoa.json` file is a configuration file used by the **tsoa** framework, which is a TypeScript OpenAPI and Swagger generation tool. This configuration file defines how tsoa will generate API documentation and routes based on the project's source code.

Specifically, it guides tsoa in locating the entry point of the application, where to find controller files, how to handle additional properties in models, where to output generated OpenAPI specification files and routes, and which files or directories to ignore during processing.

This file plays a pivotal role in automating the generation of API specs and routes, ensuring that the API documentation stays consistent with the codebase and reducing manual overhead.


Configuration Properties Explained

Below is a detailed explanation of each property in the `tsoa.json` file, including its purpose, accepted values, and usage.

1. entryFile


2. noImplicitAdditionalProperties


3. controllerPathGlobs


4. spec


5. routes


6. ignore


Usage Example

Assuming you have a TypeScript project with controllers under the `src` directory, your `tsoa.json` configuration as shown will:

You can then run tsoa CLI commands like:

tsoa spec
tsoa routes

to generate updated API specs and routes accordingly.


Implementation Details


Interaction with Other Parts of the System


Mermaid Diagram: Configuration Structure

flowchart TD
    A[tsoa.json Configuration]
    A --> B[entryFile: src/app.ts]
    A --> C[noImplicitAdditionalProperties: throw-on-extras]
    A --> D[controllerPathGlobs: src/**/controller.ts]
    A --> E[spec]
    E --> E1[outputDirectory: src]
    E --> E2[specVersion: 3]
    A --> F[routes]
    F --> F1[routesDir: src]
    A --> G[ignore]
    G --> G1[**/node_modules/**]
    G --> G2[**/dist/**]

Summary

The `tsoa.json` file is a critical configuration artifact in a tsoa-based TypeScript project that orchestrates how API documentation and routing are generated. By specifying entry points, controller locations, output directories, and validation behaviors, it streamlines the synchronization between your source code and API documentation, enabling robust and maintainable API development workflows.