-
-
Notifications
You must be signed in to change notification settings - Fork 215
adding specification enhancement for additionalProperties 2020-12 #726
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
test-schema.json
Outdated
"jsonschema": {"type": "string"}, | ||
"rfc": {"type": "string"} |
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.
Are these both URIs?
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.
They are URL's for a particular section in the JSON Schema Spec. They will redirect to the location where test-case is more relevant.
They are supposed to be, can add regex if pattern matching for scheme is required
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.
Is the structure of "specification" property supposed to be something else
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.
- These are supposed to be informative comments. It's not really anything that needs to be linked to. We really just need some sort of reference. I think just the spec name and section number will suffice.
which would give something like
"additionalProperties": { "type": "string", "pattern": "^[0-9](\.[0-9])*$"} }
{ "core": "8.5.2", "validation": "6.3" }
- What are "jsonschema" and "rfc" intended to refer to?
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.
2.. Actually each section of the draft has many paragraphs, and each paragraph has unique URI's.
like, https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-2 URI will redirect to paragraph 2 of "additionalProperties" section.
So, I thought why not that can be made use. And rfc -> too an URI for any section of RFC the description of the test located in.
- Wouldn't it make test cases bigger. And also we can provide more precise location using URLs. So, why not URI's?
- as we may need to provide multiple uris?
- usability of
{
"core": "8.5.2",
"validation": "6.3"
}
``` this will be greater??
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.
https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-10.3.2.3-2
If you look at this format it has a common pattern.
https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-
<section>-<para>
I think it'd be better just to include the last part of that, the section and paragraph. If desired, tooling can construct the URL. The spec name (core
/validation
) indicates which document were referring to.
Again, this is just a reference for documentation purposes. It doesn't need to be functional.
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.
I totally got that. We can have spec name: core/validation and for rfc: rfc3456/rfc4567 or ...
Then we can have---> section
---> para
So, mostly 3-4 indicators. Right? ❤️🔥
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.
@Julian what is the philosophy of tests for requirements like "behaves per X spec, section Y"? Do we include tests checking behavior against other specs?
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.
Like why would we include that info? Yeah we definitely have lots of that, see e.g. all the format tests, all of which essentially are testing behavior specified in some other specification and generally RFC.
But def fine to leave it out to start I think.
(I haven't read the rest of the thread yet!)
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.
Can the example structure for a test-case be:
{
"specification":{
"jsonschema-validation":{
"section": "6.3.1",
"para": "3"
},
"rfc8259":{
"section": 7
},
// "jsonschema-core":{...}
}
}
and because there may be more than one place in spec, we can make for example:
"jsonschema-validation":[{
"section": "6.3.1",
"para": "3"
},
{
"section": "6.3.1",
"para": "4"
}]
can keep it such that "jsonschema-validation"
can take both array and object..
And instead of asking can I make as many commits as possible and then take comments?
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.
Some comments from me, though I agree with the other 2 as well, though the schema here is obviously what we need to work out to start.
test-schema.json
Outdated
@@ -27,6 +27,20 @@ | |||
"type": "array", | |||
"items": { "$ref": "#/$defs/test" }, | |||
"minItems": 1 | |||
}, | |||
"specification":{ | |||
"description": "Location of the test case in the specification", |
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.
It's not just "the" specification, given it can either be the JSON Schema specification or some other specification. Probably we should elaborate here with some guidance for how to use this, specifically:
"description": "Location of the test case in the specification", | |
"description": "A reference to a specification document which defines the behavior tested by this test case. Typically this should be a JSON Schema specification document, though in cases where the JSON Schema specification points to another RFC it should contain *both* the portion of the JSON Schema specification which indicates what RFC (and section) to follow as *well* as information on where in that specification the behavior is specified.", |
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.
Got this 👍
test-schema.json
Outdated
}, | ||
"specification":{ | ||
"description": "Location of the test case in the specification", | ||
"type": "object", |
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.
I suspect an array is more correct here actually , which would allow referencing multiple locations, perhaps even within one spec.
(Or if we want to get fancy at the expense of making it harder to parse we could do oneOf: [{items: spec}, spec]
and allow either a spec or else an array of specs. But always requiring an array seems fine to me personally.)
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.
Concluding this, which of them is better to be chosen:
"specifications": [ { "core": "6.7.1", "quote": "Lorem" }, { "core": "7.4.3" }, { "validation": "12.2.1" } ]
"specification": [
{ "core" : [
{"section": "6.7.1", "quote": "Lorem" },
{"section": "7.4.3", "quote": "LoremEpsom" } ]
},
{ "validation": [ {"section": "12.2.1", "quote": "Example quote" } ] }
]
- specification is an object:
"specification": {
{ "core" : [
{"section": "6.7.1", "quote": "Lorem" },
{"section": "7.4.3", "quote": "LoremEpsom" } ]
},
{ "validation": [ {"section": "12.2.1", "quote": "Example quote" } ] }
}
I felt first one is simpler, but doesn't mention its value is a "section" explicitely
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.
Always having an array is easier to handle in some languages.
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.
Concluding this, which of them is better to be chosen:
I'd go with number 1 personally.
Always having an array is easier to handle in some languages.
Makes sense.
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.
great
test-schema.json
Outdated
"type": "object", | ||
"minProperties": 1, | ||
"properties": { | ||
"jsonschema-core": { "$ref": "#/$defs/spec"}, |
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.
core
and validation
are going to be the most common values here so I think it's fine to leave off the jsonschema
.
Also I doubt this reference (spec
) will be useful anywhere else except within this subschema, so I'd put it here for readability personally, rather than below.
test-schema.json
Outdated
"ecma262": { "$ref": "#/$defs/spec"} | ||
}, | ||
"patternProperties": { | ||
"^rfc[0-9]{4}$": {"$ref": "#/$defs/spec"} |
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.
(RFCs are not always 4 digits long.)
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.
I see some RFC names are defines like this: RFC 3162 (IPv6), RFC 1058 (v.1), RFC 2080 (v.ng), RFC 23
All RFC's have 2- 4 digits, most RFC's used in spec arent using aany of first three. So, just matching for digits is good?
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.
Yes, probably just "1 or more digits" is fine.
test-schema.json
Outdated
"properties": { | ||
"section": { | ||
"type": "string", | ||
"pattern": "^\\d+(\\.\\d+)*\\.$" |
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.
This seems wrong (in that it ends in a period -- presumably that's simply a formatting period if it appears in the doc) but also too specific to me. Not all specifications will have this form of heading sections, it's perfectly believable that one will use e.g. letters in the section names, so I.2.IV
or whatever.
I see @gregsdennis left you some helpful comments, I'd read those, and then probably we could even consider having different definitions of section
depending on the allowed specification values if we really want to make sure they're correct.
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.
The regex I left was an example, if we wanted to even enforce such a thing.
Julian has a good point about section numbering not being consistent across specs.
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.
So, sections can also contain 1.A, 1.2.B, I.V.1.a, anything right ? so we can check for only periods in between?
test-schema.json
Outdated
"type": "string", | ||
"pattern": "^\\d+(\\.\\d+)*\\.$" | ||
}, | ||
"para": { |
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.
I don't like abbreviations personally, but also I don't think paragraph numbers are that much fun, they're hard both for the person writing the thing as well as the reader, both of whom have to count to find what they want.
Ideally everything should have its own anchor and/or section link though certainly they do not today, but I think probably the right thing to do there is quote
-- i.e. a field that simply allows someone to copy-paste some substring from the spec to put here, and then they copy paste a sentence or so.
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.
Maybe this should be used sparingly, like only when the section alone isn't sufficient.
I also agree with the abbreviation thing, especially considering that users of the test suite don't necessarily understand English. Abbreviations in foreign language are really hard, in general.
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.
Yes definitely agree there!
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.
Got this one too
Hi @Julian @gregsdennis @karenetheridge I have updated my PR |
"type": "array", | ||
"minItems": 1, | ||
"items":{ | ||
"properties": { |
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.
I think all the values here will be (should be) strings, so probably you can/should use propertyNames
here (probably with a oneOf
+ enum
+ pattern
).
@@ -2,6 +2,7 @@ | |||
{ | |||
"description": | |||
"additionalProperties being false does not allow other properties", | |||
"specification": [ { "core":"10.3.2.3", "quote": "The value of \"additionalProperties\" MUST be a valid JSON Schema. Boolean \"false\" forbids everything." } ], |
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.
A good follow up (to this ticket, perhaps even before we go much further) would be to make CI annotate pull requests with links to the section.
It'd be a lot easier to check whether this was correct if something were annotating the review with a link to this section.
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.
So, for each version of the draft, we should add different "baseURI's" right which should append and check whether the the redirection to the section is failing or not?
And Ci script should be written separately for that.. I am new to this, may take time. But i'll do it
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.
Probably custom logic for each specification which knows what the right URL is given what we have put in the corresponding field, yes, which the simplest version is just "a base URI".
But exactly right. Some CI script for that, which annotates PRs, and warns for broken links.
Can you perhaps immediately open an issue at least so we don't forget about it? Then yeah if you give it a shot that'd be amazing.
For the validation and core specifications metadata: "url" there can be multiple versions of drafts: because the test-schema is same for all dialects. |
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.
I'm happy with this. @Julian has final say.
"pattern": "^((iso)|(rfc))[0-9]+$" | ||
}, | ||
{ | ||
"enum": [ "core", "validation", "ecma262", "perl5", "quote" ] |
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.
Considering we need this enum and that IIRC propertyNames
doesn't affect unevaluatedProperties
(meaning we can't use that instead of the additionalProperties
above) my suggestion (to use propertyNames
was probably bad, but whatever, we can evolve the schema later if need be. Thanks for putting this in.
Thanks! This looks good to me too, well done. |
For now we do nothing with this, maybe at some point there will be some way it's useful to use in Bowtie itself. Refs: json-schema-org/JSON-Schema-Test-Suite#726
Cool, then lets go ahead.❤️🔥 |
For some test-cases I could not find the exact location where test-case can refer perfectly
I am making this first PR on Test-Suite please guide me if I need correction or even completely wrong