3 ms·
> Do you use JSON Schema? No, but I don’t do much backend stuff, anymore. I’m totally anal about Quality, so I want to do things like jsonSchema. I used to de
by ChrisMarshallNY 4y ago
> Do you use JSON Schema?
No, but I don’t do much backend stuff, anymore.
I’m totally anal about Quality, so I want to do things like jsonSchema. I used to deliberately publish APIs in both JSON and XML, so that I could use XML Schema to validate the data, but JSON, to actually use it.
XML Schema is a huge PItA. I don’t like auto-generated Schema (see “anal,” above), so I tend to hand-tune (or write code to dynamically generate) my Schema.
The main reason I don’t use jsonSchema, is that I don’t have a real use for it, these days.
I mostly have internal APIs (proprietary backends), so there’s no need. I do have one backend that I recently wrote, that is public, and I may consider adding a published schema to it.
- bambax 4y ago> XML Schema is a huge PItA Yes. In the past I used to use Schematron; it's quite fun and extremely straightforward, although it's better described as a set of rules / tests than a tool to describe the structure of a document. https://en.wikipedia.org/wiki/Schematron https://en.wikipedia.org/wiki/Schematron A Schematron equivalent in JS would be cool. Maybe it already exists?
- michaelmior 4y agoIn some sense, JSON Schema does lean in that direction. In JSON Schema anything is valid except what you constrain. For example, the schema {} will accept any valid JSON. Anything you add to the schema is kind of like a test that further constraints the schema. If I say {"type": "object"}, now my schema will accept any valid object. If I add {"type": "object", "properties": {"foo": "string"}}, now if there is a property "foo", it must have type string. I can still have whatever other properties I want of whatever type.