Swagger UI Ready
This commit is contained in:
+15
-1
@@ -1,3 +1,17 @@
|
||||
from pathlib import Path
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
SPEC_PATH = Path(__file__).parent / 'openapi.yaml'
|
||||
|
||||
|
||||
def api_docs(request):
|
||||
"""Interactive OpenAPI documentation (Swagger UI), gated like the rest."""
|
||||
return render(request, 'api/docs.html')
|
||||
|
||||
|
||||
def api_docs_spec(request):
|
||||
"""The OpenAPI spec served to Swagger UI (YAML, gated)."""
|
||||
with open(SPEC_PATH, 'rb') as fh:
|
||||
return HttpResponse(fh.read(), content_type='application/yaml; charset=utf-8')
|
||||
|
||||
Reference in New Issue
Block a user