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

Follow refs when finding default property values #175

Merged
merged 1 commit into from Mar 2, 2024
Merged

Conversation

davishmcclurg
Copy link
Owner

This resolves any ref_schema keywords ($ref, $dynamicRef, $recursiveRef) when looking for default keywords for insert_property_defaults. It follows the keyword order defined in the vocabulary ($ref first, then $dynamicRef/$recursiveRef depending on the meta schema) and searches depth-first (ie, follows a $ref chain until a leaf schema before moving on to a sibling $dynamicRef). The first default keyword found is used, meaning a $ref default can be overwritten by the including schema, eg:

{
  "properties": {
    "example": {
      "$ref": "#/$defs/ref",
      "default": "override!"
    }
  },
  "$defs": {
    "ref": {
      "default": "overridden"
    }
  }
}

Closes: #173

This resolves any `ref_schema` keywords (`$ref`, `$dynamicRef`,
`$recursiveRef`) when looking for `default` keywords for
`insert_property_defaults`. It follows the keyword order defined in the
vocabulary (`$ref` first, then `$dynamicRef`/`$recursiveRef` depending
on the meta schema) and searches depth-first (ie, follows a `$ref` chain
until a leaf schema before moving on to a sibling `$dynamicRef`). The
first `default` keyword found is used, meaning a `$ref` default can be
overwritten by the including schema, eg:

```json
{
  "properties": {
    "example": {
      "$ref": "#/$defs/ref",
      "default": "override!"
    }
  },
  "$defs": {
    "ref": {
      "default": "overridden"
    }
  }
}
```

Closes: #173
@davishmcclurg davishmcclurg merged commit 49ff77e into 2.2.0 Mar 2, 2024
64 of 68 checks passed
@davishmcclurg davishmcclurg deleted the ref-default branch March 2, 2024 18:30
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

Successfully merging this pull request may close these issues.

None yet

1 participant