A Python DSL for defining JSON schemas
Project description
Documentation | GitHub | PyPI
JSL is a Python DSL for defining JSON Schemas.
Example
import jsl class Entry(jsl.Document): name = jsl.StringField(required=True) class File(Entry): content = jsl.StringField(required=True) class Directory(Entry): content = jsl.ArrayField(jsl.OneOfField([ jsl.DocumentField(File, as_ref=True), jsl.DocumentField(jsl.RECURSIVE_REFERENCE_CONSTANT) ]), required=True)
Directory.get_schema(ordered=True) will return the following JSON schema:
{ "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "directory": { "type": "object", "properties": { "name": {"type": "string"}, "content": { "type": "array", "items": { "oneOf": [ {"$ref": "#/definitions/file"}, {"$ref": "#/definitions/directory"} ] } } }, "required": ["name", "content"], "additionalProperties": false }, "file": { "type": "object", "properties": { "name": {"type": "string"}, "content": {"type": "string"} }, "required": ["name", "content"], "additionalProperties": false } }, "$ref": "#/definitions/directory" }
Installing
pip install jsl
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsl-0.1.3.tar.gz
(20.2 kB
view details)
File details
Details for the file jsl-0.1.3.tar.gz
.
File metadata
- Download URL: jsl-0.1.3.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 599ae94faac499d536f50a318fb6d21fd67f466392b4f11c0f85313a8769caef |
|
MD5 | 9846edd1248f304dac2743c3e59307c3 |
|
BLAKE2b-256 | 11f1b15b45563883e63a433be73b92a7f7cacb4db82ca4f95b3a487a08463229 |