我试图在这个例子中为“House”添加一个只读字段。房屋是另一个我想要设置为只读的模型。
在这个例子中,狗的数组可以设置为readOnly
而不会出错,但是当我将House的单个定义设置为readOnly
时,Swagger编辑器会显示以下警告:
$refs旁边不允许有兄弟值。
我理解这是因为此处继承了模型中的所有内容。那么,如何定义在此端点中写入API调用不能定义“House”,同时又允许在其他API端点中创建和更新“House”?
Pets:
properties:
id:
type: string
example: AAAAE12-1123AEF-1122312123
readOnly: true
name:
type: string
example: My Default Name
text:
type: string
example: My Default Text
Dogs:
type: array
readOnly: true
items:
$ref: '#/definitions/Dog'
House:
readOnly: true
$ref: '#/definitions/House'