Skip to content

oneOf with array with oneOf breaks the library #127

Closed
@diogobaeder

Description

@diogobaeder

Hi,

If we have the below schema:

{
  "Foo": {
    "properties": {
      "name": {
        "type": "string"
      },
      "values": {
        "oneOf": [
          {
            "format": "int32",
            "type": "integer"
          },
          {
            "type": "string"
          },
          {
            "items": {
              "oneOf": [
                {
                  "format": "int32",
                  "type": "integer"
                },
                {
                  "type": "string"
                }
              ]
            },
            "type": "array"
          }
        ]
      }
    },
    "required": [
      "name",
      "values"
    ],
    "type": "object"
  }
}

and receive a value like this:

{
  "name": "bar",
  "values": [
    "2"
  ]
}

it breaks the library. The reason is that during the attempt to cast() the values field, it iterates over a set of SchemaTypes to try to cast the value, but then there are no schemas in self.items for values itself (since it's a oneOf) when it matches SchemaType.ARRAY.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/schemaIndicates an issue on schema area

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions