tsoa.json

Overview

The `tsoa.json` file is a configuration file for [tsoa](https://github.com/lukeautry/tsoa), a TypeScript framework used to generate OpenAPI-compliant REST API documentation and route definitions automatically from TypeScript source code. This JSON file defines key configuration parameters that instruct tsoa how to locate application source files, generate API specification files (OpenAPI/Swagger), and create routing files.

By configuring `tsoa.json`, developers streamline the generation of API documentation and routes, ensuring consistency between TypeScript code and API contracts, reducing manual documentation effort, and improving maintainability.


Configuration Properties Explanation

The file consists of a JSON object with the following main properties:

Property

Type

Description

`entryFile`

`string`

The main entry point of the application where tsoa starts parsing the TypeScript source code. Typically points to the main app bootstrap file.

`noImplicitAdditionalProperties`

`"throw-on-extras"` \

["silently-remove-extras"](/projects/291/69124) \

`controllerPathGlobs`

`string[]`

An array of glob patterns to locate controller files. Controllers define API endpoints and their routes.

`spec`

`object`

Configuration object for the generated OpenAPI specification. Contains sub-properties like output directory and OpenAPI version.

`routes`

`object`

Configuration for the generated routing files, including the directory where routes will be output.

`ignore`

`string[]`

An array of glob patterns specifying files or folders to exclude from tsoa parsing (e.g., dependencies or build output).


Detailed Property Descriptions

entryFile: string

noImplicitAdditionalProperties: "throw-on-extras"

controllerPathGlobs: string[]

spec: object

routes: object

ignore: string[]


Usage Example

Given this configuration, running tsoa CLI commands such as `tsoa spec` and `tsoa routes` will:

This setup ensures that API documentation and routing remain synchronized with the TypeScript source code.


Implementation Details


Interaction with Other System Components


Mermaid Diagram

This file is a configuration file defining properties for tsoa CLI behavior. A flowchart showing the main configuration properties and their relationships to the tsoa workflow is appropriate.

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

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

    F --> F1[routesDir: src]

    B --> H[Parse entry file]
    D --> I[Find controllers]
    H --> J[Analyze source code]
    I --> J
    J --> K[Generate OpenAPI spec in src/]
    J --> L[Generate routes in src/]

    C --> M[Validate request bodies strictly]
    G --> N[Exclude node_modules and dist]

    style A fill:#f9f,stroke:#333,stroke-width:2px
    style J fill:#bbf,stroke:#333,stroke-width:1px

Summary

This file is central to the tsoa-based API documentation and routing automation workflow within the project.