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

added test to illustrate $ref defining a new scope #327

Merged
merged 2 commits into from
Mar 23, 2020
Merged

Conversation

gregsdennis
Copy link
Member

Had a discussion about @handrews around this and thought it'd be a good test.

Basically $ref provides an additional layer of indirection that maintains unevaluatedProperties's inability to see the rest of the schema.

So that

{
    "$defs": {
        "unevaluatedDef": {
            "unevaluatedProperties": false
        }
    },
    "properties": {
        "prop1": {"type": "string"}
    },
    "$ref": "#/$defs/unevaluatedDef"
}

becomes

{
    "properties": {
        "prop1": {"type": "string"}
    },
    "$new-scope": {
        "unevaluatedProperties": false
    }
}

(where $new-scope is essentially a no-op, except that it isolates what it contains)

rather than

{
    "properties": {
        "prop1": {"type": "string"}
    },
    "unevaluatedProperties": false
}

It illustrates how $ref resolution behaves when it's adjacent to other keywords.

{
"description": "referenced subschema doesn't see annoations from properties",
"data": {
"prop1": "match"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $ref were resolved as a literal in-place substitution, then prop1 would be allowed.

@Julian
Copy link
Member

Julian commented Mar 23, 2020

Cool, lgtm!

@gregsdennis gregsdennis merged commit f059435 into master Mar 23, 2020
@gregsdennis gregsdennis deleted the ref-scoping branch March 23, 2020 06:53
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

3 participants