tsoa.json


Overview

The `tsoa.json` file serves as the central configuration for the **tsoa** framework within the project. **tsoa** is a TypeScript-oriented tool that facilitates the automatic generation of OpenAPI-compliant REST API specifications and routes based on TypeScript controllers and models.

This file defines key settings including the entry point of the application, controller file locations, OpenAPI specification output details, routing configuration, and ignore patterns for files/folders that should be excluded from tsoa processing. By customizing `tsoa.json`, developers control how tsoa scans the project for API controllers and how it generates API documentation and routing files.


Configuration Properties

Below is a detailed explanation of each property in the `tsoa.json` file, including purpose, expected value types, and usage:

Property

Type

Description

`entryFile`

`string`

Specifies the main entry point file of the application that tsoa uses as the root for scanning and generating API metadata.

`noImplicitAdditionalProperties`

["throw-on-extras"](/projects/291/69124) \

["ignore"](/projects/291/69202) \

`controllerPathGlobs`

`string[]`

An array of glob patterns that indicate where tsoa should look for controller files. These controllers define API endpoints.

`spec`

`object`

Configuration for OpenAPI specification generation.

`spec.outputDirectory`

`string`

Directory where the generated OpenAPI specification files will be saved.

spec.specVersion

`number`

Version of the OpenAPI specification to generate (typically 2 or 3).

`routes`

`object`

Configuration for generating routing files.

`routes.routesDir`

`string`

Directory where tsoa will output generated route files.

`ignore`

`string[]`

Glob patterns for files or directories to exclude from tsoa scanning and generation (e.g., `node_modules`, build output folders).


Detailed Explanation of Properties

entryFile

noImplicitAdditionalProperties

controllerPathGlobs

spec

routes

ignore


Implementation Details and Usage Notes


Interactions with Other Parts of the System


Example Usage Scenario

Assuming this `tsoa.json`, a typical command sequence might be:

tsoa spec       # Generates OpenAPI spec files in src/
tsoa routes     # Generates route files in src/

The application then imports generated routes from `src/routes.ts` (or similar), and the API spec can be served or displayed via Swagger UI.


Mermaid Diagram: Configuration Structure Flowchart

flowchart TD
    A[tsoa.json]
    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: ["**/node_modules/**", "**/dist/**"])

Summary

The `tsoa.json` file is the cornerstone configuration that controls how tsoa processes your TypeScript project to generate API documentation and routes. It specifies where to find controllers, how to handle additional properties, where to output specs and routes, and which files to ignore. Proper configuration of this file ensures smooth integration of tsoa-generated API infrastructure into your project’s build and runtime environment.