-
-
Notifications
You must be signed in to change notification settings - Fork 216
extended tests for json-pointer format #186
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
Conversation
Well, there are 2 tests failing, as expected. ajv supports "JSON String representation" and "URI Fragment Identifier Representation", but the last one shouldn't be valid. |
@CroniD I will have a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CroniD Given that RFC6901 defines both JSON string and URI fragment formats for JSON pointer and that the JSON-Schema spec doesn't limit the format to JSON string, I don't think we should have tests here that require that URI fragment format is invalid - I believe that the tests should either be changed to make them valid or just removed to leave this question to the implementations discretion. I don't have any preference which way this is changed in this PR - "not a valid JSON-pointer (URI Fragment Identifier Representation) #1/2" should be either removed or changed to "valid".
We can change it this way or another in the next version of JSON schema spec (i.e. to explicitly specify URI fragment JSON pointer to be valid/invalid according to "json-pointer" format in the schema). I don't have particularly strong opinion how it should be in draft-07, but in draft-06 it should stay the way it is formulated in the spec.
Also, can you please change the order so that the tests that were not changed do not show as both removed and added, so it is easier to see what is added?
@epoberezkin I am asserting that a bug in the spec (careless language) produced incorrect guidance. Having a test suite that enforces the correct, intended behavior, will help us keep that behavior going forwards. Or do you suggest inverting the minimum/maximum test cases because of the copy-paste errors in those keywords in draft-06? It's fine to stay with odd behavior if that odd behavior was the intent of a spec, but a bug is a bug and we should not write tests that re-enforce the bug. |
The example given to justify adding the json-pointer format is quite clearly NOT talking about using it as a URI fragment: json-schema-org/json-schema-spec#109 |
I would also argue that, given that the ABNF for JSON Pointer in RFC 9601 has nothing to do wth URI syntax, and the format is specified to apply to JSON Strings, that the JSON String representation is pretty clearly intended to be used. There was ZERO discussion of using URI fragments with this format that I can find. Any such usage is incorrect and should be caught by the test suite. We will also improve the language. |
As I wrote, it's ok to remove those tests and leave the decision to implementations until the point when we agree in which way it should be clarified.
Do we have a copy paste error in the spec or is it just a sarcasm? In any case, the analogy is completely invalid - allowing URI fragments makes sense. Inverting test cases for minimum/maximum makes no sense. Also, the spec is primary (normative), the tests are secondary (informative), using tests to clarify the spec is not a valid approach. @awwright would agree I think. |
@handrews I think that the argument in the second paragraph of https://tools.ietf.org/html/rfc6901#section-6 is supportive of what you write. @CroniD I suggest a couple of options then - 1) remove the tests in question, merge this PR, then make another PR with these two tests and merge when I update Ajv. 2) wait till I update the Ajv (a week or so) and then merge. 3) update json-pointer format that Ajv uses in the test here: I don't think skipping the tests completely would be a good idea. In any case, could you please change the order so it's clear what's added. |
Hi all, @epoberezkin I know that most people think "JSON String representation" and "URI Fragment Identifier Representation" of Json Pointer are interchangeable when talking about what is "a valid Json Pointer", but it really isn't (strictly speaking). "valid" usually refers to something that one can verify based on rules. RFC6901 defines syntax rules. In that way, a Json Pointer in it's "URI Fragment Identifier Representation" isn't syntactical valid. Tbh, this applies to "JSON String representation" as well, because the json pointer syntax doesn't define any json-specific escape mechanism, but since a json schema is something like a json text, the escaping mechanism is inherently defined. That's why the "JSON String representation" is close to what a "valid json pointer" means in a json schema, a valid json pointer in a json text. As @handrews mentioned, it's a bug. Well, strictly speaking it's a bug. BTW: Is ajv considered to be the current reference implementation of a json schema validator? If not, why execute the tests automatically specifically with ajv? Json syntax checks are fine, but test execution is odd. Nevertheless, I think option 2 is good for me. :) About the order of the tests: I re-worked the hole section, but it's kinda strange in the diff view. I'll try to change it, so it's more clear what's changed. :) Best regards |
@CroniD ajv is not the reference implementation (there is no reference implementation), but of the two implementation owners actively involved in the process, @epoberezkin has had more time recently to implement draft-06 and extend the test suite for it. AFAIK ajv is still the only full draft-06 implementation, although I know @Julian is working on it in Python and others have at least started looking at it. |
@epoberezkin I think the key wording in that section you linked is here (bolded emphasis mine):
Saying that it can be represented in a URI fragment identifier is not the same thing as saying that it can be represented as a URI fragment identifier. The previous section uses the same wording about JSON strings, but since this standard is about working with JSON we're already working with the contents of JSON strings in all cases. So in a JSON document, a string "#/foo/bar" is a JSON string containing a fragment identifier #/foo/bar which itself contains a JSON Pointer /foo/bar. Therefore in terms of format, "#/foo/bar" is a uri-reference, not a json-pointer on its own. |
It is merged via command line. Usually github understands it... |
See also json-schema-org/json-schema-spec#328