在Openapi中使用枚举作为参数,将引号添加到参数

发布于 2025-02-04 22:49:35 字数 1186 浏览 1 评论 0原文

我正在使用枚举作为API中的参数。但这导致参数被引号包围。

在下面的图像中,它显示了%22围绕参数摘要 - %22summary%22时,我从下拉列表中选择它。

如何避免在参数中添加报价?

/v1/metrics/{profile}:
  parameters:
    - $ref: "#/components/parameters/profile"
  get:
    summary: Get list of field or summary profile metrics
    description: Retrieves list of metrics for field or summary profile
    tags:
      - profile-metrics
    responses:
      '200':
        description: OK
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProfileMetrics"
      '400':
        $ref: "#/components/responses/BadRequest"
      '404':
        $ref: "#/components/responses/NotFound"
      default:
        $ref: "#/components/responses/UnexpectedError"

配置文件参数架构

profile:
  name: profile
  description: profile type either field or summary
  schema:
    type: string
    enum: [ field, summary ]
  in: path
  required: true

“在此处输入图像描述”

任何帮助都将受到赞赏

I am using Enums as parameter in api. But it results in the parameters being surrounded by quotes.

In the image below it shows how %22 surrounds the parameter summary - %22summary%22 as I select it from drop down.

How can I avoid adding quotes to the parameter ?

/v1/metrics/{profile}:
  parameters:
    - $ref: "#/components/parameters/profile"
  get:
    summary: Get list of field or summary profile metrics
    description: Retrieves list of metrics for field or summary profile
    tags:
      - profile-metrics
    responses:
      '200':
        description: OK
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProfileMetrics"
      '400':
        $ref: "#/components/responses/BadRequest"
      '404':
        $ref: "#/components/responses/NotFound"
      default:
        $ref: "#/components/responses/UnexpectedError"

profile parameter schema

profile:
  name: profile
  description: profile type either field or summary
  schema:
    type: string
    enum: [ field, summary ]
  in: path
  required: true

enter image description here

Any help is appreciated

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

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

发布评论

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