tsoa.json


Overview

`tsoa.json` is a configuration file used by the **tsoa** framework, a TypeScript OpenAPI (Swagger) generator and routing tool for Node.js applications. This file defines the settings and parameters that guide how tsoa generates API routes, OpenAPI specifications, and integrates with the existing TypeScript codebase.

Primarily, `tsoa.json` specifies:

This file enables seamless automation of API documentation and routing by linking TypeScript controllers to generated OpenAPI specs and route files, facilitating maintainable and consistent API development.


Detailed Explanation of Properties

1. entryFile: string

Specifies the main entry point of the application, which tsoa uses as the root for analyzing the project and resolving imports.

2. noImplicitAdditionalProperties: string

Controls the behavior when additional properties not defined in the model interfaces appear in incoming requests.

3. controllerPathGlobs: string[]

An array of glob patterns specifying file paths where tsoa should look for controller classes.

4. spec: object

Settings related to the OpenAPI specification generation.

5. routes: object

Settings related to route generation.

6. ignore: string[]

An array of glob patterns specifying files or directories that tsoa should ignore during scanning.


Implementation Details and Algorithms

`tsoa.json` is a static JSON configuration file and does not contain executable code or algorithms itself. Instead, it is consumed by the tsoa CLI and API during the build or generation steps:


Interaction with Other Parts of the System


Usage Example

Assuming you have this configuration, you would run tsoa commands like:

tsoa spec

This generates an OpenAPI 3 specification inside the `src` directory.

tsoa routes

This generates route files inside the `src` directory, which you can then import in your `src/app.ts` to register routes with your Express or Koa server.


Mermaid Diagram: Configuration Structure Flowchart

flowchart TD
    A[tsoa.json Configuration]
    A --> B[Entry File: "src/app.ts"]
    A --> C[Controller Path Globs: "src/**/controller.ts"]
    A --> D[Spec Generation]
    D --> D1[Output Directory: "src"]
    D --> D2[OpenAPI Spec Version: 3]
    A --> E[Route Generation]
    E --> E1[Routes Directory: "src"]
    A --> F[Additional Properties Policy: "throw-on-extras"]
    A --> G[Ignore Patterns]
    G --> G1["**/node_modules/**"]
    G --> G2["**/dist/**"]

Summary

`tsoa.json` is a vital configuration file for projects using the tsoa framework to automate API documentation and routing. By defining the entry point, controller locations, validation rules, and output directories, it orchestrates the generation of OpenAPI specs and route bindings—ensuring that the API remains consistent, well-documented, and easy to maintain.

This file works closely with:

Together, these components enable a smooth developer experience for building and documenting RESTful APIs in TypeScript.