-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow_views.py
More file actions
26 lines (20 loc) · 937 Bytes
/
Copy pathworkflow_views.py
File metadata and controls
26 lines (20 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from typing import Any
from drf_spectacular.utils import extend_schema
from rest_framework.decorators import api_view, permission_classes
from rest_framework.permissions import IsAuthenticated
from rest_framework.request import Request
from rest_framework.response import Response
from .workflow import build_ui_schema, build_workflow_schema
@extend_schema(responses={200: Any})
@api_view(["GET"])
@permission_classes([IsAuthenticated])
def workflow_schema(request: Request) -> Response:
"""Return the full workflow schema: states, successors, field schemas, and globals."""
return Response(build_workflow_schema())
@extend_schema(responses={200: Any})
@api_view(["GET"])
@permission_classes([IsAuthenticated])
def workflow_state_schema(request: Request, state_id: str) -> Response:
"""Return the UI-enhanced JSON Schema for a given workflow state."""
schema = build_ui_schema(state_id)
return Response(schema)