mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2025-06-28 16:25:44 +08:00
Migrate to DRF-Spectacular instead of drf-yasg
This commit is contained in:
parent
c955cadc18
commit
6af2bd0c0d
5 changed files with 1452 additions and 41 deletions
|
@ -29,9 +29,19 @@ SECRET_KEY = str(os.getenv('SECRET_KEY'))
|
|||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
FRONTEND_DEBUG = True
|
||||
FRONTEND_DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*', '127.0.0.1', 'localhost', '10.0.10.32', '10.0.10.8']
|
||||
ALLOWED_HOSTS = ['*']
|
||||
CSRF_TRUSTED_ORIGINS = ["https://stude.keannu1.duckdns.org"]
|
||||
|
||||
# DRF-Spectacular
|
||||
SPECTACULAR_SETTINGS = {
|
||||
'TITLE': 'StudE API',
|
||||
'DESCRIPTION': 'A Capstone project',
|
||||
'VERSION': '1.0.0',
|
||||
'SERVE_INCLUDE_SCHEMA': False,
|
||||
# OTHER SETTINGS
|
||||
}
|
||||
|
||||
# Email credentials
|
||||
EMAIL_HOST = ''
|
||||
|
@ -76,7 +86,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'drf_yasg',
|
||||
'drf_spectacular',
|
||||
'django.contrib.gis',
|
||||
'rest_framework',
|
||||
'rest_framework_simplejwt',
|
||||
|
@ -133,7 +143,8 @@ TEMPLATES = [
|
|||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
||||
)
|
||||
),
|
||||
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
|
||||
}
|
||||
|
||||
WSGI_APPLICATION = 'config.wsgi.application'
|
||||
|
|
|
@ -18,30 +18,13 @@ from django.contrib import admin
|
|||
from django.urls import path, include
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.urls import re_path
|
||||
from rest_framework import permissions
|
||||
from drf_yasg.views import get_schema_view
|
||||
from drf_yasg import openapi
|
||||
|
||||
schema_view = get_schema_view(
|
||||
openapi.Info(
|
||||
title="StudE API",
|
||||
default_version='v1',
|
||||
description="StudE Endpoints",
|
||||
terms_of_service="https://www.google.com/policies/terms/",
|
||||
contact=openapi.Contact(email="noehbernasol0@gmail.com"),
|
||||
),
|
||||
public=True,
|
||||
permission_classes=(permissions.AllowAny,),
|
||||
)
|
||||
|
||||
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
|
||||
urlpatterns = [
|
||||
path('schema/', SpectacularAPIView.as_view(), name='schema'),
|
||||
path('swagger/',
|
||||
SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
|
||||
path('redoc/',
|
||||
SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
|
||||
path('admin/', admin.site.urls),
|
||||
path('api/v1/', include('api.urls')),
|
||||
path('swagger<format>/', 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'),
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
|
1298
stude/schema.yml
Normal file
1298
stude/schema.yml
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue