Skip to content

Commit

Permalink
Merge pull request #42 from SELab-2/swagger_init
Browse files Browse the repository at this point in the history
Init swagger
  • Loading branch information
EwoutV authored Mar 3, 2024
2 parents 1621f1e + c27bdba commit ce290bd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
21 changes: 21 additions & 0 deletions backend/ypovoli/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
'django.contrib.staticfiles',

# Third party
"rest_framework_swagger", # Swagger
Expand Down Expand Up @@ -109,3 +110,23 @@
USE_I18N = True
USE_L10N = False
USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
17 changes: 17 additions & 0 deletions backend/ypovoli/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,28 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.urls import path, include
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="Ypovoli API",
default_version='v1',),
public=True,
permission_classes=(permissions.AllowAny,),
)


urlpatterns = [
# Base API endpoints.
path("", include("api.urls")),
# Authentication endpoints.
path("auth/", include("authentication.urls")),
path("notifications/", include("notifications.urls")),
# Swagger documentation.
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0),
name='schema-swagger-ui'),
path('swagger<format>/', schema_view.without_ui(cache_timeout=0),
name='schema-json'),
]

0 comments on commit ce290bd

Please sign in to comment.