Skip to main content

A Python DSL for defining JSON schemas

Project description

Build Status Coverage Documentation PyPI Version PyPI Downloads

Documentation | GitHub | PyPI

JSL is a Python DSL for defining JSON Schemas.


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),
    ]), required=True)

Directory.get_schema(ordered=True) will return the following JSON schema:

    "$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"


pip install jsl


BSD license

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for jsl, version 0.2.4
Filename, size File type Python version Upload date Hashes
Filename, size jsl-0.2.4.tar.gz (21.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page