【问题标题】:swagger is not rendering requestbodyswagger 没有呈现 requestbody
【发布时间】:2019-04-04 07:32:26
【问题描述】:

我有以下符合 openapi 3.0 的 yaml 文件,我正在尝试通过 swagger 进行渲染。 yaml文件中没有报错,但是requestBody没有在swagger GUI上呈现。我只是得到一个 parameters 字段,它是空的,但没有为请求正文呈现任何内容,也没有任何错误。截图如下。

paths:
  /my-api:
    post:
      summary: My API Summary
      description: My API Description
      tags:
        - Cost Center
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: array
                  items:
                    $ref: '#/components/schemas/ReqBodyStruct'

获取同样显示在 swagger gui 中的 RequestBody 的方法是什么?我错过了什么吗?

【问题讨论】:

  • 您能否发布完整的 API 定义,包括 ReqBodyStruct 架构?

标签: yaml swagger openapi swagger-editor


【解决方案1】:

根据来自 Swagger UI github 页面的 OAS 3.0: Support for media type examples (aka request/response body examples) #3437Examples are not showing #2651 这两个问题,这应该在版本 3.23.0(2019 年 6 月 29 日)中得到修复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-12
    • 2016-12-11
    • 1970-01-01
    • 2016-05-28
    • 1970-01-01
    • 2021-03-16
    • 2021-03-16
    • 2018-12-05
    相关资源
    最近更新 更多