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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 2Python 3

File details

Details for the file skinfer-0.1.0.tar.gz.

File metadata

  • Download URL: skinfer-0.1.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for skinfer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cfbf98ffaad13fb8bdc49c1387f9fb25cb04c6b872a0e8bf54dbccea784709e8
MD5 2979986cd14dac1a1c1c6867e7ba0e68
BLAKE2b-256 cdb79a5056ffa90b2f896674a749e1bdafd0429a47c1df1cb2e50a05a3a95799

See more details on using hashes here.

File details

Details for the file skinfer-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for skinfer-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 50320822ad7af704712d3f58ba7e464c41bf1569d9f51e35f606f15bfbd62ef2
MD5 8f77c1f3562d84e3d38067f6f3afb678
BLAKE2b-256 4516154d269ca108c5baa7b231d0897dfd4e2a5a8f85f4721a21a5e3e14de823

See more details on using hashes here.

Supported by

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