mirror of
https://github.com/langgenius/dify.git
synced 2026-05-20 00:37:15 +08:00
- Remove response_mode from AppRunRequest; openapi /run always streams - Add POST /apps/<id>/tasks/<task_id>/stop (SIGINT hook target) - Add GET/POST /apps/<id>/form/human_input/<token> (HITL form fetch/submit) - Add GET /apps/<id>/tasks/<task_id>/events (SSE reconnect after resume) - Add HumanInputSurface.OPENAPI; map to STANDALONE_WEB_APP recipient type - Regenerate cli/src/types/data-contracts.ts via pnpm sync-models
121 lines
2.7 KiB
Python
121 lines
2.7 KiB
Python
from flask import Blueprint
|
|
from flask_restx import Namespace
|
|
|
|
from libs.device_flow_security import attach_anti_framing
|
|
from libs.external_api import ExternalApi
|
|
|
|
bp = Blueprint("openapi", __name__, url_prefix="/openapi/v1")
|
|
attach_anti_framing(bp)
|
|
|
|
api = ExternalApi(
|
|
bp,
|
|
version="1.0",
|
|
title="OpenAPI",
|
|
description="User-scoped programmatic API (bearer auth)",
|
|
)
|
|
|
|
openapi_ns = Namespace("openapi", description="User-scoped operations", path="/")
|
|
|
|
# Register response/query models BEFORE importing controller modules so that
|
|
# @openapi_ns.response / @openapi_ns.expect decorators can resolve model names.
|
|
from controllers.common.schema import register_response_schema_models, register_schema_models
|
|
from controllers.openapi._models import (
|
|
AccountPayload,
|
|
AccountResponse,
|
|
AppDescribeInfo,
|
|
AppDescribeQuery,
|
|
AppDescribeResponse,
|
|
AppInfoResponse,
|
|
AppListQuery,
|
|
AppListResponse,
|
|
AppListRow,
|
|
AppRunRequest,
|
|
DeviceCodeRequest,
|
|
DeviceCodeResponse,
|
|
DeviceLookupQuery,
|
|
DeviceLookupResponse,
|
|
DeviceMutateRequest,
|
|
DeviceMutateResponse,
|
|
DevicePollRequest,
|
|
MessageMetadata,
|
|
PermittedExternalAppsListQuery,
|
|
PermittedExternalAppsListResponse,
|
|
RevokeResponse,
|
|
SessionListResponse,
|
|
SessionRow,
|
|
TagItem,
|
|
UsageInfo,
|
|
WorkflowRunData,
|
|
WorkspaceDetailResponse,
|
|
WorkspaceListResponse,
|
|
WorkspacePayload,
|
|
WorkspaceSummaryResponse,
|
|
)
|
|
|
|
register_schema_models(
|
|
openapi_ns,
|
|
AppDescribeQuery,
|
|
AppListQuery,
|
|
AppRunRequest,
|
|
DeviceCodeRequest,
|
|
DevicePollRequest,
|
|
DeviceLookupQuery,
|
|
DeviceMutateRequest,
|
|
PermittedExternalAppsListQuery,
|
|
)
|
|
register_response_schema_models(
|
|
openapi_ns,
|
|
TagItem,
|
|
UsageInfo,
|
|
MessageMetadata,
|
|
AppListRow,
|
|
AppListResponse,
|
|
AppInfoResponse,
|
|
AppDescribeInfo,
|
|
AppDescribeResponse,
|
|
WorkflowRunData,
|
|
AccountPayload,
|
|
WorkspacePayload,
|
|
AccountResponse,
|
|
SessionRow,
|
|
SessionListResponse,
|
|
PermittedExternalAppsListResponse,
|
|
RevokeResponse,
|
|
WorkspaceSummaryResponse,
|
|
WorkspaceListResponse,
|
|
WorkspaceDetailResponse,
|
|
DeviceCodeResponse,
|
|
DeviceLookupResponse,
|
|
DeviceMutateResponse,
|
|
)
|
|
|
|
from . import (
|
|
account,
|
|
app_run,
|
|
apps,
|
|
apps_permitted_external,
|
|
human_input_form,
|
|
index,
|
|
oauth_device,
|
|
oauth_device_sso,
|
|
workflow_events,
|
|
workspaces,
|
|
)
|
|
|
|
# Request models are imported from _models.py and registered above.
|
|
|
|
__all__ = [
|
|
"account",
|
|
"app_run",
|
|
"apps",
|
|
"apps_permitted_external",
|
|
"human_input_form",
|
|
"index",
|
|
"oauth_device",
|
|
"oauth_device_sso",
|
|
"workflow_events",
|
|
"workspaces",
|
|
]
|
|
|
|
api.add_namespace(openapi_ns)
|