mirror of
https://github.com/langgenius/dify.git
synced 2026-06-23 04:05:14 +08:00
The app noun is the usage face; tags and author are build/management metadata that belong to studio-app, not here. Remove them end to end: - backend: drop tags/created_by_name from AppListRow, tag from AppListQuery, the TagItem model, and the tag-name filter lookup; stop hardcoding the cross-tenant blanks in the permitted-external list - cli: remove the --tag flag, TAGS/AUTHOR columns, and tag from the list query; single get app <id> no longer fabricates the fields - regenerate openapi contracts (types/zod) and markdown docs get app and get app <id> now agree (neither surfaces tags/author), resolving the list-vs-single divergence raised in review.
173 lines
4.2 KiB
Python
173 lines
4.2 KiB
Python
from flask import Blueprint
|
|
from flask_restx import Namespace
|
|
|
|
from controllers.openapi._errors import ErrorBody, OpenApiErrorCode, OpenApiErrorFormatter
|
|
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)",
|
|
error_body_formatter=OpenApiErrorFormatter(),
|
|
)
|
|
|
|
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.fields import EventStreamResponse
|
|
from controllers.common.schema import register_enum_models, register_response_schema_models, register_schema_models
|
|
from controllers.openapi._models import (
|
|
AccountPayload,
|
|
AccountResponse,
|
|
AppDescribeInfo,
|
|
AppDescribeQuery,
|
|
AppDescribeResponse,
|
|
AppDslExportQuery,
|
|
AppDslExportResponse,
|
|
AppDslImportPayload,
|
|
AppInfo,
|
|
AppListQuery,
|
|
AppListResponse,
|
|
AppListRow,
|
|
AppRunRequest,
|
|
DeviceCodeRequest,
|
|
DeviceCodeResponse,
|
|
DeviceLookupQuery,
|
|
DeviceLookupResponse,
|
|
DeviceMutateRequest,
|
|
DeviceMutateResponse,
|
|
DevicePollRequest,
|
|
DeviceTokenResponse,
|
|
FormSubmitResponse,
|
|
HealthResponse,
|
|
HumanInputFormDefinitionResponse,
|
|
MemberActionResponse,
|
|
MemberInvitePayload,
|
|
MemberInviteResponse,
|
|
MemberListQuery,
|
|
MemberListResponse,
|
|
MemberResponse,
|
|
MemberRoleUpdatePayload,
|
|
MessageMetadata,
|
|
PermittedExternalAppsListQuery,
|
|
PermittedExternalAppsListResponse,
|
|
RevokeResponse,
|
|
ServerVersionResponse,
|
|
SessionListQuery,
|
|
SessionListResponse,
|
|
SessionRow,
|
|
TaskStopResponse,
|
|
UsageInfo,
|
|
WorkflowRunData,
|
|
WorkspaceDetailResponse,
|
|
WorkspaceListResponse,
|
|
WorkspacePayload,
|
|
WorkspaceSummaryResponse,
|
|
)
|
|
from fields.file_fields import FileResponse
|
|
from services.app_dsl_service import Import
|
|
from services.entities.dsl_entities import CheckDependenciesResult
|
|
|
|
register_schema_models(
|
|
openapi_ns,
|
|
AppDescribeQuery,
|
|
AppDslImportPayload,
|
|
AppDslExportQuery,
|
|
AppListQuery,
|
|
AppRunRequest,
|
|
DeviceCodeRequest,
|
|
DevicePollRequest,
|
|
DeviceLookupQuery,
|
|
DeviceMutateRequest,
|
|
MemberInvitePayload,
|
|
MemberListQuery,
|
|
MemberRoleUpdatePayload,
|
|
PermittedExternalAppsListQuery,
|
|
SessionListQuery,
|
|
)
|
|
register_response_schema_models(
|
|
openapi_ns,
|
|
ErrorBody,
|
|
EventStreamResponse,
|
|
UsageInfo,
|
|
MessageMetadata,
|
|
AppListRow,
|
|
AppListResponse,
|
|
AppInfo,
|
|
AppDescribeInfo,
|
|
AppDescribeResponse,
|
|
AppDslExportResponse,
|
|
Import,
|
|
CheckDependenciesResult,
|
|
WorkflowRunData,
|
|
AccountPayload,
|
|
WorkspacePayload,
|
|
AccountResponse,
|
|
SessionRow,
|
|
SessionListResponse,
|
|
PermittedExternalAppsListResponse,
|
|
RevokeResponse,
|
|
WorkspaceSummaryResponse,
|
|
WorkspaceListResponse,
|
|
WorkspaceDetailResponse,
|
|
MemberResponse,
|
|
MemberListResponse,
|
|
MemberInviteResponse,
|
|
MemberActionResponse,
|
|
TaskStopResponse,
|
|
FormSubmitResponse,
|
|
HumanInputFormDefinitionResponse,
|
|
DeviceCodeResponse,
|
|
DeviceTokenResponse,
|
|
DeviceLookupResponse,
|
|
DeviceMutateResponse,
|
|
FileResponse,
|
|
ServerVersionResponse,
|
|
HealthResponse,
|
|
)
|
|
# Standalone definition for contract codegen; ErrorBody.code stays an open
|
|
# string on the wire so old clients keep parsing future codes.
|
|
register_enum_models(openapi_ns, OpenApiErrorCode)
|
|
|
|
from . import (
|
|
_meta,
|
|
account,
|
|
app_dsl,
|
|
app_run,
|
|
apps,
|
|
apps_permitted_external,
|
|
files,
|
|
human_input_form,
|
|
index,
|
|
oauth_device,
|
|
oauth_device_sso,
|
|
workflow_events,
|
|
workspaces,
|
|
)
|
|
|
|
# Request models are imported from _models.py and registered above.
|
|
|
|
__all__ = [
|
|
"_meta",
|
|
"account",
|
|
"app_dsl",
|
|
"app_run",
|
|
"apps",
|
|
"apps_permitted_external",
|
|
"files",
|
|
"human_input_form",
|
|
"index",
|
|
"oauth_device",
|
|
"oauth_device_sso",
|
|
"workflow_events",
|
|
"workspaces",
|
|
]
|
|
|
|
api.add_namespace(openapi_ns)
|