Keep standalone task schema aligned with explicit TTS protocol
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
此目录提供五类 HTTP 响应和六类 MQ 消息的独立校验入口,使用 JSON Schema Draft 2020-12。重复且约束相同的结构通过相对 `$ref` 引用 `common.schema.json`,仅单个入口使用的结构保留在该入口的 `$defs` 中。
|
||||
|
||||
本次仅新增文件,不替换或删除 `contracts/local/` 的原文件,不修改现有程序的校验入口、嵌入资源或来源清单。程序仍使用原有 Schema;此目录尚未接入运行或发布流程,不构成外部 SaaS 签收。
|
||||
此目录不替换或删除 `contracts/local/` 的原文件,不修改现有程序的校验入口、嵌入资源或来源清单。现行定义仍以 `contracts/local/` 和 `docs/thirds/saas-dispatcher.md` 为准,拆分副本必须随其同步;单元测试核对任务 TTS 定义完全一致,防止协议字段等内容漂移。程序仍使用原有 Schema;此目录尚未接入运行或发布流程,不构成外部 SaaS 签收。
|
||||
|
||||
## HTTP 响应
|
||||
|
||||
|
||||
@@ -302,12 +302,17 @@
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"provider_id",
|
||||
"protocol",
|
||||
"model",
|
||||
"voice",
|
||||
"language_type",
|
||||
"format"
|
||||
],
|
||||
"properties": {
|
||||
"protocol": {
|
||||
"enum": ["dashscope_tts_http", "dashscope_task_websocket"],
|
||||
"$comment": "Task selects the protocol; never infer it from model names or endpoint availability."
|
||||
},
|
||||
"provider_id": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package contracts_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStandaloneTaskTTSMatchesCurrentContract(t *testing.T) {
|
||||
load := func(path string) map[string]any {
|
||||
t.Helper()
|
||||
body, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var schema map[string]any
|
||||
if err = json.Unmarshal(body, &schema); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return schema
|
||||
}
|
||||
current := load("local/config-read.schema.json")
|
||||
exported := load("schema/http-task-detail.schema.json")
|
||||
expected := current["$defs"].(map[string]any)["tts"]
|
||||
actual := exported["$defs"].(map[string]any)["tts"]
|
||||
if !reflect.DeepEqual(expected, actual) {
|
||||
t.Fatal("standalone task TTS schema has drifted from contracts/local; update the exported copy, not the runtime contract")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user