1

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'?

Anthon
  • 69,918
  • 32
  • 186
  • 246
ChelloFera
  • 349
  • 1
  • 3
  • 16
  • 1
    See the linked question. You are using OpenAPI/Swagger 2.0 which doesn't support `oneOf`. `oneOf` is supported in OpenAPI 3.0. – Helen Aug 10 '17 at 21:52

0 Answers0