Swagger嵌套参数对象



我想创建一个swagger端点,该端点的请求主体是一个具有2个整数字段的产品对象和一个具有另外2个字段的选项对象,我使用rswag作为ruby gem

在我的规范

parameter in: :body, schema: {
type: :object,
properties: {
product_id: { type: :integer },
quantity: { type: :integer },
options: {
properties: {
color: { type: :string },
size: { type: :string },
}
},
}
}

然而,在我的ui中,我没有颜色或大小的字段,只有一个选项的文本字段,我该如何解决这个问题?

试试这个:

parameter in: :body, schema: {
type: :object,
properties: {
product_id: { type: :integer },
quantity: { type: :integer },
options: {
type: :object,
properties: {
color: { type: :string },
size: { type: :string },
}
},
}
}

最新更新