Skip to main content

Simple tool to infer and/or merge JSON schemas

Project description

https://badge.fury.io/py/skinfer.png https://travis-ci.org/scrapinghub/skinfer.png?branch=master https://pypip.in/d/skinfer/badge.png

Simple tool to infer and/or merge JSON schemas

Features

Use schema_inferer to generate a schema from a list of samples:

$ cat samples.json
{"name": "Claudio", "age": 29}
{"name": "Roberto", "surname": "Gomez", "age": 72}
$ ./bin/schema_inferer --jsonlines samples.json
{
    "$schema": "http://json-schema.org/draft-04/schema",
    "required": [
        "age",
        "name"
    ],
    "type": "object",
    "properties": {
        "age": {
            "type": "number"
        },
        "surname": {
            "type": "string"
        },
        "name": {
            "type": "string"
        }
    }
}

Use json_schema_merger to merge a list of JSON schemas into one JSON schema that represents the common properties:

$ cat schema1.json  # schema requiring name and age properties
{
    "$schema": "http://json-schema.org/draft-04/schema",
    "required": [
        "age",
        "name"
    ],
    "type": "object",
    "properties": {
        "age": {
            "type": "number"
        },
        "name": {
            "type": "string"
        }
    }
}
$ cat schema2.json  # schema with no age, but requiring name
{
    "$schema": "http://json-schema.org/draft-04/schema",
    "required": [
        "name"
    ],
    "type": "object",
    "properties": {
        "name": {
            "type": "string"
        }
    }
}
$ ./bin/json_schema_merger schema1.json schema2.json
{
    "$schema": "http://json-schema.org/draft-04/schema",
    "required": [
        "name"
    ],
    "type": "object",
    "properties": {
        "age": {
            "type": "number"
        },
        "name": {
            "type": "string"
        }
    }
}

History

0.1.0 (2015-03-03)

  • First release on PyPI.

Project details


Download files

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

Source Distribution

skinfer-0.1.0.tar.gz (19.4 kB view hashes)

Uploaded Source

Built Distribution

skinfer-0.1.0-py2.py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page