From e4af30dd74684c1fad60878a1f0524a5d95e9549 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 20 Mar 2024 11:33:17 +0100 Subject: [PATCH] SCRUM-107_Cool_View --- api/urls.py | 2 ++ api/views.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/api/urls.py b/api/urls.py index 7796244..355eccb 100644 --- a/api/urls.py +++ b/api/urls.py @@ -30,6 +30,7 @@ SetStudentAttView, SetTeacherAttView, test, + test2, MailTestView, UnsetStudentAttView, genAdmin, @@ -52,6 +53,7 @@ urlpatterns = [ path('test', test), + path('test2', test2), path('send_welcome_email', MailTestView.as_view(), name='send_welcome_email'), path('genadmin', genAdmin), diff --git a/api/views.py b/api/views.py index 1b33d48..3c7bd26 100644 --- a/api/views.py +++ b/api/views.py @@ -49,6 +49,28 @@ def test(request): """ return Response({"ping": "pong"}, 200) +@extend_schema( + methods=['GET'], # Specify methods if @api_view is not used, otherwise redundant + summary="Ping Pong 2", + description="Returns a simple ping to a pong2 response.", + responses={ + status.HTTP_200_OK: OpenApiResponse(description="Success - Returns a ping pong2 response."), + # Add more status codes as needed + } +) +@api_view(['GET']) +def test2(request): + """ + A simple API endpoint that responds with a 'pong2' to a 'ping' request. + + Args: + request (Request): The request object. + + Returns: + Response: A JSON response containing {"ping": "pong2"}. + """ + return Response({"ping": "pong2"}, 200) + @extend_schema( summary="Send Test Email", description="Tries to send a test email.",