{"id":9706,"library":"drf-jsonschema-serializer","title":"DRF JSON Schema Serializer","description":"drf-jsonschema-serializer provides automatic JSON Schema generation for Django REST Framework serializers. It allows developers to define DRF serializers as usual and then easily convert them into JSON Schema Draft 2020-12, OpenAPI 3.0.x compatible schemas. The current version is 3.0.0, with releases typically tied to major Django/DRF version compatibility.","status":"active","version":"3.0.0","language":"en","source_language":"en","source_url":"https://github.com/maykinmedia/drf-jsonschema-serializer","tags":["django","drf","json-schema","serialization","api-documentation"],"install":[{"cmd":"pip install drf-jsonschema-serializer","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for Django projects and DRF integration (>=3.2)","package":"Django","optional":false},{"reason":"Core dependency for serializer introspection (>=3.12)","package":"djangorestframework","optional":false},{"reason":"Used for schema validation and generation (>=4.0)","package":"jsonschema","optional":false},{"reason":"Optional integration for OpenAPI schema generation, if desired","package":"drf-spectacular","optional":true}],"imports":[{"symbol":"JSONSchemaSerializer","correct":"from drf_jsonschema_serializer import JSONSchemaSerializer"},{"note":"JSONSchemaField was removed in v3.0.0, use JSONSchemaDictField or JSONSchemaListField instead.","wrong":"from drf_jsonschema_serializer import JSONSchemaField","symbol":"JSONSchemaDictField","correct":"from drf_jsonschema_serializer.fields import JSONSchemaDictField"},{"note":"JSONSchemaField was removed in v3.0.0, use JSONSchemaDictField or JSONSchemaListField instead.","wrong":"from drf_jsonschema_serializer import JSONSchemaField","symbol":"JSONSchemaListField","correct":"from drf_jsonschema_serializer.fields import JSONSchemaListField"}],"quickstart":{"code":"from rest_framework import serializers\nfrom drf_jsonschema_serializer import JSONSchemaSerializer\n\nclass MyInputSerializer(serializers.Serializer):\n    name = serializers.CharField(max_length=100, help_text=\"The name of the item\")\n    quantity = serializers.IntegerField(min_value=1, help_text=\"The quantity of the item\")\n    is_active = serializers.BooleanField(default=True)\n\n# Instantiate the JSONSchemaSerializer with your DRF serializer\nschema_generator = JSONSchemaSerializer(MyInputSerializer())\n\n# Generate the JSON Schema\njson_schema = schema_generator.data\n\nprint(json_schema)\n# Example expected output (truncated):\n# {\n#   'type': 'object',\n#   'properties': {\n#     'name': {'type': 'string', 'maxLength': 100, 'description': 'The name of the item'},\n#     'quantity': {'type': 'integer', 'minimum': 1, 'description': 'The quantity of the item'},\n#     'is_active': {'type': 'boolean', 'default': True}\n#   },\n#   'required': ['name', 'quantity']\n# }","lang":"python","description":"This example demonstrates how to define a standard Django REST Framework serializer and then use `drf-jsonschema-serializer` to automatically generate its corresponding JSON Schema. The generated schema can be used for API documentation, client-side validation, or other schema-driven processes."},"warnings":[{"fix":"Upgrade Python to 3.10+, Django to 3.2+, and DRF to 3.12+ before installing or upgrading to drf-jsonschema-serializer v3.x.","message":"Version 3.0.0 drops support for Python < 3.10, Django < 3.2, and Django REST Framework < 3.12. Ensure your environment meets these minimum requirements before upgrading.","severity":"breaking","affected_versions":"3.0.0 and higher"},{"fix":"Replace `JSONSchemaField` with `JSONSchemaDictField` for dictionary-like schemas and `JSONSchemaListField` for list-like schemas. Update imports to `from drf_jsonschema_serializer.fields import JSONSchemaDictField, JSONSchemaListField`.","message":"The `JSONSchemaField` class was removed in version 3.0.0. If you were using it for dict or list fields within your DRF serializers, you must migrate to `JSONSchemaDictField` or `JSONSchemaListField` respectively.","severity":"breaking","affected_versions":"3.0.0 and higher"},{"fix":"If you require serving JSON Schemas via an API endpoint, consider using `drf-spectacular` for OpenAPI schema generation, or implement a custom view that utilizes `drf-jsonschema-serializer` directly to generate and serve the schema.","message":"The `JSONSchemaView` for serving schema endpoints was removed in v2.0.0. While this predates v3.0.0, users migrating from very old versions might encounter issues. The library now focuses purely on schema generation.","severity":"deprecated","affected_versions":"2.0.0 and higher"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Replace `JSONSchemaField` with `JSONSchemaDictField` for dictionaries or `JSONSchemaListField` for lists. Update your import statement to `from drf_jsonschema_serializer.fields import JSONSchemaDictField` (or `JSONSchemaListField`).","cause":"Attempting to import or use the deprecated `JSONSchemaField` which was removed in version 3.0.0.","error":"ImportError: cannot import name 'JSONSchemaField' from 'drf_jsonschema_serializer'"},{"fix":"Upgrade your Python installation to version 3.10 or newer. If you need to use an older Python version, you must use an older compatible version of drf-jsonschema-serializer (e.g., v2.x for Python 3.8/3.9).","cause":"Your Python environment does not meet the minimum requirement of Python 3.10 for drf-jsonschema-serializer v3.x.","error":"RuntimeError: 'drf_jsonschema_serializer' requires Python 3.10 or later."},{"fix":"Upgrade your Django installation to version 3.2 or newer. Similarly for Django REST Framework (>=3.12).","cause":"Your Django version is older than the minimum requirement of 3.2 for drf-jsonschema-serializer v3.x.","error":"django.core.exceptions.ImproperlyConfigured: 'drf_jsonschema_serializer' requires Django 3.2 or later."}]}