Need help with jsl?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

aromanovich
206 Stars 23 Forks Other 127 Commits 10 Opened issues

Description

A Python DSL for describing JSON schemas

Services available

!
?

Need anything else?

Contributors list

# 243,982
Shell
CSS
Flask
service...
105 commits
# 130,193
Flask
openapi
CSS
web-gui
4 commits
# 152,558
Rust
propert...
rhel
python3
2 commits
# 289,227
HTML
CSS
aiohttp
microse...
1 commit
# 590,219
Python
Shell
Bioinfo...
chemist...
1 commit
# 232,864
CSS
Shell
Django
mapnik
1 commit

JSL

.. image:: https://travis-ci.org/aromanovich/jsl.svg?branch=master :target: https://travis-ci.org/aromanovich/jsl :alt: Build Status

.. image:: https://coveralls.io/repos/aromanovich/jsl/badge.svg?branch=master :target: https://coveralls.io/r/aromanovich/jsl?branch=master :alt: Coverage

.. image:: https://readthedocs.org/projects/jsl/badge/?version=latest :target: https://readthedocs.org/projects/jsl/ :alt: Documentation

.. image:: http://img.shields.io/pypi/v/jsl.svg :target: https://pypi.python.org/pypi/jsl :alt: PyPI Version

Documentation_ | GitHub_ | PyPI_

JSL is a Python DSL for defining JSON Schemas.

Example

.. code:: python

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:

.. code:: json

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

BSD license
_

.. _Documentation: https://jsl.readthedocs.io/ .. _GitHub: https://github.com/aromanovich/jsl .. _PyPI: https://pypi.python.org/pypi/jsl .. _BSD license: https://github.com/aromanovich/jsl/blob/master/LICENSE

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.