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

bug: nested defaults will not be applied #632

Open
lgersman opened this issue May 19, 2020 · 1 comment
Open

bug: nested defaults will not be applied #632

lgersman opened this issue May 19, 2020 · 1 comment

Comments

@lgersman
Copy link

lgersman commented May 19, 2020

If a json schema provides nested defaults like this schema :

{
  "title": "Schema default properties",
  "type": "object",
  "properties": {
    "valuesInFormData": {
      "title": "Values in form data",
      "$ref": "#/definitions/defaultsExample"
    },
    "noValuesInFormData": {
      "title": "No values in form data",
      "$ref": "#/definitions/defaultsExample"
    }
  },
  "definitions": {
    "defaultsExample": {
      "type": "object",
      "properties": {
        "scalar": {
          "title": "Scalar",
          "type": "string",
          "default": "scalar default"
        },
        "array": {
          "title": "Array",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "nested": {
                "title": "Nested array",
                "type": "string",
                "default": "nested array default"
              }
            }
          }
        },
        "object": {
          "title": "Object",
          "type": "object",
          "properties": {
            "nested": {
              "title": "Nested object",
              "type": "string",
              "default": "nested object default"
            }
          }
        }
      }
    }
  }
}

json-schema does not apply these defaults using Constraint::CHECK_MODE_APPLY_DEFAULTS flag.

only top level defaults will be applied.

@COil
Copy link

COil commented Nov 20, 2020

Hello @lgersman, we are facing the same issue. In fact, it works for nested properties of objects but it doesn't work for array types.

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

2 participants