From 5ea2700dc16d794a599e6ed50f2c2288f8040ce0 Mon Sep 17 00:00:00 2001 From: YNorbert Klamann Date: Thu, 21 Nov 2024 11:23:13 +0000 Subject: [PATCH] Minimal configration for drf-spectacular MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Onöy commandline interface --- Pipfile | 2 +- src/paperless/settings.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Pipfile b/Pipfile index 335d9bff3..f7537a514 100644 --- a/Pipfile +++ b/Pipfile @@ -59,7 +59,7 @@ watchdog = "~=6.0" whitenoise = "~=6.8" whoosh = "~=2.7" zxing-cpp = {version = "*", platform_machine = "== 'x86_64'"} - +drf-spectacular = "*" [dev-packages] # Linting diff --git a/src/paperless/settings.py b/src/paperless/settings.py index e5f31800f..b57606380 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -317,6 +317,7 @@ INSTALLED_APPS = [ "allauth.account", "allauth.socialaccount", "allauth.mfa", + "drf_spectacular", *env_apps, ] @@ -334,6 +335,7 @@ REST_FRAMEWORK = { # Make sure these are ordered and that the most recent version appears # last "ALLOWED_VERSIONS": ["1", "2", "3", "4", "5"], + "DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema", } if DEBUG: @@ -355,8 +357,13 @@ MIDDLEWARE = [ "django.middleware.clickjacking.XFrameOptionsMiddleware", "allauth.account.middleware.AccountMiddleware", ] - -# Optional to enable compression +SPECTACULAR_SETTINGS = { + "TITLE": "Paperless API", + "DESCRIPTION": "Generated with drf-spectacular (unmodified) python manage.py spectacular --color --file schema.yml", + "VERSION": "5.0.0", + "SERVE_INCLUDE_SCHEMA": False, + # OTHER SETTINGS +}# Optional to enable compression if __get_boolean("PAPERLESS_ENABLE_COMPRESSION", "yes"): # pragma: no cover MIDDLEWARE.insert(0, "compression_middleware.middleware.CompressionMiddleware")