如何在参数中声明查询对象?

How to declare query object in the parameters?

我正在尝试在 OpenAPI 3 中定义查询对象:

      parameters:
        - name: query
          in: query
          schema:
            type: object
            properties:
              id:
                type: number
            required:
              - id

但示例值和架构未在 Swager 中显示 UI。

是否有错误或我遗漏了什么?

你的定义是正确的。

but example value and schema was not shown in swaager ui.

示例 实际显示的 JSON key/value 格式:

{
  "id": 0
}

“试用”将根据定义的 serialization method 序列化此参数,在本例中为 ?id=<value> 查询字符串。


type: object 的查询参数未显示架构的问题是一个已知限制,在此处进行了跟踪:
https://github.com/swagger-api/swagger-ui/issues/4581