Browse Source

📝 docs(chat): update file schema definition in chat message

- inline file schema instead of importing FileSchema
- add detailed fields for file object: id, name, fullUrl, type, size
- update description for file field to clarify its purpose
yourname 6 months ago
parent
commit
282cb0b68b
1 changed files with 8 additions and 3 deletions
  1. 8 3
      src/server/modules/chat/chat-message.schema.ts

+ 8 - 3
src/server/modules/chat/chat-message.schema.ts

@@ -1,5 +1,4 @@
 import { z } from '@hono/zod-openapi';
-import { FileSchema } from '@/server/modules/files/file.schema';
 
 // 基础消息Schema
 export const ChatMessageSchema = z.object({
@@ -35,8 +34,14 @@ export const ChatMessageSchema = z.object({
     example: 1,
     description: '关联文件ID(用于图片消息)'
   }),
-  file: FileSchema.nullable().optional().openapi({
-    description: '关联文件信息(用于图片消息)'
+  file: z.object({
+    id: z.number().int().positive().openapi({ description: '文件ID' }),
+    name: z.string().max(255).openapi({ description: '文件名', example: 'example.jpg' }),
+    fullUrl: z.string().openapi({ description: '文件完整URL', example: 'https://example.com/file.jpg' }),
+    type: z.string().nullable().openapi({ description: '文件类型', example: 'image/jpeg' }),
+    size: z.number().nullable().openapi({ description: '文件大小(字节)', example: 102400 })
+  }).nullable().optional().openapi({
+    description: '{描述}文件信息'
   }),
   createdBy: z.number().int().positive().nullable().openapi({
     example: 1,