英文:
Variable in Resuable component in OpenAPI
问题
在参数描述中插入SampleResourceName
,如下所示:
parameters:
ResourceName:
in: path
name: name
description: The name of the SampleResourceName
schema:
type: string
required: true
英文:
Say I have a reusable component:
parameters:
ResourceName:
in: path
name: name
description: The name of the Resource (See tag for resource)
schema:
type: string
required: true
I have a use for this component across several endpoints, and the identifier that I see for these endpoints is the tag. Can I insert the tag name in the description as its inserted?
An example implementation in an operation
tags:
- SampleResourceName
parameters:
- $ref: '#/components/parameters/ResourceName'
How can I insert SampleResourceName
in the description of the parameter, IE:
parameters:
ResourceName:
in: path
name: name
description: The name of the {tag}
schema:
type: string
required: true
答案1
得分: 1
OpenAPI 和 YAML 不支持变量占位符。
但你可以编写一个脚本来解析你的 OpenAPI 文件并按你的需求进行处理。查看在 YAML 中使用占位符,其中包含了可以帮助你的 YAML 扩展库的链接。
英文:
OpenAPI and YAML do not support variable placeholders.
But you can write a script that would parse your OpenAPI file and process it the way you need. Check out Use placeholders in YAML which contains links to YAML extension libraries that can help you with this.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论