从打字稿界面生成swagger文档 [英] Generating swagger docs from typescript interfaces
问题描述
我正在使用 swager-jsdoc 来记录该应用程序的所有DTO. /p>
我想知道有什么方法可以从打字稿界面自动生成swagger文档.
我在项目中有很多,还有很多猫鼬的模式和模型.使它们保持同步变得很乏味.另一方面,我不想使用招摇工具.我更喜欢自下而上的方法.
欢呼
tsoa 的另一个选项是路由控制器 + https://github.com/YousefED/typescript-json-schema ,它从Typescript接口生成JSONS chema;在JSON Schema中定义了模型之后,您与OpenAPI规范就相距不远了.
I'm using swager-jsdoc to document all the DTOs of the app.
I was wondering is there any way to generate the swagger docs automatically from typescript interfaces.
I have a lot of them in the project and also a lot of mongoose schemas and models. It is getting tedious to keep them in sync. On the other hand I do not want to use the swagger generation tools. I prefer the bottom-up approach.
Cheers
Another option to tsoa is routing-controllers + routing-controllers-openapi. The main difference between the two (AFAIK) is that tsoa
relies on code generation whereas routing-controllers
operates wholly on runtime. Both methods have their upsides: tsoa
is able to e.g. utilize richer metadata (such as code comments) whereas with routing-controllers
we can skip the generation step. My recommendation is to check both out!
One more option is https://github.com/YousefED/typescript-json-schema, which generates JSONS chema out of Typescript interfaces; after you've got your models defined in JSON Schema you're not terribly far off from an OpenAPI spec.
这篇关于从打字稿界面生成swagger文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!