improving-drf-endpoints

Audit Django REST Framework viewsets and serializers for type safety and OpenAPI documentation.

693|111|Updated Aug 11, 2020
One-click install
npx skills add https://github.com/PostHog/posthog-foss --skill improving-drf-endpoints
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: improving-drf-endpoints
Source: https://github.com/PostHog/posthog-foss/tree/main/.agents/skills/improving-drf-endpoints
Command: npx skills add https://github.com/PostHog/posthog-foss --skill improving-drf-endpoints

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the critical need for robust, well-documented, and type-safe API endpoints, ensuring seamless integration between backend and frontend systems and improving the reliability of downstream tools.

Core Features & Use Cases

  • Type Safety: Ensures accurate data types flow from Django serializers to generated TypeScript types and MCP tools.
  • API Documentation: Improves OpenAPI specifications through proper help_text, annotations, and schema definitions.
  • Developer Efficiency: Reduces debugging time by catching type mismatches and documentation gaps early in the development cycle.
  • Use Case: When developing a new API endpoint, use this Skill to audit the DRF viewset and serializer, ensuring all fields have help_text, SerializerMethodFields are annotated, and @extend_schema is correctly applied, leading to accurate frontend type generation and clear API documentation.

Quick Start

Use the improving-drf-endpoints skill to audit the serializer and viewset for the posthog/api/user.py file.

Frequently Asked Questions about improving-drf-endpoints

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

FAQPage Schema
How do I improve type safety in Django REST Framework serializers for TypeScript generation?

Enhance OpenAPI specifications in Django REST Framework by adding complete help_text to serializer fields, annotating methods, and correctly applying schema definitions to viewsets for clear API documentation.

How do I add help_text and annotations to DRF viewsets and serializers?

Audit DRF viewsets and serializers to add help_text to all fields, annotate SerializerMethodFields, and apply extend_schema decorators, ensuring backend changes accurately dictate frontend type generation and API documentation.

Why are my generated TypeScript types mismatching the Django REST Framework API responses?

Generated TypeScript types mismatch API responses when DRF serializer field definitions lack proper type annotations or help_text, causing downstream type generation tools to incorrectly infer the API data structure.

Can I use this to audit API endpoints in specific backend directories like posthog/api/?

Yes, you can audit API endpoints in specific backend directories like posthog/api/ and products/*/backend/api/ by targeting the DRF viewsets and serializers imported within those files during the review process.

What is the best way to ensure DRF best practices are followed for OpenAPI documentation quality?

The best way to ensure DRF best practices for OpenAPI quality is to systematically audit viewsets and serializers, verifying field definitions, help_text completeness, and schema annotations to catch documentation gaps early.