Skip to content

oneOf with array with oneOf breaks the library #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
diogobaeder opened this issue Apr 3, 2019 · 1 comment
Closed

oneOf with array with oneOf breaks the library #127

diogobaeder opened this issue Apr 3, 2019 · 1 comment
Labels
area/schema Indicates an issue on schema area

Comments

@diogobaeder
Copy link

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.

@diogobaeder
Copy link
Author

@p1c2u if you want, I can fix this later, feel free to add me as a full contributor to the project if you want so that I can help with the releases and other fixes.

@p1c2u p1c2u added the area/schema Indicates an issue on schema area label Sep 5, 2019
@p1c2u p1c2u closed this as completed Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/schema Indicates an issue on schema area
Projects
None yet
Development

No branches or pull requests

2 participants