Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • slapos slapos
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Merge requests 124
    • Merge requests 124
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • slaposslapos
  • Merge requests
  • !1883

Open
Created Sep 15, 2025 by Xavier Thompson@xavier_thompsonOwner
  • Report abuse
Report abuse

Draft: slapconfiguration: Fix jsonschema design bugs

  • Overview 2
  • Commits 7
  • Changes 2

Rewrite jsonschema validation to correctly collect defaults only from valid validation paths: when a wider sub-schema is not validated by a wider sub-instance, all of the sub(sub)schemas that were validated by sub(sub)instances are to be discarded from consideration for defaults collection. An example of this is provided in the tests.

Also, defaults are now recursively validated, which allows objects to set e.g. {} as the default, and still collect the defaults of defined by each property of that object, as in:

{
  "type": "object",
  "properties": {
    "point": {
      "type": "object",
      "default": {},
      "properties": {
        "x": {
          "type": "integer",
          "default": 0
        },
        "y": {
          "type": "integer",
          "default": 0
        }
      }
    }
  }
}

Passing the instance {} should result, after default application, in {"point": {"x": 0, "y": 0}}, not in {"point": {}}. This is important also because otherwise the behavior is inconsistent between applying defaults and setting the same value directly: given this schema, the input {} and the input {"point": {}} should produce the same output, namely {"point": {"x": 0, "y": 0}}.

Also support collecting defaults specified indirectly via a $ref, as well as unstringifying properties that specify their type by a $ref, or even a succession of $ref. This serves to support e.g.:

{
  "type": "object",
  "$defs": {
    "coordinate": {
      "type": "integer",
      "default": 0
    }
  }
  "properties": {
    "point": {
      "type": "object",
      "default": {},
      "properties": {
        "x": { "$ref": "#/$defs/coordinate" },
        "y": { "$ref": "#/$defs/coordinate" }
      }
    }
  }
}
Edited Sep 15, 2025 by Xavier Thompson
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: feat/slapconfiguration-recursive-defaults
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7