在下面的Swagger定义中,我需要参数labelValue
为LabelValueObject
类型,以便它将被验证并正确反序列化。但是,我无法弄清楚语法!怎么办?
swagger: "2.0"
paths:
/competition:
post:
parameters:
- name: labelValue
in: formData
type: array
items:
type: string ### this has to be a LabelValueObject ###
responses:
default:
description: Error
schema:
$ref: "#/definitions/AnyResponse"
definitions:
AnyResponse:
properties:
any:
type: string
LabelValueObject:
properties:
label:
type: string
value:
type: string
required:
- label
- value
答案 0 :(得分:4)
将对象作为参数传递的唯一方法是将其放在正文(in: body
)中,然后在schema
中定义此对象(内联定义或使用{{对预定义对象的引用) 1}})。这是一个完整的例子:
$ref