I am trying to create a REST contract using YAML and Swagger. So at this point a write all operations and now I am specifyng the contentes of service responses. I need to make a choice between 2 objects. For this I am using (or trying) 'oneOf' as shown:
......
responsavelPJType:
type: object
properties:
dataInicio:
type: string
dataEncerramento:
type: string
tipoResponsavel:
$ref: '#/definitions/tipoResponsavelType'
tipoResponsavelType:
type: object
oneOf:
- $ref: '#/definitions/pessoaFisicaType'
- $ref: '#/definitions/pJType'
pessoaFisicaType:
type: object
properties:
cpf:
type: integer
pJType:
type: object
properties:
cnpj:
type: integer
.....
The Swagger Editor gives me the Message: "additionalProperty 'oneOf' exist in when not allowed".
What is the correct way to use 'oneOf'?