mirror of
https://github.com/langgenius/dify.git
synced 2026-06-01 06:28:14 +08:00
fix(openapi): tighten WorkflowRunResponse.mode + outputs default
- WorkflowRunResponse.mode: Literal["workflow"] (was str) — only one valid value, so Literal makes the contract explicit. - WorkflowRunData.outputs: Field(default_factory=dict) — matches the sibling metadata field's idiom; avoids the mutable-literal-default smell flagged in code review. - Extends test_response_models_dump_per_mode with an explicit assertion on the WorkflowRunResponse.mode echo + exercises CompletionMessageResponse (was imported-but-unused).
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from typing import Any, Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@ -96,7 +96,7 @@ class WorkflowRunData(BaseModel):
|
||||
id: str
|
||||
workflow_id: str
|
||||
status: str
|
||||
outputs: dict[str, Any] = {}
|
||||
outputs: dict[str, Any] = Field(default_factory=dict)
|
||||
error: str | None = None
|
||||
elapsed_time: float | None = None
|
||||
total_tokens: int | None = None
|
||||
@ -108,5 +108,5 @@ class WorkflowRunData(BaseModel):
|
||||
class WorkflowRunResponse(BaseModel):
|
||||
workflow_run_id: str
|
||||
task_id: str
|
||||
mode: str = "workflow" # echoed for CLI per-mode rendering — see endpoints.md L154
|
||||
mode: Literal["workflow"] = "workflow" # echoed for CLI per-mode rendering — see endpoints.md L154
|
||||
data: WorkflowRunData
|
||||
|
||||
Reference in New Issue
Block a user