feat: 完成P13治理收尾并创建P14执行合同(Issue: P13-1,P13-2,P13-3,P13-4,P13-5,P13-6,P13-7,P13-8,P14-0)
这个提交包含在:
@@ -0,0 +1,89 @@
|
||||
const REQUEST_ID_SCHEMA = {
|
||||
type: "string",
|
||||
description: "服务端生成的请求追踪ID",
|
||||
};
|
||||
|
||||
const ERROR_DETAILS_SCHEMA = {
|
||||
type: "object",
|
||||
additionalProperties: true,
|
||||
};
|
||||
|
||||
const ERROR_BODY_SCHEMA = {
|
||||
type: "object",
|
||||
required: ["code", "message", "details"],
|
||||
properties: {
|
||||
code: { type: "string" },
|
||||
message: { type: "string" },
|
||||
details: ERROR_DETAILS_SCHEMA,
|
||||
},
|
||||
};
|
||||
|
||||
function buildDataEnvelopeSchema(dataSchema, description = "OK") {
|
||||
return {
|
||||
description,
|
||||
type: "object",
|
||||
required: ["requestId", "data"],
|
||||
properties: {
|
||||
requestId: REQUEST_ID_SCHEMA,
|
||||
data: dataSchema,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function buildErrorEnvelopeSchema({
|
||||
description = "业务错误",
|
||||
codeExample = "VALID_001",
|
||||
messageExample = "参数校验失败",
|
||||
detailsExample,
|
||||
} = {}) {
|
||||
const schema = {
|
||||
description,
|
||||
type: "object",
|
||||
required: ["requestId", "error"],
|
||||
properties: {
|
||||
requestId: REQUEST_ID_SCHEMA,
|
||||
error: {
|
||||
...ERROR_BODY_SCHEMA,
|
||||
properties: {
|
||||
...ERROR_BODY_SCHEMA.properties,
|
||||
code: {
|
||||
...ERROR_BODY_SCHEMA.properties.code,
|
||||
example: codeExample,
|
||||
},
|
||||
message: {
|
||||
...ERROR_BODY_SCHEMA.properties.message,
|
||||
example: messageExample,
|
||||
},
|
||||
details: {
|
||||
...ERROR_DETAILS_SCHEMA,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
if (detailsExample !== undefined) {
|
||||
schema.properties.error.properties.details.example = detailsExample;
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
const UUID_PARAM_SCHEMA = {
|
||||
type: "object",
|
||||
required: ["id"],
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
format: "uuid",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
REQUEST_ID_SCHEMA,
|
||||
ERROR_BODY_SCHEMA,
|
||||
buildDataEnvelopeSchema,
|
||||
buildErrorEnvelopeSchema,
|
||||
UUID_PARAM_SCHEMA,
|
||||
};
|
||||
在新工单中引用
屏蔽一个用户