Open jviotti opened 1 year ago
I have almost zero experience with draft3, so I'll be pasting my findings here so anybody can correct me if I'm getting any of it wrong.
One key piece of Alterschema is teaching the tool how to "walk" over all the subschemas of a given schema by definition all possible applicator keywords. From skimming https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03, all the keywords that take subschemas in some way are:
properties
patternProperties
additionalProperties
items
additionalItems
dependencies
extends
See https://github.com/sourcemeta/alterschema/pull/86 for my initial definition take.
As per the rules, these are my findings so far (I'll be updating this comment with new findings):
type
supports any
, which was removed in Draft4. We should take care of it both on the string and array form of type
(https://github.com/sourcemeta/alterschema/pull/89)disallow
, which was removed in Draft4divisibleBy
, which I presume must be reworked as multipleOf
(https://github.com/sourcemeta/alterschema/pull/90)extends
, which was removed in Draft4format
keyword has some differences. Also, it seems that format
was optional in draft3
date
, time
, utc-millisec
, regex
, color
, style
and phone
were removed in draft4ip-address
was renamed to ipv4
host-name
was renamed to hostname
required
keyword use to be a boolean at the property levelI'm going to mix in a bit of draft 2 and 3 references to build a timeline of some of the keywords.
I'm no expert, so please correct me if i'm wrong.
optional
keyword accepts boolean in draft 2, replaced by required
in draft 3, required
updated to accept array of properties in draft 04maxDecimal
in draft 2 replaced by divisibleBy
in draft 3 and replaced again by multipleOf
in draft-04maximumCanEqual
in draft 2 accepts boolean, replaced by exclusiveMaximum
in draft 3, booleanminimumCanEqual
in draft 2 accepts boolean, replaced by exclusiveMinimum
in draft 3, booleanuniqueItems
added in draft 2 accepts booleanadditionalItems
added to type: array
in draft 3, accepts boolean or schemaalternate
removed in draft 3patternProperties
added in draft 3, expects regexid
added in draft 3, expects uri$ref
added in draft 3, expects uri$schema
added in draft 3, expects urirequires
replaced with dependencies
in draft 3**Dependencies** Two types available: Simple Dependency If the dependency value is a string, then the instance object MUST have a property with the same name as the dependency value. If the dependency value is an array of strings, then the instance object MUST have a property with the same name as each string in the dependency value's array. Schema Dependency If the dependency value is a schema, then the instance object MUST be valid against the schema
@jviotti You mentioned other work on adjacent projects would support this work, has there been any movement on those projects?
@jeremyfiel Yes, there is! I'm implementing some dialect-agnostic JSON Schema foundations here: https://www.jsontoolkit.org. The idea is for that project to eventually replace the engine we have here, so we can:
Feel free to watch that repo. Definitely not forgetting about this issue. I promise it will be fixed once those things are in place.
To support upgrading arbitrary draft 3 schemas, we need to define rules to upgrade draft 3 to draft 4.