Skip to main content

Linux Build Status Code coverage Documentation Status CII Best Practices

Schema Salad

Salad is a schema language for describing JSON or YAML structured linked data documents. Salad schema describes rules for preprocessing, structural validation, and hyperlink checking for documents described by a Salad schema. Salad supports rich data modeling with inheritance, template specialization, object identifiers, object references, documentation generation, code generation, and transformation to RDF. Salad provides a bridge between document and record oriented data modeling and the Semantic Web.

The Schema Salad library is Python 3.6+ only.

Installation

pip3 install schema_salad

If you intend to use the schema-salad-tool –codegen=python feature, please include the [pycodegen] extra:

pip3 install schema_salad[pycodegen]

To install from source:

git clone https://github.com/common-workflow-language/schema_salad
cd schema_salad
pip3 install .
# or pip3 install .[pycodegen] if needed

Commands

Schema salad can be used as a command line tool or imported as a Python module:

$ schema-salad-tool
usage: schema-salad-tool [-h] [--rdf-serializer RDF_SERIALIZER] [--skip-schemas]
                      [--strict-foreign-properties] [--print-jsonld-context]
                      [--print-rdfs] [--print-avro] [--print-rdf] [--print-pre]
                      [--print-index] [--print-metadata] [--print-inheritance-dot]
                      [--print-fieldrefs-dot] [--codegen language] [--codegen-target CODEGEN_TARGET]
                      [--codegen-examples directory] [--codegen-package dotted.package]
                      [--codegen-copyright copyright_string] [--print-oneline]
                      [--print-doc] [--strict | --non-strict]
                      [--verbose | --quiet | --debug] [--only ONLY] [--redirect REDIRECT]
                      [--brand BRAND] [--brandlink BRANDLINK] [--brandstyle BRANDSTYLE]
                      [--brandinverse] [--primtype PRIMTYPE] [--version]
                      [schema] [document]

$ python
>>> import schema_salad

Validate a schema:

$ schema-salad-tool myschema.yml

Validate a document using a schema:

$ schema-salad-tool myschema.yml mydocument.yml

Generate HTML documentation:

$ schema-salad-tool --print-doc myschema.yml > myschema.html
$ # or
$ schema-salad-doc myschema.yml > myschema.html

Get JSON-LD context:

$ schema-salad-tool --print-jsonld-context myschema.yml mydocument.yml

Convert a document to JSON-LD:

$ schema-salad-tool --print-pre myschema.yml mydocument.yml > mydocument.jsonld

Generate Python classes for loading/generating documents described by the schema (Requires the [pycodegen] extra):

$ schema-salad-tool --codegen=python myschema.yml > myschema.py

Display inheritance relationship between classes as a graphviz ‘dot’ file and render as SVG:

$ schema-salad-tool --print-inheritance-dot myschema.yml | dot -Tsvg > myschema.svg

Quick Start

Let’s say you have a ‘basket’ record that can contain items measured either by weight or by count. Here’s an example:

basket:
  - product: bananas
    price: 0.39
    per: pound
    weight: 1
  - product: cucumbers
    price: 0.79
    per: item
    count: 3

We want to validate that all the expected fields are present, the measurement is known, and that “count” cannot be a fractional value. Here is an example schema to do that:

- name: Product
  doc: |
    The base type for a product.  This is an abstract type, so it
    can't be used directly, but can be used to define other types.
  type: record
  abstract: true
  fields:
    product: string
    price: float

- name: ByWeight
  doc: |
    A product, sold by weight.  Products may be sold by pound or by
    kilogram.  Weights may be fractional.
  type: record
  extends: Product
  fields:
    per:
      type:
        type: enum
        symbols:
          - pound
          - kilogram
      jsonldPredicate: '#per'
    weight: float

- name: ByCount
  doc: |
    A product, sold by count.  The count must be a integer value.
  type: record
  extends: Product
  fields:
    per:
      type:
        type: enum
        symbols:
          - item
      jsonldPredicate: '#per'
    count: int

- name: Basket
  doc: |
    A basket of products.  The 'documentRoot' field indicates it is a
    valid starting point for a document.  The 'basket' field will
    validate subtypes of 'Product' (ByWeight and ByCount).
  type: record
  documentRoot: true
  fields:
    basket:
      type:
        type: array
        items: Product

You can check the schema and document in schema_salad/tests/basket_schema.yml and schema_salad/tests/basket.yml:

$ schema-salad-tool basket_schema.yml basket.yml
Document `basket.yml` is valid

Documentation

See the specification and the metaschema (salad schema for itself). For an example application of Schema Salad see the Common Workflow Language.

Rationale

The JSON data model is an popular way to represent structured data. It is attractive because of it’s relative simplicity and is a natural fit with the standard types of many programming languages. However, this simplicity comes at the cost that basic JSON lacks expressive features useful for working with complex data structures and document formats, such as schemas, object references, and namespaces.

JSON-LD is a W3C standard providing a way to describe how to interpret a JSON document as Linked Data by means of a “context”. JSON-LD provides a powerful solution for representing object references and namespaces in JSON based on standard web URIs, but is not itself a schema language. Without a schema providing a well defined structure, it is difficult to process an arbitrary JSON-LD document as idiomatic JSON because there are many ways to express the same data that are logically equivalent but structurally distinct.

Several schema languages exist for describing and validating JSON data, such as JSON Schema and Apache Avro data serialization system, however none understand linked data. As a result, to fully take advantage of JSON-LD to build the next generation of linked data applications, one must maintain separate JSON schema, JSON-LD context, RDF schema, and human documentation, despite significant overlap of content and obvious need for these documents to stay synchronized.

Schema Salad is designed to address this gap. It provides a schema language and processing rules for describing structured JSON content permitting URI resolution and strict document validation. The schema language supports linked data through annotations that describe the linked data interpretation of the content, enables generation of JSON-LD context and RDF schema, and production of RDF triples by applying the JSON-LD context. The schema language also provides for robust support of inline documentation.

Metadata

Release files for schema-salad 8.2.20220103095339

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schema-salad 8.2.20220103095339
File Size Uploaded
schema-salad-8.2.20220103095339.tar.gz 479.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for schema-salad 8.2.20220103095339
File
schema_salad-8.2.20220103095339-py3-none-any.whl Python 3 none any Details
schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ ARM64 Details
schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.12+ x86-64, Linux glibc 2.5+ x86-64 Details
schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ ARM64 Details
schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.12+ x86-64, Linux glibc 2.5+ x86-64 Details
schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ ARM64 Details
schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64, Linux glibc 2.12+ x86-64 Details
schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details
schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ ARM64 Details
schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64, Linux glibc 2.12+ x86-64 Details

Total release size: 31.3 MB

Release files / schema-salad-8.2.20220103095339.tar.gz

Download URL schema-salad-8.2.20220103095339.tar.gz
Size 479.1 kB
Tags Source
SHA-256 checksum
How to use checksums
051690a2f89b98e35100cd2cb489406a5169a60c2f27a716f3f287a42d45be2d
BLAKE2b-256 checksum
How to use checksums
8e904a2cc012f32a39864372855c2fe06e2976cedf1e18844c17debc30a13c7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / schema_salad-8.2.20220103095339-py3-none-any.whl

Download URL schema_salad-8.2.20220103095339-py3-none-any.whl
Size 511.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea54e6606ecacaa5a2453532aa8e78b38154c34aa99167f8ccfa92f914a72f2c
BLAKE2b-256 checksum
How to use checksums
a140e6e6efdf46f1eedee08f41430dc9e983f90fafb3e1c038a7c53af8ab5c55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.7 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2b3ff052b2ab83ba5ecdddd783b4f1a2c8a150f8a923cb0d366b0d282f8e1f3f
BLAKE2b-256 checksum
How to use checksums
1af9c711b8f75033f301151b9048b39e7a01bea7eaa9e47b067e20797c266b2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.6 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
3e7ed71f53076e9d3baab3fdfedf850834f6de10ec9fb40b1ab3376a9f168a56
BLAKE2b-256 checksum
How to use checksums
81156ff09074b0bae5edfcb0fe4593764b5ea2e014320b551ae027a6bf714bcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL schema_salad-8.2.20220103095339-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.8 MB
Tags CPython 3.10 Linux glibc 2.12+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
a6ea4820568f90382585dcf269352b9fd26f00a245e3906398cef84b99a63ea7
BLAKE2b-256 checksum
How to use checksums
6e0466e9473a82f3227e770cf3ea94e9e01926d05193d800df607c8f4e202ef6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.7 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
4744b5fdc5894c49f8c7dbca8393e90c97e4b3f4f227c848a5c8feeb5bf70d7d
BLAKE2b-256 checksum
How to use checksums
f4f2fcf870b509e9ee1cdcbebf09341206a390bf25a55a0c72a14719414d49d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.6 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
e3483e800f58169afa3bfed117bc1396e329bee8d09b1cb427f55fb67d8cb131
BLAKE2b-256 checksum
How to use checksums
daeaa13f5d4dcbc1de92837d7f03efddba280aec691223da01b769fa49484759
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL schema_salad-8.2.20220103095339-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.7 MB
Tags CPython 3.9 Linux glibc 2.12+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
d9656313c17d439a14a5f8e9149a2a708a5dcd5d69d81cbced52ff5beddb6972
BLAKE2b-256 checksum
How to use checksums
15b77fd6e011bf440838c1be190f0c6286c35f259acca0fc1c2b5d7a5d31a4c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.5 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
35cc32ba214faca47a39e97da1bd2df0b49c824118b283f9101037d89777627b
BLAKE2b-256 checksum
How to use checksums
dd8588f240cc2b779052d5955822da22c57aa49ccf519e6ef58c72ac35891801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.4 MB
Tags CPython 3.8 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
91f1b15e83470c721e2d79a4290c1961262942435c483844a4b11873e3091f3d
BLAKE2b-256 checksum
How to use checksums
492202cfe7f3311b73a334b2818caed11af6269ecdaec01b0f0f2a0000e37a7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL schema_salad-8.2.20220103095339-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.5 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
60060fc8065ec29704e35d59b9c9b7042710734edf96a205ef8c76121c5d0cc2
BLAKE2b-256 checksum
How to use checksums
90b9edcea1de83d683fa924ea364e9510f4bbf1b409e6f146f053bad12398b70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.3 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
0ce33774970da53434c966a5d1af063672b18127992d407b57fb6b354b134030
BLAKE2b-256 checksum
How to use checksums
8d268b737b1cdbd186930277cbef4c240e29b693ab477da9dd6daeb134c73196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
295e7334cf4023997fa198ef134ee0aab8918efcdbc9e27ee2cf6f75c7fe767b
BLAKE2b-256 checksum
How to use checksums
5a322572114659428171e6b25cc78d426ffcef28fcb3c551c5a90e981a29bc01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl

Download URL schema_salad-8.2.20220103095339-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Size 2.3 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
43366cc97bed82ee7a49a3ea39b2769bf732dd52bd678144717c7aec5fc40da6
BLAKE2b-256 checksum
How to use checksums
6f7c91a05e5c4bb46569e76e3e6b2ebc88f566ae47c17d53a10e8a00936eb549
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

8.3

12 release files

This release

8.2.20220103095339 This release

14 release files

1.7

2 release files

1.1.1

1 release file

1.1.0

1 release file

1.0.6

1 release file

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

1 release file

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page