Skip to main content

Schema Annotations for Linked Avro Data (SALAD)

Reason this release was yanked:

regression https://github.com/common-workflow-language/schema_salad/issues/575

Project description

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.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

schema-salad-8.3.20220721194857.tar.gz (532.4 kB view details)

Uploaded Source

Built Distributions

schema_salad-8.3.20220721194857-py3-none-any.whl (573.1 kB view details)

Uploaded Python 3

schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.6m manylinux: glibc 2.17+ ARM64

File details

Details for the file schema-salad-8.3.20220721194857.tar.gz.

File metadata

File hashes

Hashes for schema-salad-8.3.20220721194857.tar.gz
Algorithm Hash digest
SHA256 438101b276918bb5ad36a8c9a3b4041cf071b15784ac756a1968933893dc6cea
MD5 38f8a94facd768035fb21ab34a01c935
BLAKE2b-256 f6253f3740f8cbbab2607cf544bad2f1d310e434212a783da0fb3e806bc9d867

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-py3-none-any.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-py3-none-any.whl
Algorithm Hash digest
SHA256 677c02967fa5cde051a85211f20ef9f43da1b95cf7656c64c9c64c25d2f3bb88
MD5 b309ecd5a536d7fde183160d56dc786e
BLAKE2b-256 7bb64d717368ddc3cfdd1710180afe39eedbf568f52b10522010b3aa275eb1a2

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c2a03d8e31a320f049f2cf614eee299fed471ab37a44a141766ce462c686b4fc
MD5 9af5503d4deaf86a70f5dfb738c3435c
BLAKE2b-256 2bc9f0191089ca5d1010a97856c53b0c6dd7703fd1ddae5bd304c1cfa75cb8fd

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 3101ed3c6722d30efb8b5db16aff7e3bdb529e28ddee3da7b70bdd113c2cf0cf
MD5 5983c2cd03ac750e7ad5bed7649ef030
BLAKE2b-256 e87c65124e6f22d52a1b86df92fc27dd733dc1d46bb92e7e2fdb434f765835e9

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 db9f5e08e536187cd0f25f0bc3f44e0776370bee199e5d2be72a01af929e24fb
MD5 939865023e815f7f88b9238785e0c39a
BLAKE2b-256 88a577c4a8a887ef2e77d89390227bfdb8798c67e6f352455faf857fe91d9147

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 15b5020bab2a0b397ba214b21648d2dce320595acb6b71cdabd984581b3ebd0a
MD5 acade22a5dfcf56c5b24a7968dcd98df
BLAKE2b-256 d82debbd112b0cb6e4b69aff0615efc6db7c895782b6b9160b39fac467bdd8fa

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 78cf9cbbf1c0b2b4cc807044d3c606090cfc261cbf478b6d25ec0b3846483428
MD5 99b0be567811f264c8b447cb2f14a4ea
BLAKE2b-256 80b2d3c2d6095f1189073d89c68575b493ed0260e06138522902e6423dbc1f9b

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a48aed6c4e177c3f3b8167ed34fdd5f225f1cf02d7bff6f548b1fc983efa697d
MD5 5a6acf6a07561b28c639fd84cc45fb27
BLAKE2b-256 b37d642abe438409100148a8e41e10f17cfbe4f8ae6a7f7ea73131f4f20c1037

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 79815a0597a4a4747dafc47dae596467713b5dfd8c1a451d3b356edb50bd88db
MD5 4195ca54df6d2c53d3bd955366a111f1
BLAKE2b-256 dec2f28610c4fd9777cf697adcb15dbfe22b5781752ec949097044f998b1f82f

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 fcce5c5febaa8d551f4e96d93fb0b240165e2d92296b51be35b5be51efcb92cc
MD5 1196cc8c74eaf8d9a449662aaa93bae7
BLAKE2b-256 578c5ee4762a025b0ee6426f57ac8e765fac5490ed9c4f07f5cd026ff461b691

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a5328448bd65dd7e3f6d6deac405ff97f758a1f55aa1eb7ae75583f4844d76e2
MD5 522d1b3bfb0f8da03fb5a6dd1707ab06
BLAKE2b-256 e3301ece1f0aa61c0a4da3cedaa48e25aec5dee95d4f9c28b09408c0208329e8

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed19ba4aae03fb1249fd4ec211f85508b3ba04da6331f46cbf47e338baaeb41b
MD5 9949127ae4467d393f762787f319d80b
BLAKE2b-256 6c4e6c3fa0f9ca077242c1655147a03393269ddfc3f00020cad22c077268e9f8

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 a7aa12d15d7cf44d48373466741f763ce302b1fb0fe9076f2ce7a928623fe99f
MD5 25eef8e693d4ed02f5d0e93699024cc0
BLAKE2b-256 af4998008d2bdf6d3b154fcb0c7977d420529e4ffc660b200150d044e1246d50

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f8296b7dd376b2e5f17ced40a14044854d68c75a5aece81433af0251e0f5d347
MD5 f4e6afdb6cf23b45e72cb136f1eed12d
BLAKE2b-256 c578eb7e9d4e922b4bc5eb930f034cc74636c26ec41100a3436c5ffd2bdc22df

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b7ed2d2da3a940c62f185d3fb1931ce375ef9c8468644b2db27745268736b678
MD5 48258ee281701c517bc41e346e1eaf73
BLAKE2b-256 2903ac279e4f10c433de947d8478415a1087775c094b6bf3276e55d8bce4eeac

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 9bf75f1a1a1d4a41b7afb027dc3b1b3a9d728dcc21349713ea399a5abaed4912
MD5 c1058b57fed0f580a56cd5cdcd07c562
BLAKE2b-256 17ed269bd2dce0e54faffdd726212bf4599ca9fdc837a3dc4ac5a1ae665659be

See more details on using hashes here.

Provenance

File details

Details for the file schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for schema_salad-8.3.20220721194857-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3a8a3bda1fc66b89e5b2c5979f8cb0934c9ba38c3c1d6d58e9ffc3afdcb71c31
MD5 e212c9e6c21360fe4a1af93c1f15561c
BLAKE2b-256 a22fa7da374b3e9a7085644f2dcea5c5b7e143ca414ce4937e4a2c30659d8ba3

See more details on using hashes here.

Provenance

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