Skip to content

Commit f141f5d

Browse files
committed
Add OpenAPI docstrings to API endpoints
Added detailed OpenAPI-style docstrings to the plan_approval, user_clarification, and agent_message_user endpoints. These docstrings specify request parameters, request body schemas, and possible responses to improve API documentation and clarity for consumers.
1 parent 2cbc49e commit f141f5d

File tree

1 file changed

+142
-3
lines changed

1 file changed

+142
-3
lines changed

src/backend/v3/api/router.py

Lines changed: 142 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,56 @@ async def run_with_context():
358358
async def plan_approval(
359359
human_feedback: messages.PlanApprovalResponse, request: Request
360360
):
361-
"""Endpoint to receive plan approval or rejection from the user."""
361+
"""
362+
Endpoint to receive plan approval or rejection from the user.
363+
364+
---
365+
tags:
366+
- Plans
367+
parameters:
368+
- name: user_principal_id
369+
in: header
370+
type: string
371+
required: true
372+
description: User ID extracted from the authentication header
373+
requestBody:
374+
description: Plan approval payload
375+
required: true
376+
content:
377+
application/json:
378+
schema:
379+
type: object
380+
properties:
381+
m_plan_id:
382+
type: string
383+
description: The internal m_plan id for the plan (required)
384+
approved:
385+
type: boolean
386+
description: Whether the plan is approved (true) or rejected (false)
387+
feedback:
388+
type: string
389+
description: Optional feedback or comment from the user
390+
plan_id:
391+
type: string
392+
description: Optional user-facing plan_id
393+
responses:
394+
200:
395+
description: Approval recorded successfully
396+
content:
397+
application/json:
398+
schema:
399+
type: object
400+
properties:
401+
status:
402+
type: string
403+
401:
404+
description: Missing or invalid user information
405+
404:
406+
description: No active plan found for approval
407+
500:
408+
description: Internal server error
409+
"""
410+
362411
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
363412
user_id = authenticated_user["user_principal_id"]
364413
if not user_id:
@@ -420,7 +469,51 @@ async def plan_approval(
420469
async def user_clarification(
421470
human_feedback: messages.UserClarificationResponse, request: Request
422471
):
423-
"""Endpoint to receive plan approval or rejection from the user."""
472+
"""
473+
Endpoint to receive user clarification responses for clarification requests sent by the system.
474+
475+
---
476+
tags:
477+
- Plans
478+
parameters:
479+
- name: user_principal_id
480+
in: header
481+
type: string
482+
required: true
483+
description: User ID extracted from the authentication header
484+
requestBody:
485+
description: User clarification payload
486+
required: true
487+
content:
488+
application/json:
489+
schema:
490+
type: object
491+
properties:
492+
request_id:
493+
type: string
494+
description: The clarification request id sent by the system (required)
495+
answer:
496+
type: string
497+
description: The user's answer or clarification text
498+
plan_id:
499+
type: string
500+
description: (Optional) Associated plan_id
501+
m_plan_id:
502+
type: string
503+
description: (Optional) Internal m_plan id
504+
responses:
505+
200:
506+
description: Clarification recorded successfully
507+
400:
508+
description: RAI check failed or invalid input
509+
401:
510+
description: Missing or invalid user information
511+
404:
512+
description: No active plan found for clarification
513+
500:
514+
description: Internal server error
515+
"""
516+
424517
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
425518
user_id = authenticated_user["user_principal_id"]
426519
if not user_id:
@@ -493,7 +586,53 @@ async def user_clarification(
493586
async def agent_message_user(
494587
agent_message: messages.AgentMessageResponse, request: Request
495588
):
496-
"""Endpoint to receive agent messages."""
589+
"""
590+
Endpoint to receive messages from agents (agent -> user communication).
591+
592+
---
593+
tags:
594+
- Agents
595+
parameters:
596+
- name: user_principal_id
597+
in: header
598+
type: string
599+
required: true
600+
description: User ID extracted from the authentication header
601+
requestBody:
602+
description: Agent message payload
603+
required: true
604+
content:
605+
application/json:
606+
schema:
607+
type: object
608+
properties:
609+
plan_id:
610+
type: string
611+
description: ID of the plan this message relates to
612+
agent:
613+
type: string
614+
description: Name or identifier of the agent sending the message
615+
content:
616+
type: string
617+
description: The message content
618+
agent_type:
619+
type: string
620+
description: Type of agent (AI/Human)
621+
m_plan_id:
622+
type: string
623+
description: Optional internal m_plan id
624+
responses:
625+
200:
626+
description: Message recorded successfully
627+
schema:
628+
type: object
629+
properties:
630+
status:
631+
type: string
632+
401:
633+
description: Missing or invalid user information
634+
"""
635+
497636
authenticated_user = get_authenticated_user_details(request_headers=request.headers)
498637
user_id = authenticated_user["user_principal_id"]
499638
if not user_id:

0 commit comments

Comments
 (0)