json-schema-org / JSON-Schema-Test-Suite

A language agnostic test suite for the JSON Schema specifications
MIT License
610 stars 205 forks source link

Add tests for `$dynamicRef` keyword that contains JSON Pointer #600

Open flaksp opened 1 year ago

flaksp commented 1 year ago

Currently, all tests cover only the case where $dynamicRef contains a plain name fragment, e.g.:

{
  "$dynamicRef": "#items"
}

I believe we need more test cases because the question "what will happen if $dynamicRef will contain something but plain name fragment" seems to be popular from people like me who try to investigate how dynamic scope works. And it's confusing that there are no official examples nor in the spec and in the tests.

jdesrosiers commented 1 year ago

There are tests for initial resolution.

https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/main/tests/draft2020-12/dynamicRef.json#L259 https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/main/tests/draft2020-12/dynamicRef.json#L311

There should probably be a test for using a JSON Pointer in a dynamic reference. Using a JSON Pointer doesn't make sense for a dynamic reference, but it's not illegal. It would just behave like a normal reference. (FYI, weird edge cases like that are going away in the next release.)

flaksp commented 1 year ago

Oh, sorry, I missed them. I will rename the issue to mention only the JSON Pointer case.

Julian commented 1 year ago

Any chance you're interested in a PR @flaksp?

flaksp commented 1 year ago

Yeah. I'm learning how all these complicated things work and test cases will be very helpful for me 🙂