mirror of
https://github.com/langgenius/dify.git
synced 2026-10-29 18:07:39 +08:00
feat: unified ErrorBody contract for /openapi/v1 and difyctl (#37285)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
autofix-ci[bot]
parent
2bf66813ae
commit
ba59d9a4ac
@@ -168,6 +168,20 @@ export type DevicePollRequest = {
|
||||
device_code: string
|
||||
}
|
||||
|
||||
export type ErrorBody = {
|
||||
code: string
|
||||
details?: Array<ErrorDetail> | null
|
||||
hint?: string | null
|
||||
message: string
|
||||
status: number
|
||||
}
|
||||
|
||||
export type ErrorDetail = {
|
||||
loc?: Array<unknown>
|
||||
msg: string
|
||||
type: string
|
||||
}
|
||||
|
||||
export type FileResponse = {
|
||||
conversation_id?: string | null
|
||||
created_at?: number | null
|
||||
@@ -278,6 +292,37 @@ export type MessageMetadata = {
|
||||
usage?: UsageInfo
|
||||
}
|
||||
|
||||
export type OpenApiErrorCode
|
||||
= | 'app_unavailable'
|
||||
| 'bad_gateway'
|
||||
| 'bad_request'
|
||||
| 'completion_request_error'
|
||||
| 'conflict'
|
||||
| 'conversation_completed'
|
||||
| 'file_extension_blocked'
|
||||
| 'file_too_large'
|
||||
| 'filename_not_exists'
|
||||
| 'forbidden'
|
||||
| 'internal_server_error'
|
||||
| 'invalid_param'
|
||||
| 'member_license_exceeded'
|
||||
| 'member_limit_exceeded'
|
||||
| 'method_not_allowed'
|
||||
| 'model_currently_not_support'
|
||||
| 'no_file_uploaded'
|
||||
| 'not_acceptable'
|
||||
| 'not_found'
|
||||
| 'provider_not_initialize'
|
||||
| 'provider_quota_exceeded'
|
||||
| 'rate_limit_error'
|
||||
| 'request_entity_too_large'
|
||||
| 'too_many_files'
|
||||
| 'too_many_requests'
|
||||
| 'unauthorized'
|
||||
| 'unknown'
|
||||
| 'unsupported_file_type'
|
||||
| 'unsupported_media_type'
|
||||
|
||||
export type Package = {
|
||||
plugin_unique_identifier: string
|
||||
version?: string | null
|
||||
@@ -401,6 +446,12 @@ export type GetHealthData = {
|
||||
url: '/_health'
|
||||
}
|
||||
|
||||
export type GetHealthErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetHealthError = GetHealthErrors[keyof GetHealthErrors]
|
||||
|
||||
export type GetHealthResponses = {
|
||||
200: HealthResponse
|
||||
}
|
||||
@@ -414,6 +465,12 @@ export type GetVersionData = {
|
||||
url: '/_version'
|
||||
}
|
||||
|
||||
export type GetVersionErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetVersionError = GetVersionErrors[keyof GetVersionErrors]
|
||||
|
||||
export type GetVersionResponses = {
|
||||
200: ServerVersionResponse
|
||||
}
|
||||
@@ -427,6 +484,12 @@ export type GetAccountData = {
|
||||
url: '/account'
|
||||
}
|
||||
|
||||
export type GetAccountErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetAccountError = GetAccountErrors[keyof GetAccountErrors]
|
||||
|
||||
export type GetAccountResponses = {
|
||||
200: AccountResponse
|
||||
}
|
||||
@@ -443,6 +506,13 @@ export type GetAccountSessionsData = {
|
||||
url: '/account/sessions'
|
||||
}
|
||||
|
||||
export type GetAccountSessionsErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetAccountSessionsError = GetAccountSessionsErrors[keyof GetAccountSessionsErrors]
|
||||
|
||||
export type GetAccountSessionsResponses = {
|
||||
200: SessionListResponse
|
||||
}
|
||||
@@ -457,6 +527,13 @@ export type DeleteAccountSessionsSelfData = {
|
||||
url: '/account/sessions/self'
|
||||
}
|
||||
|
||||
export type DeleteAccountSessionsSelfErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type DeleteAccountSessionsSelfError
|
||||
= DeleteAccountSessionsSelfErrors[keyof DeleteAccountSessionsSelfErrors]
|
||||
|
||||
export type DeleteAccountSessionsSelfResponses = {
|
||||
200: RevokeResponse
|
||||
}
|
||||
@@ -473,6 +550,13 @@ export type DeleteAccountSessionsBySessionIdData = {
|
||||
url: '/account/sessions/{session_id}'
|
||||
}
|
||||
|
||||
export type DeleteAccountSessionsBySessionIdErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type DeleteAccountSessionsBySessionIdError
|
||||
= DeleteAccountSessionsBySessionIdErrors[keyof DeleteAccountSessionsBySessionIdErrors]
|
||||
|
||||
export type DeleteAccountSessionsBySessionIdResponses = {
|
||||
200: RevokeResponse
|
||||
}
|
||||
@@ -494,6 +578,13 @@ export type GetAppsData = {
|
||||
url: '/apps'
|
||||
}
|
||||
|
||||
export type GetAppsErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetAppsError = GetAppsErrors[keyof GetAppsErrors]
|
||||
|
||||
export type GetAppsResponses = {
|
||||
200: AppListResponse
|
||||
}
|
||||
@@ -509,6 +600,13 @@ export type GetAppsByAppIdCheckDependenciesData = {
|
||||
url: '/apps/{app_id}/check-dependencies'
|
||||
}
|
||||
|
||||
export type GetAppsByAppIdCheckDependenciesErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetAppsByAppIdCheckDependenciesError
|
||||
= GetAppsByAppIdCheckDependenciesErrors[keyof GetAppsByAppIdCheckDependenciesErrors]
|
||||
|
||||
export type GetAppsByAppIdCheckDependenciesResponses = {
|
||||
200: CheckDependenciesResult
|
||||
}
|
||||
@@ -527,6 +625,14 @@ export type GetAppsByAppIdDescribeData = {
|
||||
url: '/apps/{app_id}/describe'
|
||||
}
|
||||
|
||||
export type GetAppsByAppIdDescribeErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetAppsByAppIdDescribeError
|
||||
= GetAppsByAppIdDescribeErrors[keyof GetAppsByAppIdDescribeErrors]
|
||||
|
||||
export type GetAppsByAppIdDescribeResponses = {
|
||||
200: AppDescribeResponse
|
||||
}
|
||||
@@ -546,6 +652,13 @@ export type GetAppsByAppIdExportData = {
|
||||
url: '/apps/{app_id}/export'
|
||||
}
|
||||
|
||||
export type GetAppsByAppIdExportErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetAppsByAppIdExportError = GetAppsByAppIdExportErrors[keyof GetAppsByAppIdExportErrors]
|
||||
|
||||
export type GetAppsByAppIdExportResponses = {
|
||||
200: AppDslExportResponse
|
||||
}
|
||||
@@ -575,6 +688,7 @@ export type PostAppsByAppIdFilesUploadErrors = {
|
||||
415: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type PostAppsByAppIdFilesUploadError
|
||||
@@ -616,6 +730,14 @@ export type PostAppsByAppIdFormHumanInputByFormTokenData = {
|
||||
url: '/apps/{app_id}/form/human_input/{form_token}'
|
||||
}
|
||||
|
||||
export type PostAppsByAppIdFormHumanInputByFormTokenErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type PostAppsByAppIdFormHumanInputByFormTokenError
|
||||
= PostAppsByAppIdFormHumanInputByFormTokenErrors[keyof PostAppsByAppIdFormHumanInputByFormTokenErrors]
|
||||
|
||||
export type PostAppsByAppIdFormHumanInputByFormTokenResponses = {
|
||||
200: FormSubmitResponse
|
||||
}
|
||||
@@ -632,6 +754,12 @@ export type PostAppsByAppIdRunData = {
|
||||
url: '/apps/{app_id}/run'
|
||||
}
|
||||
|
||||
export type PostAppsByAppIdRunErrors = {
|
||||
422: ErrorBody
|
||||
}
|
||||
|
||||
export type PostAppsByAppIdRunError = PostAppsByAppIdRunErrors[keyof PostAppsByAppIdRunErrors]
|
||||
|
||||
export type PostAppsByAppIdRunResponses = {
|
||||
200: {
|
||||
[key: string]: unknown
|
||||
@@ -670,6 +798,13 @@ export type PostAppsByAppIdTasksByTaskIdStopData = {
|
||||
url: '/apps/{app_id}/tasks/{task_id}/stop'
|
||||
}
|
||||
|
||||
export type PostAppsByAppIdTasksByTaskIdStopErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type PostAppsByAppIdTasksByTaskIdStopError
|
||||
= PostAppsByAppIdTasksByTaskIdStopErrors[keyof PostAppsByAppIdTasksByTaskIdStopErrors]
|
||||
|
||||
export type PostAppsByAppIdTasksByTaskIdStopResponses = {
|
||||
200: TaskStopResponse
|
||||
}
|
||||
@@ -763,6 +898,14 @@ export type GetPermittedExternalAppsData = {
|
||||
url: '/permitted-external-apps'
|
||||
}
|
||||
|
||||
export type GetPermittedExternalAppsErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetPermittedExternalAppsError
|
||||
= GetPermittedExternalAppsErrors[keyof GetPermittedExternalAppsErrors]
|
||||
|
||||
export type GetPermittedExternalAppsResponses = {
|
||||
200: PermittedExternalAppsListResponse
|
||||
}
|
||||
@@ -777,6 +920,12 @@ export type GetWorkspacesData = {
|
||||
url: '/workspaces'
|
||||
}
|
||||
|
||||
export type GetWorkspacesErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetWorkspacesError = GetWorkspacesErrors[keyof GetWorkspacesErrors]
|
||||
|
||||
export type GetWorkspacesResponses = {
|
||||
200: WorkspaceListResponse
|
||||
}
|
||||
@@ -792,6 +941,13 @@ export type GetWorkspacesByWorkspaceIdData = {
|
||||
url: '/workspaces/{workspace_id}'
|
||||
}
|
||||
|
||||
export type GetWorkspacesByWorkspaceIdErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetWorkspacesByWorkspaceIdError
|
||||
= GetWorkspacesByWorkspaceIdErrors[keyof GetWorkspacesByWorkspaceIdErrors]
|
||||
|
||||
export type GetWorkspacesByWorkspaceIdResponses = {
|
||||
200: WorkspaceDetailResponse
|
||||
}
|
||||
@@ -810,6 +966,8 @@ export type PostWorkspacesByWorkspaceIdAppsImportsData = {
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdAppsImportsErrors = {
|
||||
400: Import
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdAppsImportsError
|
||||
@@ -835,6 +993,7 @@ export type PostWorkspacesByWorkspaceIdAppsImportsByImportIdConfirmData = {
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdAppsImportsByImportIdConfirmErrors = {
|
||||
400: Import
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdAppsImportsByImportIdConfirmError
|
||||
@@ -859,6 +1018,14 @@ export type GetWorkspacesByWorkspaceIdMembersData = {
|
||||
url: '/workspaces/{workspace_id}/members'
|
||||
}
|
||||
|
||||
export type GetWorkspacesByWorkspaceIdMembersErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type GetWorkspacesByWorkspaceIdMembersError
|
||||
= GetWorkspacesByWorkspaceIdMembersErrors[keyof GetWorkspacesByWorkspaceIdMembersErrors]
|
||||
|
||||
export type GetWorkspacesByWorkspaceIdMembersResponses = {
|
||||
200: MemberListResponse
|
||||
}
|
||||
@@ -875,6 +1042,14 @@ export type PostWorkspacesByWorkspaceIdMembersData = {
|
||||
url: '/workspaces/{workspace_id}/members'
|
||||
}
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdMembersErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdMembersError
|
||||
= PostWorkspacesByWorkspaceIdMembersErrors[keyof PostWorkspacesByWorkspaceIdMembersErrors]
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdMembersResponses = {
|
||||
201: MemberInviteResponse
|
||||
}
|
||||
@@ -892,6 +1067,13 @@ export type DeleteWorkspacesByWorkspaceIdMembersByMemberIdData = {
|
||||
url: '/workspaces/{workspace_id}/members/{member_id}'
|
||||
}
|
||||
|
||||
export type DeleteWorkspacesByWorkspaceIdMembersByMemberIdErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type DeleteWorkspacesByWorkspaceIdMembersByMemberIdError
|
||||
= DeleteWorkspacesByWorkspaceIdMembersByMemberIdErrors[keyof DeleteWorkspacesByWorkspaceIdMembersByMemberIdErrors]
|
||||
|
||||
export type DeleteWorkspacesByWorkspaceIdMembersByMemberIdResponses = {
|
||||
200: MemberActionResponse
|
||||
}
|
||||
@@ -909,6 +1091,14 @@ export type PutWorkspacesByWorkspaceIdMembersByMemberIdRoleData = {
|
||||
url: '/workspaces/{workspace_id}/members/{member_id}/role'
|
||||
}
|
||||
|
||||
export type PutWorkspacesByWorkspaceIdMembersByMemberIdRoleErrors = {
|
||||
422: ErrorBody
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type PutWorkspacesByWorkspaceIdMembersByMemberIdRoleError
|
||||
= PutWorkspacesByWorkspaceIdMembersByMemberIdRoleErrors[keyof PutWorkspacesByWorkspaceIdMembersByMemberIdRoleErrors]
|
||||
|
||||
export type PutWorkspacesByWorkspaceIdMembersByMemberIdRoleResponses = {
|
||||
200: MemberActionResponse
|
||||
}
|
||||
@@ -925,6 +1115,13 @@ export type PostWorkspacesByWorkspaceIdSwitchData = {
|
||||
url: '/workspaces/{workspace_id}/switch'
|
||||
}
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdSwitchErrors = {
|
||||
default: ErrorBody
|
||||
}
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdSwitchError
|
||||
= PostWorkspacesByWorkspaceIdSwitchErrors[keyof PostWorkspacesByWorkspaceIdSwitchErrors]
|
||||
|
||||
export type PostWorkspacesByWorkspaceIdSwitchResponses = {
|
||||
200: WorkspaceDetailResponse
|
||||
}
|
||||
|
||||
@@ -156,6 +156,30 @@ export const zDevicePollRequest = z.object({
|
||||
device_code: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* ErrorDetail
|
||||
*/
|
||||
export const zErrorDetail = z.object({
|
||||
loc: z.array(z.unknown()).optional().default([]),
|
||||
msg: z.string(),
|
||||
type: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* ErrorBody
|
||||
*
|
||||
* Canonical non-2xx body. ``code`` is typed ``str`` (not the enum) so the
|
||||
* generated client schema stays an open enum — old CLIs keep parsing when a
|
||||
* future server adds a code. Formatter tests pin emitted values to the enum.
|
||||
*/
|
||||
export const zErrorBody = z.object({
|
||||
code: z.string(),
|
||||
details: z.array(zErrorDetail).nullish(),
|
||||
hint: z.string().nullish(),
|
||||
message: z.string(),
|
||||
status: z.int(),
|
||||
})
|
||||
|
||||
/**
|
||||
* FileResponse
|
||||
*/
|
||||
@@ -308,6 +332,41 @@ export const zMemberRoleUpdatePayload = z.object({
|
||||
role: z.enum(['admin', 'normal']),
|
||||
})
|
||||
|
||||
/**
|
||||
* OpenApiErrorCode
|
||||
*/
|
||||
export const zOpenApiErrorCode = z.enum([
|
||||
'app_unavailable',
|
||||
'bad_gateway',
|
||||
'bad_request',
|
||||
'completion_request_error',
|
||||
'conflict',
|
||||
'conversation_completed',
|
||||
'file_extension_blocked',
|
||||
'file_too_large',
|
||||
'filename_not_exists',
|
||||
'forbidden',
|
||||
'internal_server_error',
|
||||
'invalid_param',
|
||||
'member_license_exceeded',
|
||||
'member_limit_exceeded',
|
||||
'method_not_allowed',
|
||||
'model_currently_not_support',
|
||||
'no_file_uploaded',
|
||||
'not_acceptable',
|
||||
'not_found',
|
||||
'provider_not_initialize',
|
||||
'provider_quota_exceeded',
|
||||
'rate_limit_error',
|
||||
'request_entity_too_large',
|
||||
'too_many_files',
|
||||
'too_many_requests',
|
||||
'unauthorized',
|
||||
'unknown',
|
||||
'unsupported_file_type',
|
||||
'unsupported_media_type',
|
||||
])
|
||||
|
||||
/**
|
||||
* Package
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user