Commit d579559c by Ryo Committed by GitHub

fix: openapi schema issue while creating openapi json (#6727)

parent c8bbd8a6
...@@ -49,7 +49,7 @@ const AIChatItemSchema = z.object({ ...@@ -49,7 +49,7 @@ const AIChatItemSchema = z.object({
}); });
export type AIChatItemType = z.infer<typeof AIChatItemSchema>; export type AIChatItemType = z.infer<typeof AIChatItemSchema>;
const HelperBotChatRoleSchema = z.discriminatedUnion('obj', [ const HelperBotChatRoleSchema = z.union([
UserChatItemSchema, UserChatItemSchema,
SystemChatItemSchema, SystemChatItemSchema,
AIChatItemSchema AIChatItemSchema
......
...@@ -4,7 +4,7 @@ import { z } from 'zod'; ...@@ -4,7 +4,7 @@ import { z } from 'zod';
/** /**
* 文件操作 - 统一请求体 * 文件操作 - 统一请求体
*/ */
export const SandboxFileOperationBodySchema = z.discriminatedUnion('action', [ export const SandboxFileOperationBodySchema = z.union([
z.object({ z.object({
action: z.literal('list'), action: z.literal('list'),
appId: z.string(), appId: z.string(),
......
...@@ -6,6 +6,21 @@ import { StoreEdgeItemTypeSchema } from '../../../../core/workflow/type/edge'; ...@@ -6,6 +6,21 @@ import { StoreEdgeItemTypeSchema } from '../../../../core/workflow/type/edge';
import { StoreNodeItemTypeSchema } from '../../../../core/workflow/type/node'; import { StoreNodeItemTypeSchema } from '../../../../core/workflow/type/node';
import { ShortUrlSchema } from '../../../../support/marketing/type'; import { ShortUrlSchema } from '../../../../support/marketing/type';
import { z } from 'zod'; import { z } from 'zod';
import { FlowNodeOutputItemTypeSchema } from '../../../../core/workflow/type/io';
const OpenAPIFlowNodeOutputItemTypeSchema = FlowNodeOutputItemTypeSchema.omit({
invalidCondition: true
}).extend({
invalidCondition: z.any().optional().meta({
description: 'Internal editor validation function. This field is not expected in API payloads.'
})
});
const OpenAPIStoreNodeItemTypeSchema = StoreNodeItemTypeSchema.omit({
outputs: true
}).extend({
outputs: z.array(OpenAPIFlowNodeOutputItemTypeSchema)
});
/* Get App Permission */ /* Get App Permission */
export const GetAppPermissionQuerySchema = z.object({ export const GetAppPermissionQuerySchema = z.object({
...@@ -14,6 +29,7 @@ export const GetAppPermissionQuerySchema = z.object({ ...@@ -14,6 +29,7 @@ export const GetAppPermissionQuerySchema = z.object({
description: '应用 ID' description: '应用 ID'
}) })
}); });
export type GetAppPermissionQueryType = z.infer<typeof GetAppPermissionQuerySchema>; export type GetAppPermissionQueryType = z.infer<typeof GetAppPermissionQuerySchema>;
export const GetAppPermissionResponseSchema = z.object({ export const GetAppPermissionResponseSchema = z.object({
...@@ -58,7 +74,7 @@ export const CreateAppBodySchema = z ...@@ -58,7 +74,7 @@ export const CreateAppBodySchema = z
example: AppTypeEnum.workflow, example: AppTypeEnum.workflow,
description: '应用类型' description: '应用类型'
}), }),
modules: z.array(StoreNodeItemTypeSchema).meta({ modules: z.array(OpenAPIStoreNodeItemTypeSchema).meta({
example: [], example: [],
description: '应用节点配置' description: '应用节点配置'
}), }),
......
...@@ -59,11 +59,9 @@ export const HelperBotCompletionsParamsSchema = z.object({ ...@@ -59,11 +59,9 @@ export const HelperBotCompletionsParamsSchema = z.object({
name: z.string() name: z.string()
}) })
), ),
metadata: z.discriminatedUnion('type', [ metadata: z.object({
z.object({ type: z.literal(HelperBotTypeEnum.topAgent),
type: z.literal(HelperBotTypeEnum.topAgent), data: topAgentParamsSchema
data: topAgentParamsSchema })
})
])
}); });
export type HelperBotCompletionsParamsType = z.infer<typeof HelperBotCompletionsParamsSchema>; export type HelperBotCompletionsParamsType = z.infer<typeof HelperBotCompletionsParamsSchema>;
...@@ -2,6 +2,26 @@ import { z } from 'zod'; ...@@ -2,6 +2,26 @@ import { z } from 'zod';
import { OAuthEnum } from '../../../../../support/user/constant'; import { OAuthEnum } from '../../../../../support/user/constant';
import { TrackRegisterParamsSchema } from '../../../../../support/marketing/type'; import { TrackRegisterParamsSchema } from '../../../../../support/marketing/type';
import { LanguageSchema } from '../../../../../common/i18n/type'; import { LanguageSchema } from '../../../../../common/i18n/type';
import { TeamTmbItemSchema } from '../../../../../support/user/team/type';
import { UserSchema } from '../../../../../support/user/type';
const OpenAPITeamTmbItemSchema = TeamTmbItemSchema.omit({
permission: true
}).extend({
permission: z.any().meta({
description: '团队权限实例。返回值为服务端权限对象,文档中按任意结构展示。'
})
});
export const OpenAPIUserSchema = UserSchema.omit({
team: true,
permission: true
}).extend({
team: OpenAPITeamTmbItemSchema,
permission: z.any().meta({
description: '用户权限实例。返回值为服务端权限对象,文档中按任意结构展示。'
})
});
export const LoginSuccessResponseSchema = z.object({ export const LoginSuccessResponseSchema = z.object({
user: z.any().meta({ user: z.any().meta({
......
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
GetWXLoginQRResponseSchema, GetWXLoginQRResponseSchema,
LoginSuccessResponseSchema LoginSuccessResponseSchema
} from './api'; } from './api';
import { UserSchema } from '../../../../../support/user/type'; import { OpenAPIUserSchema } from './api';
export const LoginPath: OpenAPIPath = { export const LoginPath: OpenAPIPath = {
'/support/user/account/tokenLogin': { '/support/user/account/tokenLogin': {
...@@ -23,7 +23,7 @@ export const LoginPath: OpenAPIPath = { ...@@ -23,7 +23,7 @@ export const LoginPath: OpenAPIPath = {
description: '成功获取用户信息', description: '成功获取用户信息',
content: { content: {
'application/json': { 'application/json': {
schema: UserSchema schema: OpenAPIUserSchema
} }
} }
} }
......
...@@ -76,7 +76,7 @@ export const CreateExtractDatasetBillSchema = z ...@@ -76,7 +76,7 @@ export const CreateExtractDatasetBillSchema = z
discountCouponId: z.string().optional().meta({ description: '优惠券 ID(未使用)' }) discountCouponId: z.string().optional().meta({ description: '优惠券 ID(未使用)' })
}) })
.meta({ description: '额外数据集存储订单创建参数' }); .meta({ description: '额外数据集存储订单创建参数' });
export const CreateBillPropsSchema = z.discriminatedUnion('type', [ export const CreateBillPropsSchema = z.union([
CreateStandPlanBillSchema, CreateStandPlanBillSchema,
CreateExtractPointsBillSchema, CreateExtractPointsBillSchema,
CreateExtractDatasetBillSchema CreateExtractDatasetBillSchema
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment