是否可以从外部文件引用OpenAPI操作description?
这是我的代码样本。我希望将描述“--此API用于获取用户详细信息”保留在一个单独的文件中,并将其作为变量或模板或引用在这里使用。有办法这样做吗?
get:
tags:
- User
summary: Get user details
description: This API is used to get user details
operationId: updateUser
parameters:
- name: userid
in: path
description: The id that needs to be pulled
required: true
schema:
type: string

发布于 2022-11-03 02:48:21
如果您对捆绑使用Redocly,那么您可以将它放在一个单独的文件中,如下所示:
get:
tags:
- User
summary: Get user details
description:
$ref: ./updateUser-description.md
operationId: updateUser
parameters:
- name: userid
in: path
description: The id that needs to be pulled
required: true
schema:
type: string然后,在一个名为updateUser-description.md的单独文件中(注意,您也可以更改名称):
This API is used to get user details然后,当您运行bundle命令时,它解析$ref并用相应的Markdown文件中的内容替换描述。
npx @redocly/cli bundle my-openapi.yamlhttps://stackoverflow.com/questions/74297572
复制相似问题