API Documentation

compound_jsonapi

The compound_jsonapi provides two main classes:

  • The Schema acts as the base-class for all specific schemas that are then used to serialise / deserialise data. Details of its public interface can be found at Schema.
  • The Relationship is a custom field to define relationships between Schema.

compound_jsonapi.schema

The Schema defines the base-class for custom schemas to use for serialisation / deserialisation.

class compound_jsonapi.schema.Schema(include_schemas=None, *args, **kwargs)

Extends the Schema with the functionality needed for serialising to / deserialising from compound JSONAPI documents.

When instantiating a Schema, by default only the attributes of the current schema a serialised. If relationships are to be followed, then the Schemas that are to be included must be listed in include_schemas.

Parameters:include_schemas (list of Schema) – The Schemas to include when serialising / deserialising

compound_jsonapi.fields

Provides the Relationship custom field for defining relationships between Schemas.

class compound_jsonapi.fields.Relationship(schema, many=False, **kwargs)

The Relationship creates a link between two Schema. The linked Schema can either be provided as a class or a dotted classname string.

Parameters:
  • schema – The Schema that defines how to handle the linked data.
  • many (bool) – By default the relationship is one-to-one. Set this to true to create a one-to-many relationship
schema

Property that returns an instantiated Schema for the relationship.