@done-coding/schema-api 0.0.1-alpha.1 → 0.0.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,8 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "common-error-codes.schema.json",
4
4
  "title": "CommonErrorCodes",
5
- "description": "通用失败码表:每个码固定 HTTP 状态(x-httpStatus),并给出能否重试与是否已执行的缺省值(default)。错误体引用本表:code 是通用失败码时,服务未另行指定 error.retryable 与 error.outcome 就取表中值;服务能确定更具体的重试性或执行结局时可以覆盖,任何合法的 retryable 与 outcome 都合法。$defs/code 列出全部通用失败码,须与 allOf 各项一一对应。",
5
+ "description": "通用失败码表(参考资源):每个码给出 HTTP 状态(x-httpStatus),以及能否重试与是否已执行的参考值(x-referenceValue)。本表不约束任何结构:错误体不引用它,包不替使用方填写;使用方可显式引用表中值。$defs/code 列出全部通用失败码,须与 allOf 各项一一对应。",
6
+ "x-referenceResource": true,
6
7
  "$defs": {
7
8
  "code": {
8
9
  "description": "通用失败码。",
@@ -33,8 +34,8 @@
33
34
  "properties": {
34
35
  "error": {
35
36
  "properties": {
36
- "retryable": { "default": false },
37
- "outcome": { "default": "not_executed" }
37
+ "retryable": { "x-referenceValue": false },
38
+ "outcome": { "x-referenceValue": "not_executed" }
38
39
  }
39
40
  }
40
41
  }
@@ -51,8 +52,8 @@
51
52
  "properties": {
52
53
  "error": {
53
54
  "properties": {
54
- "retryable": { "default": false },
55
- "outcome": { "default": "not_executed" }
55
+ "retryable": { "x-referenceValue": false },
56
+ "outcome": { "x-referenceValue": "not_executed" }
56
57
  }
57
58
  }
58
59
  }
@@ -69,8 +70,8 @@
69
70
  "properties": {
70
71
  "error": {
71
72
  "properties": {
72
- "retryable": { "default": false },
73
- "outcome": { "default": "not_executed" }
73
+ "retryable": { "x-referenceValue": false },
74
+ "outcome": { "x-referenceValue": "not_executed" }
74
75
  }
75
76
  }
76
77
  }
@@ -87,8 +88,8 @@
87
88
  "properties": {
88
89
  "error": {
89
90
  "properties": {
90
- "retryable": { "default": false },
91
- "outcome": { "default": "not_executed" }
91
+ "retryable": { "x-referenceValue": false },
92
+ "outcome": { "x-referenceValue": "not_executed" }
92
93
  }
93
94
  }
94
95
  }
@@ -105,8 +106,8 @@
105
106
  "properties": {
106
107
  "error": {
107
108
  "properties": {
108
- "retryable": { "default": false },
109
- "outcome": { "default": "not_executed" }
109
+ "retryable": { "x-referenceValue": false },
110
+ "outcome": { "x-referenceValue": "not_executed" }
110
111
  }
111
112
  }
112
113
  }
@@ -123,8 +124,8 @@
123
124
  "properties": {
124
125
  "error": {
125
126
  "properties": {
126
- "retryable": { "default": false },
127
- "outcome": { "default": "not_executed" }
127
+ "retryable": { "x-referenceValue": false },
128
+ "outcome": { "x-referenceValue": "not_executed" }
128
129
  }
129
130
  }
130
131
  }
@@ -141,8 +142,8 @@
141
142
  "properties": {
142
143
  "error": {
143
144
  "properties": {
144
- "retryable": { "default": false },
145
- "outcome": { "default": "not_executed" }
145
+ "retryable": { "x-referenceValue": false },
146
+ "outcome": { "x-referenceValue": "not_executed" }
146
147
  }
147
148
  }
148
149
  }
@@ -159,8 +160,8 @@
159
160
  "properties": {
160
161
  "error": {
161
162
  "properties": {
162
- "retryable": { "default": true },
163
- "outcome": { "default": "not_executed" }
163
+ "retryable": { "x-referenceValue": true },
164
+ "outcome": { "x-referenceValue": "not_executed" }
164
165
  }
165
166
  }
166
167
  }
@@ -177,8 +178,8 @@
177
178
  "properties": {
178
179
  "error": {
179
180
  "properties": {
180
- "retryable": { "default": false },
181
- "outcome": { "default": "unknown" }
181
+ "retryable": { "x-referenceValue": false },
182
+ "outcome": { "x-referenceValue": "unknown" }
182
183
  }
183
184
  }
184
185
  }
@@ -195,8 +196,8 @@
195
196
  "properties": {
196
197
  "error": {
197
198
  "properties": {
198
- "retryable": { "default": false },
199
- "outcome": { "default": "unknown" }
199
+ "retryable": { "x-referenceValue": false },
200
+ "outcome": { "x-referenceValue": "unknown" }
200
201
  }
201
202
  }
202
203
  }
@@ -213,8 +214,8 @@
213
214
  "properties": {
214
215
  "error": {
215
216
  "properties": {
216
- "retryable": { "default": true },
217
- "outcome": { "default": "unknown" }
217
+ "retryable": { "x-referenceValue": true },
218
+ "outcome": { "x-referenceValue": "unknown" }
218
219
  }
219
220
  }
220
221
  }
@@ -2,7 +2,8 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "cursor-list-request.schema.json",
4
4
  "title": "CursorListRequest",
5
- "description": "游标式列表的请求参数。线上以 cursor. 前缀的查询参数传递(如 cursor.limit=20),本定义约束解码后的对象;前缀下未声明的参数不合法。",
5
+ "description": "游标式列表的请求参数。线上以 cursor. 前缀的查询参数传递(如 cursor.limit=20),本定义约束解码后的对象;前缀下未声明的参数不合法。线上名为「前缀.字段名」。查询串里的整数参数(type 为 integer 的字段)只收整串匹配 x-queryIntegerPattern 的十进制数字串,解码成整数后再按本定义校验;\"02\"、\"+2\"、\" 2\"、\"2.0\"、\"1e1\"、空串都不合法。",
6
+ "x-queryIntegerPattern": "^(?:0|[1-9][0-9]*)$(?![\\s\\S])",
6
7
  "x-paramPrefix": "cursor",
7
8
  "x-pathConstants": "CURSOR_LIST_REQUEST_PARAMS",
8
9
  "type": "object",
@@ -14,10 +15,9 @@
14
15
  "maxLength": 1024
15
16
  },
16
17
  "limit": {
17
- "description": "本批最多取多少条;缺省值由各接口自定。",
18
+ "description": "本批最多取多少条,至少 1;不带时取多少条、上限多少由接口自己声明。",
18
19
  "type": "integer",
19
- "minimum": 1,
20
- "maximum": 100
20
+ "minimum": 1
21
21
  }
22
22
  },
23
23
  "additionalProperties": false
@@ -2,20 +2,20 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "error-body.schema.json",
4
4
  "title": "ErrorBody",
5
- "description": "错误体。HTTP 状态表达大类,包体带业务码、说明、能否重试、是否已执行与出错字段定位。code 是通用失败码时,retryable 与 outcome 的缺省值见通用失败码表,服务能确定更具体的情形时可以覆盖。",
5
+ "description": "错误体。HTTP 状态表达大类,包体带业务码、说明、能否重试、是否已执行与出错字段定位。retryable 与 outcome 由服务按实际情形填写,包不替使用方填写;通用失败码表给了一组参考值,使用方可显式引用。",
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "code": {
9
9
  "description": "业务码,开放字符串:字母开头,只含字母、数字、下划线,1–128 个字符;不能是 OK。使用方遇到不认识的码按 HTTP 状态归类处理。",
10
10
  "type": "string",
11
- "pattern": "^[A-Za-z][A-Za-z0-9_]{0,127}$",
11
+ "pattern": "^[A-Za-z][A-Za-z0-9_]{0,127}$(?![\\s\\S])",
12
12
  "not": { "const": "OK" }
13
13
  },
14
14
  "message": {
15
15
  "description": "说明,不能是纯空白。",
16
16
  "type": "string",
17
17
  "maxLength": 1000,
18
- "pattern": "\\S"
18
+ "pattern": "[^\\t\\n\\v\\f\\r \\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]"
19
19
  },
20
20
  "data": {
21
21
  "description": "错误体恒为 null。",
@@ -25,7 +25,7 @@
25
25
  "requestId": {
26
26
  "description": "请求标识,1–128 个字符,不含空白字符。",
27
27
  "type": "string",
28
- "pattern": "^\\S{1,128}$"
28
+ "pattern": "^[^\\t\\n\\v\\f\\r \\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]{1,128}$(?![\\s\\S])"
29
29
  },
30
30
  "detail": {
31
31
  "description": "补充说明,可选,不限长。",
@@ -34,7 +34,6 @@
34
34
  },
35
35
  "required": ["code", "message", "data", "error", "requestId"],
36
36
  "additionalProperties": false,
37
- "allOf": [{ "$ref": "common-error-codes.schema.json" }],
38
37
  "$defs": {
39
38
  "errorDetail": {
40
39
  "title": "ErrorDetail",
@@ -70,18 +69,18 @@
70
69
  "code": {
71
70
  "description": "字段级错误码:字母开头,只含字母、数字、下划线、点、短横线,1–128 个字符。",
72
71
  "type": "string",
73
- "pattern": "^[A-Za-z][A-Za-z0-9_.\\-]{0,127}$"
72
+ "pattern": "^[A-Za-z][A-Za-z0-9_.\\-]{0,127}$(?![\\s\\S])"
74
73
  },
75
74
  "message": {
76
75
  "description": "说明,不能是纯空白。",
77
76
  "type": "string",
78
77
  "maxLength": 1000,
79
- "pattern": "\\S"
78
+ "pattern": "[^\\t\\n\\v\\f\\r \\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]"
80
79
  },
81
80
  "pointer": {
82
81
  "description": "请求体内的位置,RFC 6901 JSON Pointer。",
83
82
  "type": "string",
84
- "pattern": "^(?:(?:/(?:[^~/]|~[01])*)*/(?:(?:[^~/]|~[01])*(?:[^~/\\n]|~[01]))?)?$"
83
+ "pattern": "^(?:(?:/(?:[^~/]|~[01])*)*/(?:(?:[^~/]|~[01])*(?:[^~/\\n]|~[01]))?)?$(?![\\s\\S])"
85
84
  },
86
85
  "parameter": {
87
86
  "description": "参数名,1–256 个字符。",
@@ -7,7 +7,7 @@
7
7
  "x-pathConstants": "LIST_FILTER_PARAMS",
8
8
  "type": "object",
9
9
  "patternProperties": {
10
- "^[a-z][a-zA-Z0-9]*$": { "$ref": "#/$defs/condition" }
10
+ "^[a-z][a-zA-Z0-9]*$(?![\\s\\S])": { "$ref": "#/$defs/condition" }
11
11
  },
12
12
  "additionalProperties": false,
13
13
  "$defs": {
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "list-reference-values.schema.json",
4
+ "title": "ListReferenceValues",
5
+ "description": "列表的参考数值(参考资源):只是参考,不约束任何结构。结构定义里页码、每页条数、每批条数都没有默认值和上限,包不替使用方填写;要用这些数值须在自己的代码里显式引用,或声明自己的值。",
6
+ "x-referenceResource": true,
7
+ "x-referenceValues": {
8
+ "PAGED_LIST_REFERENCE_VALUES": {
9
+ "description": "页码式列表的参考数值:page 是请求不带页码时可参考的页码,pageSize 是请求不带每页条数时可参考的条数,maxPageSize 是每页条数可参考的上限。",
10
+ "value": {
11
+ "page": 1,
12
+ "pageSize": 10,
13
+ "maxPageSize": 100
14
+ }
15
+ },
16
+ "CURSOR_LIST_REFERENCE_VALUES": {
17
+ "description": "游标式列表的参考数值:maxLimit 是每批条数可参考的上限。",
18
+ "value": {
19
+ "maxLimit": 100
20
+ }
21
+ }
22
+ }
23
+ }
@@ -2,23 +2,21 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "paged-list-request.schema.json",
4
4
  "title": "PagedListRequest",
5
- "description": "页码式列表的请求参数。线上以 page. 前缀的查询参数传递(如 page.pageSize=20),本定义约束解码后的对象;前缀下未声明的参数不合法。",
5
+ "description": "页码式列表的请求参数。线上以 page. 前缀的查询参数传递(如 page.pageSize=20),本定义约束解码后的对象;前缀下未声明的参数不合法。线上名为「前缀.字段名」。查询串里的整数参数(type 为 integer 的字段)只收整串匹配 x-queryIntegerPattern 的十进制数字串,解码成整数后再按本定义校验;\"02\"、\"+2\"、\" 2\"、\"2.0\"、\"1e1\"、空串都不合法。",
6
+ "x-queryIntegerPattern": "^(?:0|[1-9][0-9]*)$(?![\\s\\S])",
6
7
  "x-paramPrefix": "page",
7
8
  "x-pathConstants": "PAGED_LIST_REQUEST_PARAMS",
8
9
  "type": "object",
9
10
  "properties": {
10
11
  "page": {
11
- "description": "页码,从 1 开始。",
12
+ "description": "页码,从 1 开始;不带时的含义由接口自己声明。",
12
13
  "type": "integer",
13
- "minimum": 1,
14
- "default": 1
14
+ "minimum": 1
15
15
  },
16
16
  "pageSize": {
17
- "description": "每页条数。",
17
+ "description": "每页条数,至少 1;不带时的含义与上限由接口自己声明。",
18
18
  "type": "integer",
19
- "minimum": 1,
20
- "maximum": 100,
21
- "default": 10
19
+ "minimum": 1
22
20
  },
23
21
  "query": {
24
22
  "description": "模糊搜索词,最多 200 个字符。",
@@ -29,7 +27,7 @@
29
27
  "description": "排序:逗号分隔,每段是小驼峰字段名,后面可跟一个空格加 asc 或 desc(缺省 asc);逗号后可有一个空格;最多 200 个字符。",
30
28
  "type": "string",
31
29
  "maxLength": 200,
32
- "pattern": "^[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?(?:, ?[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?)*$"
30
+ "pattern": "^[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?(?:, ?[a-z][a-zA-Z0-9]*(?: (?:asc|desc))?)*$(?![\\s\\S])"
33
31
  }
34
32
  },
35
33
  "additionalProperties": false
@@ -27,10 +27,9 @@
27
27
  "minimum": 0
28
28
  },
29
29
  "pageSize": {
30
- "description": "每页条数,回显请求值。",
30
+ "description": "每页条数,回显请求值,至少 1。",
31
31
  "type": "integer",
32
- "minimum": 1,
33
- "maximum": 100
32
+ "minimum": 1
34
33
  },
35
34
  "totalPage": {
36
35
  "description": "总页数。",
@@ -2,13 +2,13 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "service-error-codes.schema.json",
4
4
  "title": "ServiceErrorCodes",
5
- "description": "一个服务的专有业务码清单。不得重新定义通用码;OK 与 HTTP_<数字> 形式的码保留,不得使用;比较按字节精确进行,不做大小写归一。",
5
+ "description": "一个服务的专有业务码清单。OK 与 HTTP_<数字> 形式的码是结构保留字,不得使用;比较按字节精确进行,不做大小写归一。专有码是否要避开某组通用码由使用方显式检查:把那组码传给参考资源出口的检查函数,不传就不比。",
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "service": {
9
9
  "description": "服务标识:小写字母开头,只含小写字母、数字、短横线,最长 64 个字符。",
10
10
  "type": "string",
11
- "pattern": "^[a-z][a-z0-9\\-]{0,63}$"
11
+ "pattern": "^[a-z][a-z0-9\\-]{0,63}$(?![\\s\\S])"
12
12
  },
13
13
  "codes": {
14
14
  "description": "专有码,至少 1 项;code 在清单内不重复(x-uniqueItemsBy)。",
@@ -30,11 +30,15 @@
30
30
  "description": "码:整体大写下划线或整体小写下划线写法,字母开头,不以下划线结尾,不含连续下划线,最长 128 个字符。",
31
31
  "type": "string",
32
32
  "maxLength": 128,
33
- "pattern": "^(?:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*)$",
33
+ "pattern": "^(?:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*)$(?![\\s\\S])",
34
34
  "allOf": [
35
35
  { "not": { "const": "OK" } },
36
- { "not": { "type": "string", "pattern": "^HTTP_[0-9]+$" } },
37
- { "not": { "$ref": "common-error-codes.schema.json#/$defs/code" } }
36
+ {
37
+ "not": {
38
+ "type": "string",
39
+ "pattern": "^HTTP_[0-9]+$(?![\\s\\S])"
40
+ }
41
+ }
38
42
  ]
39
43
  },
40
44
  "stage": {