summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.pre-commit-config.yaml1
-rw-r--r--Makefile2
-rw-r--r--README.md1
-rw-r--r--app/settings.py1
-rw-r--r--app/urls.py15
-rw-r--r--requirements.txt1
6 files changed, 20 insertions, 1 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 19ce43c..5b1e3df 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -46,3 +46,4 @@ repos:
- django-stubs==4.2.5
- django-environ==0.11.2
- django_extensions==3.2.3
+ - drf-yasg[validation]==1.21.7
diff --git a/Makefile b/Makefile
index cc582bd..e55aebf 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ init: build migrate
# Development
-up:
+up: migrate
docker-compose up
django-manage:
diff --git a/README.md b/README.md
index 2cd9152..4131f55 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,7 @@ This is my Django starter base app. Nothing too fancy.
- Django
- Django REST Framework
- django-extensions
+- drf-yasg for automatic swagger
- Docker & docker-compose with a Postgres DB
- GitlabCI / Github Actions
- Linting with:
diff --git a/app/settings.py b/app/settings.py
index 77ebf47..49f2be3 100644
--- a/app/settings.py
+++ b/app/settings.py
@@ -41,6 +41,7 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
+ "drf_yasg",
"django_extensions",
]
diff --git a/app/urls.py b/app/urls.py
index 65cf0d6..689da0a 100644
--- a/app/urls.py
+++ b/app/urls.py
@@ -16,7 +16,22 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
+from drf_yasg import openapi
+from drf_yasg.views import get_schema_view
+from rest_framework import permissions
+
+SchemaView = get_schema_view(
+ openapi.Info(
+ title="App API",
+ default_version="v1",
+ description="An API",
+ ),
+ public=True,
+ permission_classes=(permissions.AllowAny,),
+)
urlpatterns = [
path("admin/", admin.site.urls),
+ path("swagger/", SchemaView.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
+ path("redoc/", SchemaView.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
]
diff --git a/requirements.txt b/requirements.txt
index 283f7e4..603961b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,6 +6,7 @@ psycopg2-binary
pylint-django==2.5.3
pre-commit==3.5.0
django-stubs[compatible-mypy]==4.2.5
+drf-yasg[validation]==1.21.7
Werkzeug==3.0.0
bpython
flake8-bugbear==23.9.16