Swagger - 默认某些对象项未指定/缺失

问题描述

在 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"
}

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)