Skip to content

Commit e7dd8d6

Browse files
committed
Added /api/health_check/ to swagger documentation
1 parent e4520ec commit e7dd8d6

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

seed/views/main.py

+53-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
from django.db import connection
1515
from django.http import JsonResponse
1616
from django.shortcuts import redirect, render
17-
from django.views.decorators.http import require_GET
17+
from drf_yasg.utils import swagger_auto_schema
1818
from rest_framework import status
19-
from rest_framework.decorators import api_view
19+
from rest_framework.decorators import api_view, permission_classes
20+
from rest_framework.permissions import AllowAny
2021

2122
from seed.celery import app
2223
from seed.decorators import ajax_request
2324
from seed.lib.superperms.orgs.decorators import has_perm_class
2425
from seed.utils.api import api_endpoint
26+
from seed.utils.api_schema import AutoSchemaHelper
2527
from seed.utils.users import get_js_role
2628

2729
_log = logging.getLogger(__name__)
@@ -124,6 +126,42 @@ def celery_queue(request):
124126
return JsonResponse(results)
125127

126128

129+
@swagger_auto_schema(
130+
method="GET",
131+
responses={
132+
200: AutoSchemaHelper.schema_factory(
133+
{
134+
"status": "string",
135+
"postgres": "string",
136+
"celery": "string",
137+
"redis": "string",
138+
},
139+
example={
140+
"status": "healthy",
141+
"postgres": "success",
142+
"celery": "success",
143+
"redis": "success",
144+
},
145+
),
146+
418: AutoSchemaHelper.schema_factory(
147+
{
148+
"status": "string",
149+
"postgres": "string",
150+
"celery": "string",
151+
"redis": "string",
152+
},
153+
example={
154+
"status": "unhealthy",
155+
"postgres": "success",
156+
"celery": "error",
157+
"redis": "success",
158+
},
159+
),
160+
},
161+
)
162+
@api_view(["GET"])
163+
@permission_classes([AllowAny])
164+
@ajax_request
127165
def health_check(request):
128166
"""
129167
Perform a health check without requiring authentication
@@ -158,11 +196,22 @@ def health_check(request):
158196
)
159197

160198

199+
@swagger_auto_schema(
200+
method="GET",
201+
responses={
202+
200: AutoSchemaHelper.schema_factory(
203+
{
204+
"allow_signup": "boolean",
205+
}
206+
)
207+
},
208+
)
209+
@api_view(["GET"])
210+
@permission_classes([AllowAny])
161211
@ajax_request
162-
@require_GET
163212
def config(request):
164213
"""
165-
Returns readonly django settings
214+
Returns readonly django settings without requiring authentication
166215
"""
167216

168217
return {

0 commit comments

Comments
 (0)