使用Nest-Swagger Openapi生成嵌套对象

发布于 2025-02-13 17:58:11 字数 359 浏览 0 评论 0原文

我想使用Nestjs/Swagger生成一个API文件,其中其中一个是对象。 在“组件/模式”部分下的结果中,我看到了我正确创建的所有模式,但是在“路径”部分下,我看到嵌套属性被提取和扁平。 即,而不是这个条目,

...
"optional": true,
"schema": { "$ref": "#/components/schemas/MySchema" }

我会为MySchema中的每个属性获得条目(并且与父架上的其他条目相同的级别。所以真的不好)。

无论如何,“ myschema”是在组件/模式中正确生成的,它只是在“路径”部分中没有自动引用。枚举,原语等会自动引用,因此我想我只需要一些调整即可。我需要做什么?

I want to generate an API file using nestjs/swagger, where one of the properties is an object.
In the result under the components/schemas section I see all schemas I created properly, but under the "paths" section I see that the nested properties are extracted and flattened.
i.e instead of this one entry

...
"optional": true,
"schema": { "$ref": "#/components/schemas/MySchema" }

I get entries for each of the properties in MySchema (and in the same level with other entries from the parent schema. so really not good).

Anyway, "MySchema" is generated properly in components/schemas, it's just not automatically referenced to in "paths" section. Enums, primitives etc. are automatically referenced, so I guess I just need some adjustments. what do I need to do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文