How to manage multiple JSON schema files?

In JSON Schemas, you can either put a schema per file and then access them using their URL (where you stored them), or a big schema with id tags. Here is for one big file: { “id”: “#root”, “properties”: { “author”: { “id”: “#author”, “properties”: { “first_name”: { “type”: “string” }, “last_name”: { “type”: “string” … Read more

Using RegEx in JSON Schema

To test a string value (not a property name) against a RegEx, you should use the “pattern” keyword: { “type”: “object”, “properties”: { “progBinaryName”: { “type”: “string”, “pattern”: “^[A-Za-z0-9 -_]+_Prog\\.(exe|EXE)$” } } } P.S. – if you want the pattern to match the key for the property (not the value), then you should use “patternProperties” … Read more

Correct JSON Schema for an array of items of different type

I asked this same question on the JSON schema google group, and it was answered quickly. User fge asked that I post his response here: Hello, The current specification is draft v4, not draft v3. More specifically, the validation specification is here: https://datatracker.ietf.org/doc/html/draft-fge-json-schema-validation-00 The web site is not up to date, I don’t know why… … Read more

Convert a JSON schema to a python class

So far the closest thing I’ve been able to find is warlock, which advertises this workflow: Build your schema >>> schema = { ‘name’: ‘Country’, ‘properties’: { ‘name’: {‘type’: ‘string’}, ‘abbreviation’: {‘type’: ‘string’}, }, ‘additionalProperties’: False, } Create a model >>> import warlock >>> Country = warlock.model_factory(schema) Create an object using your model >>> sweden … Read more

Dictionary-like JSON schema

additionalProperties is your keyword: { “type” : “object”, “additionalProperties” : { “type” : “object”, “required” : [ “age”, “gender” ], “properties” : { “age” : { “type” : “string” }, “gender” : { “type” : “string” } } } } additionalProperties can have the following values with different meanings: “additionalProperties”: false No more properties are … Read more

How to extend a schema in JSON schema?

JSON Schema doesn’t use an object oriented paradigm, so concepts like inheritance don’t translate well. JSON Schema is a collection of constraints. It’s subtractive rather than additive like most people are used to. This means that given an empty schema, the set of valid JSON documents is the set of all JSON documents. As you … Read more

JSON Schema – specify field is required based on value of another field

This is definitely possible with version 3 of the draft. Since you have a complete list of allowed countries, then you could do something like this: { “type”: [ { “title”: “New Zealand (no postcode)”, “type”: “object”, “properties”: { “country”: {“enum”: [“NZ”, “NZL”, “NEW ZEALAND”]} } }, { “title”: “Other countries (require postcode)”, “type”: “object”, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)