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

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

Open
andy-miracl opened this issue May 21, 2018 · 1 comment

Comments

@andy-miracl
Copy link
Contributor

andy-miracl commented May 21, 2018

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"
  }
}
@andy-miracl
Copy link
Contributor Author

If a schema has a valid type then it should apply the defaults.

@andy-miracl andy-miracl changed the title support supplementary oneOf, anyOf, allOf, noneOf section in schema support supplementary oneOf, anyOf, allOf, noneOf section in schema with valid 'type' May 21, 2018
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