-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial drf-yasg to drf-spectacular migration (#48)
* Initial drf-yasg to drf-spectacular migration * Edit descriptions * Install drf_spectacular * Trailing slash --------- Co-authored-by: Bane Sullivan <[email protected]>
- Loading branch information
1 parent
9491546
commit eb0a201
Showing
11 changed files
with
233 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'rest_framework', | ||
'drf_yasg', | ||
'drf_spectacular', | ||
'django_large_image', | ||
] | ||
|
||
|
@@ -129,3 +129,14 @@ | |
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field | ||
|
||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' | ||
|
||
REST_FRAMEWORK = { | ||
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema', | ||
} | ||
|
||
SPECTACULAR_SETTINGS = { | ||
'TITLE': 'Django Large Image API', | ||
'DESCRIPTION': 'Django Large Image Demo', | ||
'CONTACT': {'email': '[email protected]'}, | ||
'LICENSE': {'name': 'Apache 2.0'}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,12 +15,10 @@ | |
""" | ||
from django.contrib import admin | ||
from django.urls import include, path, re_path | ||
from django.urls import include, path | ||
from django.views.generic.base import RedirectView | ||
from drf_yasg import openapi | ||
from drf_yasg.views import get_schema_view | ||
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView | ||
from myimages.imagefiles.viewsets import ImageFileDetailViewSet | ||
from rest_framework import permissions | ||
from rest_framework.routers import SimpleRouter | ||
|
||
router = SimpleRouter(trailing_slash=False) | ||
|
@@ -32,26 +30,9 @@ | |
path(r'', RedirectView.as_view(url='admin/', permanent=False), name='index'), | ||
] + router.urls | ||
|
||
schema_view = get_schema_view( | ||
openapi.Info( | ||
title='Resonant GeoData API', | ||
default_version='v1', | ||
description='Resonant GeoData', | ||
# terms_of_service='https://www.google.com/policies/terms/', | ||
contact=openapi.Contact(email='[email protected]'), | ||
license=openapi.License(name='Apache 2.0'), | ||
), | ||
public=True, | ||
permission_classes=(permissions.AllowAny,), | ||
patterns=urlpatterns, | ||
) | ||
|
||
urlpatterns += [ | ||
re_path( | ||
r'^swagger(?P<format>\.json|\.yaml)$', | ||
schema_view.without_ui(cache_timeout=0), | ||
name='schema-json', | ||
), | ||
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), | ||
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), | ||
path('schema/', SpectacularAPIView.as_view(), name='schema'), | ||
path('swagger/', SpectacularSwaggerView.as_view(), name='schema-swagger-ui'), | ||
path('redoc/', SpectacularRedocView.as_view(), name='schema-redoc'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.