prije uspostave API documentation
This commit is contained in:
parent
ade8ea32e2
commit
92d98a299c
Binary file not shown.
@ -19,6 +19,8 @@ class ObjektSigurnostiList(generics.ListCreateAPIView):
|
|||||||
queryset = ObjektSigurnosti.objects.all().order_by("naziv")
|
queryset = ObjektSigurnosti.objects.all().order_by("naziv")
|
||||||
serializer_class = ObjektSigurnostiSerializer
|
serializer_class = ObjektSigurnostiSerializer
|
||||||
pagination_class = CustomObjektSigurnostiPagination
|
pagination_class = CustomObjektSigurnostiPagination
|
||||||
|
permission_classes = []
|
||||||
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -49,6 +49,8 @@ INSTALLED_APPS = [
|
|||||||
'django_extensions',
|
'django_extensions',
|
||||||
# 3rd party
|
# 3rd party
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
|
'drf_yasg',
|
||||||
|
'rest_framework_swagger',
|
||||||
# Custom apps:
|
# Custom apps:
|
||||||
'plovidba_aplikacija',
|
'plovidba_aplikacija',
|
||||||
|
|
||||||
@ -122,6 +124,21 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Define DRF settings
|
||||||
|
REST_FRAMEWORK = {
|
||||||
|
"DEFAULT_AUTHENTICATION_CLASSES": [
|
||||||
|
"rest_framework_simplejwt.authentication.JWTAuthentication",
|
||||||
|
],
|
||||||
|
"DEFAULT_PERMISSION_CLASSES": [
|
||||||
|
"rest_framework.permissions.IsAuthenticated",
|
||||||
|
],
|
||||||
|
"DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"],
|
||||||
|
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
|
||||||
|
"PAGE_SIZE": 100,
|
||||||
|
}
|
||||||
|
|
||||||
|
# API docs
|
||||||
|
SHOW_API_DOCS = ENV_BOOL("SHOW_API_DOCS", True)
|
||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
||||||
|
|||||||
@ -14,11 +14,39 @@ Including another URLconf
|
|||||||
1. Import the include() function: from django.urls import include, path
|
1. Import the include() function: from django.urls import include, path
|
||||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from plovidba_aplikacija import views
|
from plovidba_aplikacija import views
|
||||||
|
|
||||||
|
from drf_yasg import openapi
|
||||||
|
from drf_yasg.views import get_schema_view
|
||||||
|
from drf_yasg import openapi
|
||||||
|
from rest_framework import permissions
|
||||||
|
|
||||||
|
|
||||||
|
api_schema_view = get_schema_view(
|
||||||
|
openapi.Info(
|
||||||
|
title="API docs",
|
||||||
|
default_version='v1',
|
||||||
|
description="Swagger docs for ListLabs API",
|
||||||
|
contact=openapi.Contact(email="elena.maric@listlabs.net")
|
||||||
|
),
|
||||||
|
public=True,
|
||||||
|
permission_classes=[permissions.AllowAny],
|
||||||
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('api/', include('plovidba_aplikacija.urls')),
|
path('api/', include('plovidba_aplikacija.urls')),
|
||||||
]
|
path("swagger/", api_schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
|
||||||
|
path("redoc/", api_schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
|
||||||
|
]
|
||||||
|
|
||||||
|
if settings.SHOW_API_DOCS:
|
||||||
|
urlpatterns += [
|
||||||
|
path('api/docs/swagger/',
|
||||||
|
api_schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
|
||||||
|
path('api/docs/redoc/',
|
||||||
|
api_schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc-ui')
|
||||||
|
]
|
||||||
Loading…
x
Reference in New Issue
Block a user