Просмотр исходного кода

✨ (openapi): 字符串字面量联合生成 enum;AI 对话路由枚举、游客 client_ip 必填

- generate.php:@return 里全是 'a'|'b' 字面量的联合类型生成 string enum
- 管理端提问记录与评价的 route 字段、filter[route] 参数带上枚举(question / term / passage / chat)
- agent-charges:client_ip 说明改为游客必填
- 删除会话:说明改为连同问答一起不可见、服务器永久保留(不再到期清除)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 4 дней назад
Родитель
Сommit
366a4a1fb1

+ 1 - 0
openapi/public/assets/protocol/resources/auto/v3-admin-agent-feedback.yaml

@@ -101,6 +101,7 @@ get:
                       nullable: true
                     route:
                       type: string
+                      enum: [question, term, passage, chat]
                       nullable: true
                     status:
                       type: string

+ 5 - 0
openapi/public/assets/protocol/resources/auto/v3-admin-agent-runs-run.yaml

@@ -67,6 +67,11 @@ get:
                     type: string
                   route:
                     type: string
+                    enum:
+                      - question
+                      - term
+                      - passage
+                      - chat
                     nullable: true
                   deep:
                     type: boolean

+ 7 - 1
openapi/public/assets/protocol/resources/auto/v3-admin-agent-runs.yaml

@@ -35,7 +35,12 @@ get:
       in: query
       schema:
         type: string
-      description: '研究路径(question / term / passage / chat)'
+        enum:
+          - question
+          - term
+          - passage
+          - chat
+      description: '研究路径:question 一般问题 / term 术语与词 / passage 阅读页提问 / chat 闲聊'
     -
       name: 'filter[account_type]'
       in: query
@@ -116,6 +121,7 @@ get:
                       type: string
                     route:
                       type: string
+                      enum: [question, term, passage, chat]
                       nullable: true
                     deep:
                       type: boolean

+ 1 - 1
openapi/public/assets/protocol/resources/auto/v3-agent-charges.yaml

@@ -39,7 +39,7 @@ post:
               description: '设备匿名 id(uuid)。游客必填'
             client_ip:
               type: string
-              description: '客户端 IP。只对游客用于同 IP 上限'
+              description: '客户端 IP(runtime 写入)。游客必填,没有就 422;只对游客用于同 IP 上限'
           required:
             - run_id
   responses:

+ 1 - 1
openapi/public/assets/protocol/resources/auto/v3-me-agent-threads-thread.yaml

@@ -65,7 +65,7 @@ delete:
     - agent-threads
   operationId: delete_api_v3_me_agent_threads_thread_
   description: |-
-    软删:从我的历史里消失,服务器保留到期(默认 180 天)后彻底清除,期间用于防滥用。
+    软删:会话连同它的问答一起从我的历史里消失,之后任何接口都读不到;服务器上的数据永久保留(防滥用、改进回答)。
     返回软删后的会话本身(200,`deleted_at` 非空),不是 204。
 
     实现:`V3\MeAgentThreadController@destroy`

+ 10 - 0
openapi/scripts/generate.php

@@ -606,6 +606,16 @@ function phpTypeToSchema(string $type): array
             }
             $concrete[] = $mem;
         }
+        // 全是字符串字面量('question'|'term'|…)→ 字符串枚举
+        $literals = array_filter($concrete, fn ($m) => preg_match("/^'[^']*'$/", $m));
+        if ($concrete && count($literals) === count($concrete)) {
+            $schema = ['type' => 'string', 'enum' => array_map(fn ($m) => trim($m, "'"), array_values($concrete))];
+            if ($nullable) {
+                $schema['nullable'] = true;
+            }
+
+            return $schema;
+        }
         $type = $concrete ? $concrete[0] : 'mixed';
     }
     $type = trim($type);