18 lines
517 B
Python
18 lines
517 B
Python
from pathlib import Path
|
|
|
|
from django.http import HttpResponse
|
|
from django.shortcuts import render
|
|
|
|
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')
|