backend-drf-spectacular

Documents Django REST Framework endpoints as an OpenAPI 3 schema using drf-spectacular.

Updated May 13, 2026
One-click install
npx skills add https://github.com/jcg-admin/kaupamex-api --skill backend-drf-spectacular-jcg-admin
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: backend-drf-spectacular
Source: https://github.com/jcg-admin/kaupamex-api/tree/main/.claude/skills/backend-drf-spectacular
Command: npx skills add https://github.com/jcg-admin/kaupamex-api --skill backend-drf-spectacular-jcg-admin

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires drf-spectacular, djangorestframework, django, and includes references (resource) components.

What problem does it solve? Documenting a DRF API contract by hand drifts out of sync with the code, and drf-spectacular's automatic introspection fails on custom auth, third-party serializers, and colliding enum names. This Skill encodes the project's conventions for generating a clean, warning-free OpenAPI 3 schema. ## Core Features & Use Cases - Endpoint contract annotation: Apply @extend_schema with summary, parameters, responses, and per-app tags, following the project's proven usage patterns. - Open/Closed schema architecture: Add new apps via their own schema.py with SPECTACULAR_TAGS and extensions, without ever editing the global SPECTACULAR_SETTINGS in base.py. - Introspection fixes: Write authentication, serializer, and view extensions for cases drf-spectacular cannot introspect, such as simplejwt login/logout and CSRF-exempt session auth. - Use Case: When adding a new orders app endpoint, annotate its view method with @extend_schema, declare the app tag in orders/schema.py, and verify the schema generates without warnings via the deploy check. ## Quick Start Ask the assistant to document a new DRF endpoint's OpenAPI contract with drf-spectacular following the project's per-app schema.py conventions.

Frequently Asked Questions about backend-drf-spectacular

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I document a DRF endpoint with drf-spectacular?▼

Annotate the view method with @extend_schema, providing summary, parameters via OpenApiParameter, responses per status code, and a tag matching your app's SPECTACULAR_TAGS. Place the decorator on the actual entry method like get or post, not on list or retrieve.

How do I add a new Django app to the OpenAPI schema?▼

Create a schema.py in the app declaring SPECTACULAR_TAGS and any extensions. The project's PREPROCESSING and POSTPROCESSING hooks collect tags and register extensions automatically, so you never edit the global SPECTACULAR_SETTINGS in base.py.

Why does drf-spectacular emit 'could not resolve' warnings?▼

This warning signals failed introspection, usually a missing extension for custom authentication or a third-party serializer. Fix it by writing an OpenApiAuthenticationExtension, OpenApiSerializerExtension, or OpenApiViewExtension in the app's schema.py.

How do I fix enum name collision warnings in drf-spectacular?▼

Add an entry to ENUM_NAME_OVERRIDES in SPECTACULAR_SETTINGS mapping the colliding choice set to a fixed component name. Do not rename the model choices themselves to solve a schema-level naming problem.

Does drf-spectacular work with simplejwt login and logout views?▼

Yes, but simplejwt's views need extensions because introspection fails on the overridden validate method and empty logout response. The project uses an OpenApiSerializerExtension for login and an OpenApiViewExtension for logout.

When should I not use @extend_schema_view with drf-spectacular?▼

Avoid it when you can annotate the method directly, which is the project convention. Reserve @extend_schema_view for methods you do not override, such as inherited ViewSet actions or multi-method @api_view functions.