跳转到主要内容

用于定义JSON模式的Python DSL

项目描述

Build Status Coverage Documentation PyPI Version PyPI Downloads

文档 | GitHub | PyPI

JSL是用于定义JSON模式的Python DSL。

示例

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)将返回以下JSON模式

{
    "$schema": "https://json-schema.fullstack.org.cn/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"
}

安装

pip install jsl

许可证

BSD许可证

项目详情


下载文件

下载适合您平台文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。

源分布

jsl-0.2.4.tar.gz (21.0 kB 查看哈希值)

上传于 来源

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面