Skip to content

support supplementary oneOf, anyOf, allOf, noneOf section in schema with valid 'type' #68

Description

@andy-miracl

If you have a schem with a valid type and also oneOf anyOf, allOf or noneOf, then defaults are not applied.

A typical use case is when you have an object schema that is required to have one field or another, but not both, (see https://stackoverflow.com/questions/24023536/json-schema-how-do-i-require-one-field-or-another-or-one-of-two-others-but-no). You can do this kind of thing with the following type of schema schema :

{
    "title": "test",
    "type": "object",
    "properties": {
      "obj1": {
        "type": "object",
        "properties": {
          "prop1": {
            "type": "string",
            "default": "val1"
          }
        }
      },
      "obj2": {
        "type": "object",
        "properties": {
          "prop2": {
            "type": "string",
            "default": "val2"
          }
        }
      }
    },
    "oneOf": [
      {
        "required": [
          "obj1"
        ]
      },
      {
        "required": [
          "obj2"
        ]
      }       
    ]
}

However, conflate does not apply the object property defaults in the case of json input data such as :

{
  "obj1": {} 
}

Conflate should output :

{
  "obj1": {
    "prop1": "val1"
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions