mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2025-06-29 00:35:45 +08:00
Fixed subject serializer and added drf-yasg for better endpoint documentation
This commit is contained in:
parent
a33b32436d
commit
c955cadc18
6 changed files with 117 additions and 14 deletions
|
@ -76,6 +76,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'drf_yasg',
|
||||
'django.contrib.gis',
|
||||
'rest_framework',
|
||||
'rest_framework_simplejwt',
|
||||
|
|
|
@ -18,8 +18,30 @@ 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,),
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('api/v1/', include('api.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)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from django.urls import include, path
|
||||
from .views import SubjectByYearSemesterView, SubjectListView
|
||||
from .views import SubjectByCourseYearSemesterView, SubjectListView
|
||||
from rest_framework import routers
|
||||
urlpatterns = [
|
||||
path('', SubjectListView.as_view()),
|
||||
path('<slug:course_slug>/<slug:year_slug>/<slug:semester_slug>',
|
||||
SubjectByYearSemesterView.as_view()),
|
||||
SubjectByCourseYearSemesterView.as_view()),
|
||||
]
|
||||
|
|
|
@ -10,8 +10,9 @@ class SubjectListView(generics.ListAPIView):
|
|||
queryset = Subject.objects.all()
|
||||
|
||||
|
||||
class SubjectByYearSemesterView(generics.ListAPIView):
|
||||
class SubjectByCourseYearSemesterView(generics.ListAPIView):
|
||||
queryset = Subject.objects.all()
|
||||
serializer_class = SubjectSerializer
|
||||
|
||||
def get(self, request, course_slug, year_slug, semester_slug):
|
||||
# Retrieve the subjects based on year level and semester slugs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue