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

test when $dynamicRef references a boolean schema #701

Merged
merged 1 commit into from
Dec 10, 2023

Conversation

karenetheridge
Copy link
Member

This was an interesting one in my implementation - when looking for a $dynamicAnchor keyword at the destination schema, it threw an exception when that schema wasn't an object, but rather a boolean.

@karenetheridge karenetheridge requested a review from a team as a code owner November 12, 2023 23:13
Copy link
Member

@gregsdennis gregsdennis left a comment

Choose a reason for hiding this comment

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

One of the things that's changing for $dynamicRef in the next version is that it's a completely separate referencing system from $ref. Only anchor-like referencing will be allowed, which means it is simply incapable of referencing a boolean schema.

So these tests don't apply for draft/next.

Edit: I reference the conversation here but I think the bulk of it may have happened in slack and I can't find it.

},
{
"description": "false schema",
"data": { "false": 1 },
Copy link
Member

Choose a reason for hiding this comment

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

This branch of the test seems "uninteresting" / unrelated to this test case -- I assume it fails both before and after whatever bugfix you made. It seems more likely to be interesting/relevant if you put it behind a dynamic ref itself? i.e. #/$defs/true and #/$defs/false and fail when you hit false via the dynamicRef.

Copy link
Member Author

Choose a reason for hiding this comment

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

The intent is to show a way to a 'valid' state. Otherwise, a naive interpretation of the test should be that this input should always cause a validation failure. Do you have a suggestion for a better way to provide a valid data input?

Copy link
Member

Choose a reason for hiding this comment

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

The intent is to show a way to a 'valid' state.

(I was commenting on the invalid branch, which fails simply because it's equivalent to {"properties": {"foo": false}})

What I was trying to suggest instead above (albeit I don't know whether it exercises your specific bug you were targeting, but it seems like it should be the same) was to use this schema:

{
            "$defs": {
                "true": true,
                "false": false
            },
            "properties": {
                "true": {
                    "$dynamicRef": "#/$defs/true"
                },
                "false": { "$dynamicRef": "#/$defs/false" }
            }
        }

and to then have the two instances (and outcomes) be exactly the ones you have now I think.

@Julian Julian added the waiting for author A pull request which is waiting for an update from its author. label Nov 15, 2023
@karenetheridge
Copy link
Member Author

One of the things that's changing for $dynamicRef in the next version...

Has that change already landed, or is it planned to be done in the future?

@gregsdennis
Copy link
Member

Has that change already landed, or is it planned to be done in the future?

It hasn't yet. We have a task in the opening comment of the issue I linked, but that's it.

@karenetheridge
Copy link
Member Author

Ok, I fixed the tests to make the true and false branches look more alike, as you suggested. I also added $schema keywords as I believe we now require that.

I left the draft-next tests alone, as the specified behaviour of $dynamicRef has not yet changed; when it does, this test (along with some others I'm sure) will start failing in the test suite and we can fix/remove them then.

@gregsdennis
Copy link
Member

I left the draft-next tests alone, as the specified behaviour of $dynamicRef has not yet changed; when it does, this test (along with some others I'm sure) will start failing in the test suite and we can fix/remove them then.

I'm happy with that.

@karenetheridge karenetheridge merged commit 217bf81 into main Dec 10, 2023
3 checks passed
@karenetheridge karenetheridge deleted the ether/dynamicRef-boolean branch December 10, 2023 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for author A pull request which is waiting for an update from its author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants