MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Swagger UI Integration0%
Study Materials
REST API Development with DjangoProgress 0%
1.1REST Principles1.2HTTP Methods Overview1.3Status Codes
9.1Swagger UI Integration9.2Redoc Documentation9.3Documenting API Endpoints
HomeTutorialsREST API Development with DjangoSwagger UI Integration
Redoc Documentation

Swagger UI Integration

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

OpenAPI 3 and Swagger UI with drf-spectacular

Interactive API documentation is essential for modern frontend-backend collaboration. DRF OpenAPI 3 documentation is powered by drf-spectacular, the officially recommended documentation generator for Django REST Framework.


1. Why drf-spectacular?

Older tools like coreapi and drf-yasg only supported OpenAPI 2.0 (Swagger 2.0). drf-spectacular generates fully compliant OpenAPI 3.0 schemas, supporting:

  • Rich typing and JSON Schema validation
  • Accurate component schemas for nested serializers and Polymorphic models
  • Interactive Swagger UI and Redoc endpoints
  • Client code generation (TypeScript fetch, Axios, Python SDKs)

2. Installation and Settings Configuration

Install the package:

1pip install drf-spectacular

Add to INSTALLED_APPS and configure DRF default schema class in settings.py:

1INSTALLED_APPS = [
2 ...,
3 'rest_framework',
4 'drf_spectacular',
5 'store',
6]
7 
8REST_FRAMEWORK = {
9 'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
10}
11 
12SPECTACULAR_SETTINGS = {
13 'TITLE': 'MSK Institute E-Commerce & Academy API',
14 'DESCRIPTION': 'High-performance REST API with JWT Auth, Filtering, and Stripe integration.',
15 'VERSION': '1.0.0',
16 'SERVE_INCLUDE_SCHEMA': False,
17 'COMPONENT_SPLIT_REQUEST': True,
18 'SCHEMA_PATH_PREFIX': r'/api/v[0-9]',
19}

3. Configuring URL Endpoints

In config/urls.py, register the raw schema download endpoint and the interactive Swagger UI:

1from django.urls import path
2from drf_spectacular.views import (
3 SpectacularAPIView,
4 SpectacularSwaggerView,
5 SpectacularRedocView
6)
7 
8urlpatterns = [
9 # OpenAPI Schema (YAML or JSON)
10 path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
11
12 # Swagger UI (Interactive Explorer)
13 path('api/docs/swagger/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
14
15 # Redoc (Clean Documentation Reader)
16 path('api/docs/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
17]

Visiting /api/docs/swagger/ in your browser provides an interactive dashboard where developers can test endpoints, view request bodies, inspect status codes, and authenticate using the "Authorize" button.


Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What standard does drf-spectacular generate documentation for?
Question 2
What setting must be added to REST_FRAMEWORK in settings.py for drf-spectacular to inspect views?
Question 3
What is the purpose of SpectacularAPIView in urls.py?
Question 4
What does setting 'SERVE_INCLUDE_SCHEMA': False in SPECTACULAR_SETTINGS do?
Question 5
Why is OpenAPI 3 documentation superior to static markdown for frontend developers?
Next Lesson

Redoc Documentation

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Automated API TestsRedoc Documentation

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master REST API Development with Django with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext