mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-17 02:06:41 +08:00
fix: openapi schema issue while creating openapi json (#6727)
This commit is contained in:
@@ -49,7 +49,7 @@ const AIChatItemSchema = z.object({
|
||||
});
|
||||
export type AIChatItemType = z.infer<typeof AIChatItemSchema>;
|
||||
|
||||
const HelperBotChatRoleSchema = z.discriminatedUnion('obj', [
|
||||
const HelperBotChatRoleSchema = z.union([
|
||||
UserChatItemSchema,
|
||||
SystemChatItemSchema,
|
||||
AIChatItemSchema
|
||||
|
||||
@@ -4,7 +4,7 @@ import { z } from 'zod';
|
||||
/**
|
||||
* 文件操作 - 统一请求体
|
||||
*/
|
||||
export const SandboxFileOperationBodySchema = z.discriminatedUnion('action', [
|
||||
export const SandboxFileOperationBodySchema = z.union([
|
||||
z.object({
|
||||
action: z.literal('list'),
|
||||
appId: z.string(),
|
||||
|
||||
@@ -6,6 +6,21 @@ import { StoreEdgeItemTypeSchema } from '../../../../core/workflow/type/edge';
|
||||
import { StoreNodeItemTypeSchema } from '../../../../core/workflow/type/node';
|
||||
import { ShortUrlSchema } from '../../../../support/marketing/type';
|
||||
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 */
|
||||
export const GetAppPermissionQuerySchema = z.object({
|
||||
@@ -14,6 +29,7 @@ export const GetAppPermissionQuerySchema = z.object({
|
||||
description: '应用 ID'
|
||||
})
|
||||
});
|
||||
|
||||
export type GetAppPermissionQueryType = z.infer<typeof GetAppPermissionQuerySchema>;
|
||||
|
||||
export const GetAppPermissionResponseSchema = z.object({
|
||||
@@ -58,7 +74,7 @@ export const CreateAppBodySchema = z
|
||||
example: AppTypeEnum.workflow,
|
||||
description: '应用类型'
|
||||
}),
|
||||
modules: z.array(StoreNodeItemTypeSchema).meta({
|
||||
modules: z.array(OpenAPIStoreNodeItemTypeSchema).meta({
|
||||
example: [],
|
||||
description: '应用节点配置'
|
||||
}),
|
||||
|
||||
@@ -59,11 +59,9 @@ export const HelperBotCompletionsParamsSchema = z.object({
|
||||
name: z.string()
|
||||
})
|
||||
),
|
||||
metadata: z.discriminatedUnion('type', [
|
||||
z.object({
|
||||
type: z.literal(HelperBotTypeEnum.topAgent),
|
||||
data: topAgentParamsSchema
|
||||
})
|
||||
])
|
||||
metadata: z.object({
|
||||
type: z.literal(HelperBotTypeEnum.topAgent),
|
||||
data: topAgentParamsSchema
|
||||
})
|
||||
});
|
||||
export type HelperBotCompletionsParamsType = z.infer<typeof HelperBotCompletionsParamsSchema>;
|
||||
|
||||
@@ -2,6 +2,26 @@ import { z } from 'zod';
|
||||
import { OAuthEnum } from '../../../../../support/user/constant';
|
||||
import { TrackRegisterParamsSchema } from '../../../../../support/marketing/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({
|
||||
user: z.any().meta({
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
GetWXLoginQRResponseSchema,
|
||||
LoginSuccessResponseSchema
|
||||
} from './api';
|
||||
import { UserSchema } from '../../../../../support/user/type';
|
||||
import { OpenAPIUserSchema } from './api';
|
||||
|
||||
export const LoginPath: OpenAPIPath = {
|
||||
'/support/user/account/tokenLogin': {
|
||||
@@ -23,7 +23,7 @@ export const LoginPath: OpenAPIPath = {
|
||||
description: '成功获取用户信息',
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: UserSchema
|
||||
schema: OpenAPIUserSchema
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ export const CreateExtractDatasetBillSchema = z
|
||||
discountCouponId: z.string().optional().meta({ description: '优惠券 ID(未使用)' })
|
||||
})
|
||||
.meta({ description: '额外数据集存储订单创建参数' });
|
||||
export const CreateBillPropsSchema = z.discriminatedUnion('type', [
|
||||
export const CreateBillPropsSchema = z.union([
|
||||
CreateStandPlanBillSchema,
|
||||
CreateExtractPointsBillSchema,
|
||||
CreateExtractDatasetBillSchema
|
||||
|
||||
Reference in New Issue
Block a user