Skip to content
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

Defaults and oneOf not working as expected #474

Open
technotic opened this issue Oct 27, 2022 · 0 comments
Open

Defaults and oneOf not working as expected #474

technotic opened this issue Oct 27, 2022 · 0 comments

Comments

@technotic
Copy link

technotic commented Oct 27, 2022

This is with version 1.14.1.

It seems that if there are multiple oneOf subschemas which share the same field and one has a default and the others do not then the default is always used no matter which subschema is matched. This feels like a defect?

eg. schema:

{
  "title": "Example",
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "kind": {
          "enum": [
            "A"
          ]
        },
        "foo": {
          "type": "string",
          "default": "bar"
        }
      }
    },
    {
      "type": "object",
      "properties": {
        "kind": {
          "enum": [
            "B"
          ]
        },
        "foo": {
          "type": "string"
        }
      },
      "required": [
        "foo"
      ]
    }
  ]
}

Valid (correctly):

{
  "kind": "A"
}

Should not be valid but is:

{
  "kind": "B"
}

because the B kind takes the default from the A oneOf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant