Skip to content

oneOf where more than 2 types inside an array #257

@harveyappleton

Description

@harveyappleton

Are you using jest or chai?
Jest

Are you using OpenAPI 2, 3.0.X, or 3.1.0?
OpenAPI 3.0.3

Describe the bug clearly
When I use oneOf for items in an array with more than 2 distinct references, it fails randomly and can't discriminate which is the matched entity type (even with discriminator property).

Steps to reproduce the bug:

  1. Create an open api spec with oneOf with more than 2 - for example
List:
  type: array
  items: 
    oneOf:
      - $ref: '#/components/schemas/Account'
      - $ref: '#/components/schemas/Item'
      - $ref: '#/components/schemas/Payment'
  1. From an endpoint, return this array with a mix of these 3 entities, eg
[
   { type: 'Account' },
   { type: 'Item' },
   { type: 'Payment' }
]

(my actual entities are more complex than this, but for the sake of a simple bug description, this will suffice)

  1. It fails on 1 of the 3 entity types, if I remove one and only do 2 entity types then it is fine.

What did you expect to happen instead?
It validates the array correctly

Are you going to resolve the issue?
If I'm pointed in the right direction I may be able to!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions