While drf-spectacular inspects serializers automatically, custom actions, query parameters, multipart file uploads, and dynamic responses require explicit annotations. DRF provides the powerful @extend_schema decorator to customize every detail of OpenAPI generation.
@extend_schema DecoratorThe @extend_schema decorator can be applied to @api_view functions, APIView methods (get, post), or ViewSet action methods (@action).
OpenApiParameterWhen an endpoint filters on parameters not present in the request body (e.g. GET requests), use OpenApiParameter:
drf_spectacular.utils is used to customize the OpenAPI schema of a view or method?list, retrieve, create) simultaneously??search=term using drf-spectacular?examples argument in @extend_schema accomplish?tags argument in @extend_schema?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Redoc Documentation | Build REST API for E-commerce App |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.