0

在 swagger 中,我将 JSON(即对象)定义为 API 的输入请求主体。有些 JSON 项目是强制性的,有些则不是,而我希望默认(或显示示例)中的一些根本不在默认 JSON 中指定。我怎样才能做到这一点?

InputJSON:
  type: object
  required:
    - item1
  properties:
    item1:
      type: string
    item2:
      type: string
    item3:
      type: array
      items:
        type: string

上面的代码显示示例为:

{
  "item1": "string",
  "item2": "string",
  "item3": [
    "string"
  ]
}

但我希望它是:

{
  "item1": "string"
}

谢谢你。

4

0 回答 0