我正在尝试使用静态 swagger 文件记录一个 API,该文件可以返回一些 JSON,其中包含一个看起来像这样的数组:
[
{
"type": "type A",
"field A": "this field is specific to type A"
},
{
"type": "type B",
"field B": "this field is specific to type B"
}
]
我尝试了几种不同的方法来定义我的规范,使用多态性或显式定义多个示例。这些示例总是最终看起来像:
[
{
"type": "type A",
"field A": "this field is specific to type A",
"field B": "this field is specific to type B"
}
]
要不就:
[
{
"type": "type A",
"field A": "this field is specific to type A"
}
]
有没有办法在我的 swagger 规范中定义一个示例,以便 swagger-ui 显示的示例有效负载将包含一个数组,其中包含一个类型 A 的示例和一个类型 B 的示例,就像我写的第一个 JSON 一样?