In Swagger, is it possible to reference a parent object's properties when defining what properties of a child object are required
?
For example, given the following base class:
definitions:
Pet:
type: object
properties:
name:
type: string
owner:
type: string
I would like to have two child classes: one for creating a Pet (where all properties are required in the payload) and another for updating a Pet (where none are required). I tried achieving this by doing:
CreatePetRequest:
allOf:
- $ref: '#/definitions/Pet'
required:
- name
- owner
UpdatePetRequest:
allOf:
- $ref: '#/definitions/Pet'
However, this doesn't work. Instead, an exception is raised:
swagger_spec_validator.common.SwaggerValidationError: Required list has properties not defined: ['name', 'owner']
How can I achieve this? Is it even possible with Swagger?