如何在Swagger中描述一个具有简单对象的数组模型?



我有一个REST服务文档,其中一些接受简单的数组,如:

[
{ "name":"a" },
{ "class":"b" },
{ "hello":"c" }
]
How do I describe this in the Swagger yaml model section? I can only create 'is_sellerarray' like
{
"is_seller": [
{
"name": "string",
"asim": "string"
}
]
}

您可以定义自己的数组类型。您的宠物对象将具有nameasim作为两个属性。请按照文档了解更多信息。https://swagger.io/docs/specification/data-models/

type: array
items:
$ref: '#/components/schemas/Pet'

你可以玩周围的在线swagger编辑器,以查看实时的变化。https://editor-next.swagger.io/

最新更新