🪟 Windows TippsHow to Enable Windows 11 Screen Savers(07.09.2026 um 12:41 Uhr)
🪟 Windows TippsMicrosoft Phone Link Not Showing Messages on Windows 11? Fix It(09.09.2026 um 07:52 Uhr)
⚠️ Malware / Trojaner / VirenPost-DEF CON phishing campaign delivered AMOS and NetSupport malware(24.08.2026 um 09:42 Uhr)
💾 IT Security ToolsHow to Use BloodHound Active Directory Setup Attack Path Analysis(10.09.2026 um 14:35 Uhr)
🕵️ SicherheitslückenCompliance Alert: EU Cyber Resilience Act 24-Hour Reporting Enforced(11.09.2026 um 06:25 Uhr)
🕵️ SicherheitslückenAWS IAM Privilege Escalation: Cheat Sheet And Defense(11.09.2026 um 07:43 Uhr)
🕵️ SicherheitslückenArista warns customers ahead of next week’s security disclosures(02.09.2026 um 23:34 Uhr)
🕵️ SicherheitslückenKARR Security vulnerability(02.09.2026 um 03:15 Uhr)
🪟 Windows TippsHow to Enable Windows 11 Screen Savers(07.09.2026 um 12:41 Uhr)
🪟 Windows TippsMicrosoft Phone Link Not Showing Messages on Windows 11? Fix It(09.09.2026 um 07:52 Uhr)
⚠️ Malware / Trojaner / VirenPost-DEF CON phishing campaign delivered AMOS and NetSupport malware(24.08.2026 um 09:42 Uhr)
💾 IT Security ToolsHow to Use BloodHound Active Directory Setup Attack Path Analysis(10.09.2026 um 14:35 Uhr)
🕵️ SicherheitslückenCompliance Alert: EU Cyber Resilience Act 24-Hour Reporting Enforced(11.09.2026 um 06:25 Uhr)
🕵️ SicherheitslückenAWS IAM Privilege Escalation: Cheat Sheet And Defense(11.09.2026 um 07:43 Uhr)
🕵️ SicherheitslückenArista warns customers ahead of next week’s security disclosures(02.09.2026 um 23:34 Uhr)
🕵️ SicherheitslückenKARR Security vulnerability(02.09.2026 um 03:15 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 3 Min Lesezeit
0

Django Rest framework with Swagger

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht




What to expect from this article?



This article will cover implementing Swagger in a Django rest framework project; we will work on our accounts management






Series order



Check previous articles if interested!






  1. , but I'm open to suggestions if you know a better one!

    Let's start with package installation




    CODE
    pip install drf-yasg






    now moving to our setting file




    CODE
    INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'drf_yasg', #new
    'corsheaders',
    'rest_framework',
    'django_filters',
    'app_account',
    'app_admin',
    'app_main',
    ]

    SWAGGER_SETTINGS = {
    'LOGIN_URL' : '/api/account/login/',
    'SECURITY_DEFINITIONS': {
    'Bearer': {
    'type': 'apiKey',
    'name': 'Authorization',
    'in': 'header'
    }
    }
    }

    REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
    'rest_framework_simplejwt.authentication.JWTAuthentication',
    ],
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
    }








    alive_diary/settings.py




    We have added the drf_yasg app to the installed apps and set the default authentication method to Bearer JWT token.



    now to the URLs file




    CODE
    from django.contrib import admin
    from django.urls import path, include


    from rest_framework.documentation import include_docs_urls # new
    from rest_framework.schemas import get_schema_view # new

    from drf_yasg.views import get_schema_view # new
    from drf_yasg import openapi # new

    schema_view = get_schema_view(
    openapi.Info(
    title="Swagger API",
    default_version='v1',
    ),
    public=True,
    )
    API_DESCRIPTION = 'A Web API for creating and editing.' # new
    API_TITLE = 'API' # new

    urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/account/', include('app_account.urls')),

    path('docs/', include_docs_urls(title=API_TITLE,description=API_DESCRIPTION)), # new
    path('swagger/', schema_view.with_ui('swagger',cache_timeout=0),name="swagger-schema"), # new
    ]







    that is it! great job!

    let's try it




    CODE
    python manage.py runserver 0.0.0.0:8555 






    opening http://localhost:8555/swagger/ should look like





    Then, we authenticate using the "Authorize" button at the top of the swagger page. Make sure to use the access token, and don't forget the Bearer in front of it: "Bearer token..."





    it is empty! swagger wasn't able to recognize request schema, the easiest way to fit it is to use



    we can test all authenticated requests using Swagger now! next article will go back to the accounts app



    Stay tuned 😎

    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
2 Quellen
Microsoft Phone Link Not Showing Messages on Windows 11? Fix It
1 Quelle
How to Enable Windows 11 Screen Savers
1 Quelle
Post-DEF CON phishing campaign delivered AMOS and NetSupport malware
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Django Rest framework with Swagger

Thematisch verwandte Begriffe: Django, Rest, framework, with · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...