feat(api): 统一官方兼容接口响应协议
兼容接口现在以入口协议作为最终响应协议,同协议保留官方 Wire 响应,跨协议统一转换成功、任务状态与错误结构。 同时修正异步提交状态边界,持久化兼容公开任务标识和官方提交响应,并新增迁移、流式响应及协议契约测试。 验证:go vet ./...;go test ./...;govulncheck ./...;pnpm lint;pnpm test;pnpm build;pnpm audit --audit-level high;pnpm openapi;全部 CI 脚本。
This commit is contained in:
@@ -39,6 +39,55 @@ type ErrorPayload struct {
|
||||
Param any `json:"param,omitempty"`
|
||||
}
|
||||
|
||||
type OpenAIErrorEnvelope struct {
|
||||
Error OpenAIErrorPayload `json:"error"`
|
||||
}
|
||||
|
||||
type OpenAIErrorPayload struct {
|
||||
Message string `json:"message" example:"Invalid parameter"`
|
||||
Type string `json:"type" example:"invalid_request_error"`
|
||||
Param string `json:"param,omitempty" example:"model"`
|
||||
Code string `json:"code,omitempty" example:"invalid_parameter"`
|
||||
}
|
||||
|
||||
type GeminiErrorEnvelope struct {
|
||||
Error GeminiErrorStatus `json:"error"`
|
||||
}
|
||||
|
||||
type GeminiErrorStatus struct {
|
||||
Code int `json:"code" example:"400"`
|
||||
Message string `json:"message" example:"Invalid argument"`
|
||||
Status string `json:"status" example:"INVALID_ARGUMENT"`
|
||||
Details []map[string]any `json:"details"`
|
||||
}
|
||||
|
||||
type VolcesErrorEnvelope struct {
|
||||
Error VolcesErrorPayload `json:"error"`
|
||||
}
|
||||
|
||||
type VolcesErrorPayload struct {
|
||||
Code string `json:"code" example:"invalid_parameter"`
|
||||
Message string `json:"message" example:"model is required"`
|
||||
}
|
||||
|
||||
type VolcesContentsGenerationTaskResponse struct {
|
||||
ID string `json:"id" example:"cgt-202607221234"`
|
||||
Model string `json:"model,omitempty"`
|
||||
Status string `json:"status,omitempty" enums:"queued,running,succeeded,failed,cancelled"`
|
||||
Content map[string]any `json:"content,omitempty"`
|
||||
CreatedAt int64 `json:"created_at,omitempty"`
|
||||
UpdatedAt int64 `json:"updated_at,omitempty"`
|
||||
Usage map[string]any `json:"usage,omitempty"`
|
||||
Error map[string]any `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type KlingErrorEnvelope struct {
|
||||
Code int `json:"code" example:"1001"`
|
||||
Message string `json:"message" example:"invalid parameter"`
|
||||
RequestID string `json:"request_id"`
|
||||
Error string `json:"error,omitempty" example:"invalid_parameter"`
|
||||
}
|
||||
|
||||
type AuthResponse struct {
|
||||
AccessToken string `json:"accessToken" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."`
|
||||
TokenType string `json:"tokenType" example:"Bearer"`
|
||||
|
||||
Reference in New Issue
Block a user