Skip to main content

A package that constructs JsonSchema validation error into error tree for Django Rest Framework with custom error message in compliance with the DRF error message.

Project description

drf-jsonschema, created by Kiratech from extending jsonschema package. This package provides JsonSchemaField and constructs JsonSchema validation error into error tree for Django Rest Framework with custom error message.

This package will install jsonschema automatically so manual installation is not necessary.

Quick Start

  1. You can use JsonSchemaFieldValidator in Django’s models.py as such:

    from drf_jsonschema import JsonSchemaFieldValidator
    ...
    ...
    json_data = models.JSONField(validators=[JsonSchemaFieldValidator(schema=your_json_schema)])
  2. On serializers.py, modify the serializer field mapping from JSONField to JSONSchemaField as the example below:

    from drf_jsonschema.serializers import JsonSchemaModelSerializer
    
    class YourSerializer(JsonSchemaModelSerializer):
        ...
  3. For more information, visit jsonschema

Project details


Download files

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

Source Distribution

drf-jsonschema-0.2.2.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

drf_jsonschema-0.2.2-py3-none-any.whl (9.8 kB view hashes)

Uploaded Python 3

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