inversify / InversifyJS

A powerful and lightweight inversion of control container for JavaScript & Node.js apps powered by TypeScript.
http://inversify.io/
MIT License
11.02k stars 712 forks source link

Support for Open API documentation auto generation in express utils and other frameworks #1569

Open elbassel opened 2 months ago

elbassel commented 2 months ago

Expected Behavior

Imagine having an API that handles creating game data and returns the created user information. For example:

@httpPost("/",`` { description: "create a game" }) async createGame(@requestBody() gameData: CreateGameData, @request() req: Request): Promise { const newGame = await this.gameService.createGame(gameData, deps); newGame.status = GameStatusLabelBuilder.build(newGame, req.language); return newGame; }

In this scenario, API documentation could be auto-generated based on the HTTP method annotations, function arguments, and return types. This would ensure the documentation is always up-to-date and more reliable compared to manual documentation.

Current Behavior

Currently, this feature does not seem to be implemented.

Possible Solution

Implement a mechanism to generate the Swagger YAML file at runtime based on the HTTP method annotations, function arguments, and return types.

Context

Auto-generating API documentation will keep it consistently up-to-date and more accurate, significantly improving over the manual documentation process.

PodaruDragos commented 2 months ago

this would be a great idea, PR's are welcomed