JSON Schema Directives

.. jsonschema::

The core jsonschema directive, mainatined in the sphinxcontrib-jsonschema repository.

The exact output of this is somewhat specific to the OCDS usecases, so we subclass the directive to create alternatives for other data standards, see below.

Source:

```{eval-rst}
.. jsonschema:: _static/example_schema.json
```

Output:

Title

Description

Type

Format

Required

id

string

Required

Identifier

An identifier

foo

integer

Foo bar

Foo bar baz bar baz bar baz bar baz. Bar foo baz foo bar. Baz bar foo bar foo bar foo bar foo.

when

string

date-time

Required

When

When did this thing happen

lorem

string

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porttitor urna in diam ornare luctus. Donec accumsan sit amet velit id auctor. Sed commodo elit ut tempor suscipit. Fusce volutpat malesuada felis, accumsan molestie nisi aliquet non. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

subthings

array[object]

SubThing

Description of SubThing

subthings/0/id

string

Required

Identifier

An identifier for this subthing

subthings/0/example

string

Example

An example field

.. jsonschema-titles::

Display titles, but not field names.

Currently only used for 360Giving.

Source:

```{eval-rst}
.. jsonschema-titles:: _static/example_schema.json
```

Output:

Title

Description

Type

Required

Identifier

An identifier

string

True

Foo bar

Foo bar baz bar baz bar baz bar baz. Bar foo baz foo bar. Baz bar foo bar foo bar foo bar foo.

integer

False

When

When did this thing happen

date-time

True

Lorem ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porttitor urna in diam ornare luctus. Donec accumsan sit amet velit id auctor. Sed commodo elit ut tempor suscipit. Fusce volutpat malesuada felis, accumsan molestie nisi aliquet non. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

string

False

Source:

```{eval-rst}
.. jsonschema-titles:: _static/example_schema.json
    :child: subthings
```

Output:

Description of SubThing

Title

Description

Type

Required

SubThing:Identifier

An identifier for this subthing

string

True

SubThing:Example

An example field

string

False

.. jsonschema-title-fieldname-map::

Display the mapping between titles and field names.

Currently only used for 360Giving.

Source:

```{eval-rst}
.. jsonschema-title-fieldname-map:: _static/example_schema.json
```

Output:

Title

Name

Type

Identifier

id

string

Foo bar

foo

integer

When

when

date-time

Lorem ipsum

lorem

string

SubThing:Identifier

subthings/0/id

string

SubThing:Example

subthings/0/example

string

.. jsonschema-array::

Handle a jsonschema where the top element is an array. Don’t display titles in the table.

Currently only used for OpenReferral.

Source:

```{eval-rst}
.. jsonschema-array:: _static/example_schema_array.json
```

Output:

Description

Type

Required

id

An identifier

string

True

foo

Foo bar baz bar baz bar baz bar baz. Bar foo baz foo bar. Baz bar foo bar foo bar foo bar foo.

integer

False

when

When did this thing happen

date-time

True

lorem

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porttitor urna in diam ornare luctus. Donec accumsan sit amet velit id auctor. Sed commodo elit ut tempor suscipit. Fusce volutpat malesuada felis, accumsan molestie nisi aliquet non. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

string

False

subthings/0/id

An identifier for this subthing

string

True

subthings/0/example

An example field

string

False

CSS

To display the tables better, add this css to your site: jsonschema.css. You need to add the file to a _static folder within your docs, and then add the following to _templates/layout.html.

{% extends "!layout.html" %}
{% set css_files = css_files + ["_static/jsonschema.css"] %}