在OpenAPI中的可重用组件中的变量

huangapple go评论41阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月9日 01:20:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75389461.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定