drf spectacular

This commit is contained in:
vabene1111
2024-02-29 16:34:13 +01:00
parent 521c71733a
commit e47bdd043e
4 changed files with 154 additions and 95 deletions

View File

@@ -2,13 +2,13 @@ from pydoc import locate
from django.urls import include, path
from django.views.generic import TemplateView
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView
from rest_framework import permissions, routers
from rest_framework.schemas import get_schema_view
from cookbook.version_info import TANDOOR_VERSION
from recipes.settings import DEBUG, PLUGINS
from .models import (Automation, Comment, CustomFilter, Food, InviteLink, Keyword, PropertyType,
Recipe, RecipeBook, RecipeBookEntry, RecipeImport, Space, Step,
Storage, Supermarket, SupermarketCategory, Sync, SyncLog, Unit, UnitConversion,
@@ -135,8 +135,10 @@ urlpatterns = [
path('telegram/hook/<slug:token>/', telegram.hook, name='telegram_hook'),
path('docs/markdown/', views.markdown_info, name='docs_markdown'),
path('docs/search/', views.search_info, name='docs_search'),
path('docs/api/', views.api_info, name='docs_api'),
path('openapi/', get_schema_view(title="Django Recipes", version=TANDOOR_VERSION, public=True, permission_classes=(permissions.AllowAny, )), name='openapi-schema'),
path('docs/api/', SpectacularRedocView.as_view(url_name='openapi-schema'), name='docs_api'),
path('openapi/', SpectacularAPIView.as_view(api_version=TANDOOR_VERSION), name='openapi-schema'),
path('api/', include((router.urls, 'api'))),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
path('api-token-auth/', CustomAuthToken.as_view()),
@@ -147,13 +149,11 @@ urlpatterns = [
path('manifest.json', views.web_manifest, name='web_manifest'),
]
generic_models = (
Recipe, RecipeImport, Storage, ConnectorConfig, RecipeBook, SyncLog, Sync,
Comment, RecipeBookEntry, InviteLink, UserSpace, Space
)
for m in generic_models:
py_name = get_model_name(m)
url_name = py_name.replace('_', '-')