HomePhabricator

api: Add JSONSchemaField for JSON data with a schema

Description

api: Add JSONSchemaField for JSON data with a schema

toolhub.fields.JSONSchemaField extends JSONField to add jsonschema
validation. A schema can be provided as either a static asset or an
inline object.

toolhub.serializers.JSONSchemaField extends DRF's ModelField to
implement a serializer for a toolhub.fields.JSONSchemaField instance.
The serializer passes the field's schema on to drf-spectacular's
generated OpenAPI specification.

toolhub.apps.toolinfo.schema is a new module providing functions for
working with our jsonschema/toolinfo schemas.

toolhub.apps.toolinfo.models.Tool has been updated to use
JSONSchemaField rather than the prior JSONField for JSON blob fields.
These fields also now use jsonschema specifications copied at runtime
from the 1.2.0 toolinfo schema.

Bug: T272719
Change-Id: I72e18ecb69154e37a9d7189b920aec9a75d10337

Details

Provenance
bd808Authored on Jan 25 2021, 5:17 AM
jenkins-botCommitted on Jan 26 2021, 12:48 AM
Parents
rWTHU6abe87c34b4b: api: Create and edit endpoints for toolinfo records
Branches
Unknown
Tags
Unknown
References
refs/changes/58/658458/3
ChangeId
I72e18ecb69154e37a9d7189b920aec9a75d10337