from drf_spectacular.utils import extend_schema
from rest_framework.decorators import api_view
from rest_framework.response import Response


@extend_schema(
    summary='Confirm the caller is authenticated.',
    responses={200: {'type': 'object', 'properties': {'ok': {'type': 'boolean'}}}},
)
@api_view(['GET'])
def ping(request):
    """
    The smallest authenticated endpoint, and the Phase 0 gate.

    It exists because "/api/ answers 401" is not something an empty urlconf can
    do — an unrouted path returns 404, which is indistinguishable from a broken
    deployment. This returns 401 without a token and {"ok": true} with one, so
    the whole chain (JWT auth class, default permission, renderer, URL prefix)
    is proved by a single request.
    """
    return Response({'ok': True})
