Ver Fonte

📝 docs(file-module): add 401 response documentation for file routes

- 为delete、download、get-url路由添加未授权访问响应描述
- 为multipart-complete、multipart-policy、upload-policy路由添加401状态码文档
- 统一使用ErrorSchema作为未授权响应数据结构

✅ test(file-module): update integration tests with path parameter

- 在无效文件数据测试用例中添加path字段
- 在过期token测试中补充path参数
- 在错误授权头测试中完善请求参数结构
yourname há 4 semanas atrás
pai
commit
714de6aa46

+ 4 - 0
packages/file-module/src/routes/[id]/delete.ts

@@ -31,6 +31,10 @@ const deleteFileRoute = createRoute({
         }
       }
     },
+    401: {
+      description: '未授权访问',
+      content: { 'application/json': { schema: ErrorSchema } }
+    },
     404: {
       description: '文件不存在',
       content: { 'application/json': { schema: ErrorSchema } }

+ 4 - 0
packages/file-module/src/routes/[id]/download.ts

@@ -37,6 +37,10 @@ const downloadFileRoute = createRoute({
         }
       }
     },
+    401: {
+      description: '未授权访问',
+      content: { 'application/json': { schema: ErrorSchema } }
+    },
     404: {
       description: '文件不存在',
       content: { 'application/json': { schema: ErrorSchema } }

+ 4 - 0
packages/file-module/src/routes/[id]/get-url.ts

@@ -33,6 +33,10 @@ const getFileUrlRoute = createRoute({
         }
       }
     },
+    401: {
+      description: '未授权访问',
+      content: { 'application/json': { schema: ErrorSchema } }
+    },
     404: {
       description: '文件不存在',
       content: { 'application/json': { schema: ErrorSchema } }

+ 4 - 0
packages/file-module/src/routes/multipart-complete/post.ts

@@ -86,6 +86,10 @@ const completeMultipartUploadRoute = createRoute({
         'application/json': { schema: CompleteMultipartUploadResponse }
       }
     },
+    401: {
+      description: '未授权访问',
+      content: { 'application/json': { schema: ErrorSchema } }
+    },
     400: {
       description: '请求参数错误',
       content: { 'application/json': { schema: ErrorSchema } }

+ 4 - 0
packages/file-module/src/routes/multipart-policy/post.ts

@@ -74,6 +74,10 @@ const createMultipartUploadPolicyRoute = createRoute({
         }
       }
     },
+    401: {
+      description: '未授权访问',
+      content: { 'application/json': { schema: ErrorSchema } }
+    },
     400: {
       description: '请求参数错误',
       content: { 'application/json': { schema: ErrorSchema } }

+ 4 - 0
packages/file-module/src/routes/upload-policy/post.ts

@@ -44,6 +44,10 @@ const createUploadPolicyRoute = createRoute({
         }
       }
     },
+    401: {
+      description: '未授权访问',
+      content: { 'application/json': { schema: ErrorSchema } }
+    },
     400: {
       description: '请求参数错误',
       content: { 'application/json': { schema: ErrorSchema } }

+ 6 - 3
packages/file-module/tests/integration/file.routes.integration.test.ts

@@ -138,7 +138,8 @@ describe('文件路由API集成测试 (使用hono/testing)', () => {
     it('应该拒绝创建无效文件数据的请求', async () => {
       const invalidFileData = {
         name: '', // 空文件名
-        type: 'text/plain'
+        type: 'text/plain',
+        path: 'test/path.txt'
       };
 
       const response = await client['upload-policy'].$post({
@@ -509,7 +510,8 @@ describe('文件路由API集成测试 (使用hono/testing)', () => {
         json: {
           name: 'test_expired_token.txt',
           type: 'text/plain',
-          size: 1024
+          size: 1024,
+          path: 'test/expired_token.txt'
         }
       }, {
         headers: {
@@ -530,7 +532,8 @@ describe('文件路由API集成测试 (使用hono/testing)', () => {
         json: {
           name: 'test_bad_auth_header.txt',
           type: 'text/plain',
-          size: 1024
+          size: 1024,
+          path: 'test/bad_auth_header.txt'
         }
       }, {
         headers: {