I like JSON schema, but I haven't found any good tools to designing them. Or at least not a few years ago when I was looking. However, we already had an XMLSpy license, so decided to just stick with designing XSDs in XMLSpy and then just translate that to JSON Schema. If you make some small decisions, like value with attributes becomes an object, you can get a fairy decent subset of XSD to map 1:1 onto JSON Schema 20…
JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
31–40 of 40 posts
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#32I like JSON schema, but I haven't found any good tools to designing them. Or at least not a few years ago when I was looking. However, we already had an XMLSpy license, so decided to just stick with designing XSDs in XMLSpy and then just translate that to JSON Schema. If you make some small decisions, like value with attributes becomes an object, you can get a fairy decent subset of XSD to map 1:1 onto JSON Schema 20…
Yes, I've been searching for a long time for a good solution to allow non-coding people to visually design JSON Schemas. The closest thing I found is the schema editor in the amazing Stoplight service, but that is sadly not open source.
It's not a problem for a dozen properties, but we have several hundreds in our larger schemas, even accounting for them being fairly normalized w.r.t. types. And five or more levels of nesting turns into an effective ten plus levels in the schema.
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#33Earlier quoted context omitted.
Yes, I've been searching for a long time for a good solution to allow non-coding people to visually design JSON Schemas. The closest thing I found is the schema editor in the amazing Stoplight service, but that is sadly not open source.
Heck, I'm a coder and I get lost when just dealing with the raw JSON Schema. It's not a problem for a dozen properties, but we have several hundreds in our larger schemas, even accounting for them being fairly normalized w.r.t. types. And five or more levels of nesting turns into an effective ten plus levels in the schema.
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#34JSON schema is nice overall* but every software only supports ancient versions like draft 4 *even if I would prefer more transformation/conversion features that would bring it to more more a parser rather than only a validator
Not really true? There are lots of validators supporting the most recent version: https://json-schema.org/tools?query=&sortBy=name&sortOrder=a...
I agree that it is easy to implement a recent version in your own code, what I meant is that a lot of the tools/software you might want to use JSON Schema with (eg mongodb validation) only support old versions
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#35Earlier quoted context omitted.
Heck, I'm a coder and I get lost when just dealing with the raw JSON Schema. It's not a problem for a dozen properties, but we have several hundreds in our larger schemas, even accounting for them being fairly normalized w.r.t. types. And five or more levels of nesting turns into an effective ten plus levels in the schema.
One underutilised feature of JSON Schema is referencing external schemas and reusing them in multiple places, rather than copying them over and over again. The main hurdle to a better use of this feature is the lack of a good standard for schema repositories; I've been working on addressing this, but it's difficult to find the time. :/
Yeah, though while it does make each subschema somewhat more readable and contained, you still don't get a good overview. If you're reading the spec for a given object, do you don't easily see where it's being used in the schema.
For now I've just supplied the JSON Schema as a self-contained thing, and deferred other parties to the XSD to get an overview. The self-contained makes it trivial to load into a validator and such.
So while it helps for knowing what to fill into that exact object, it doesn't help for getting a feel for the overall schema. This is where the visual view of tools such as XMLSpy really helps.
> lack of a good standard for schema repositories
Interesting, do you have something public to show? For our large ones I feel they'd be entirely custom anyway, but perhaps I can see standard sub-schemas useful for other tasks. Would be interesting to have a look.
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#36JSON schema was nice when it was simple. Now it feels like writing a validator is extremely complicated. IMO, the built-in vocabularies were enough, and keeping it simple would provide more value. JSON as a format didn't win because it supported binary number encoding or could be extended with custom data types -- but rather because it couldn't.
This and schema support for JSON will always be an ill fitting afterthought. If you really, really need the strictness and correctness (and you most probably don't) XML has you covered.
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#37Earlier quoted context omitted.
One underutilised feature of JSON Schema is referencing external schemas and reusing them in multiple places, rather than copying them over and over again. The main hurdle to a better use of this feature is the lack of a good standard for schema repositories; I've been working on addressing this, but it's difficult to find the time. :/
> One underutilised feature of JSON Schema is referencing external schemas and reusing them in multiple places Yeah, though while it does make each subschema somewhat more readable and contained, you still don't get a good overview. If you're reading the spec for a given object, do you don't easily see where it's being used in the schema. For now I've just supplied the JSON Schema as a self-contained thing, and defer…
True, when focusing only on the schemas as code. But good tooling could provide links and similar.
> do you have something public to show
Just a very early PoC [0]. I'm slowly working my way through a very long to-do list of improvements, but I'm lacking time and resources to do it more efficiently.
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#38JSON schema was nice when it was simple. Now it feels like writing a validator is extremely complicated. IMO, the built-in vocabularies were enough, and keeping it simple would provide more value. JSON as a format didn't win because it supported binary number encoding or could be extended with custom data types -- but rather because it couldn't.
This and schema support for JSON will always be an ill fitting afterthought. If you really, really need the strictness and correctness (and you most probably don't) XML has you covered.
I also often make heavy use of schema based editors to auto-generate UI.
Perhaps I'd feel differently if I ever had to write a validator myself, but they seem to exist in all the popular languages as is.
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#39The metaschemas are useful but not strict enough. They don't set `additionalProperties: false`, which is great if you wanna extend the schema with your own properties, but it won't catch simple typos. For example, the following issues pass under the metaschema. {"foo": {"bar": { ... }}} # wrong {"foo": {"type": "object", "properties": {"bar": { ... }}}} # correct {"additional_properties": false} # wrong {"additionalP…
This is intentional because unknown keywords are permitted with JSON Schema 2020-12 and prior. We are changing this with the upcoming version, which means we'll be updating the meta-schema to enforce it as well.
Re: JSON Schema Demystified: Dialects, Vocabularies and Metaschemas
#40Earlier quoted context omitted.
> No one should be using 3.0.x anymore Many users are stuck at 3.0 or even Swagger 2.0 because the libraries they use refuse to support recent versions. Also OpenAPI is still not a strict superset because things like `discriminator` are still missing in JSON schema.
This. If you're building a brand new, multi-language, multi-platform system that uses advanced open-api features - you will get bitten by lack of support in 3.1 versions of tooling for features that already existed and work fine right now in 3.0 tool versions. Especially if you're using a schema-first workflow (which you should be). For example, $ref's to files across windows/linux/macos across multiple different lan…