I am trying to add a read-only field for 'House' in this example. The house is another model that I want to be read-only.
In this example, the array of Dogs can be set to readOnly
without an error, but when I set the single definition of House to readOnly
I get the following warning in the Swagger Editor:
Sibling values are not allowed alongside $refs
I understand that this is because everything in the model is inherited here. So how do I define that the write API calls cannot define a 'House' in this endpoint whilst also allowing House to be created and updated in another API endpoints?
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'
You need
allOf
to combine a$ref
with other attributes: