feat: P3 JSON Schema support — not, contains, propertyNames, metadata (#82) #88

Merged
xingyue merged 1 commits from feat/82-schema-p3 into main 2026-06-01 02:34:08 +00:00
Owner

What

#82 Phase 3(最终阶段):新增 8 个 JSON Schema 关键字。

Changes

分类 关键字 collectRefs
组合 not 遍历子 schema
数组 contains 遍历匹配项
对象 propertyNames — 约束 key 名
元数据 examples
元数据 readOnly
元数据 writeOnly
元数据 deprecated
元数据 $comment

改动文件

  • schema.ts — 白名单 +8, isValidSchema() +8, collectRefs() +2 (not/contains)
  • bootstrap.ts — meta-schema +8 properties
  • schema.test.ts — 7 个新测试
  • schema-validation.test.ts — meta-schema 结构断言更新

collectRefs 修复

contains 必须在 array 分支内处理(array 分支有 early return),不能放在外面。

完成度

已支持 40 个关键字,覆盖 JSON Schema Draft 2020-12 常用子集。
$ref/$defs/$id/$schema 未支持(P4,复杂度高,暂缓)。

Test

516 pass, 0 fail, build + lint clean

Ref

Closes #82

## What #82 Phase 3(最终阶段):新增 8 个 JSON Schema 关键字。 ## Changes | 分类 | 关键字 | collectRefs | |------|--------|:-----------:| | 组合 | `not` | ✅ 遍历子 schema | | 数组 | `contains` | ✅ 遍历匹配项 | | 对象 | `propertyNames` | — 约束 key 名 | | 元数据 | `examples` | — | | 元数据 | `readOnly` | — | | 元数据 | `writeOnly` | — | | 元数据 | `deprecated` | — | | 元数据 | `$comment` | — | ### 改动文件 - `schema.ts` — 白名单 +8, `isValidSchema()` +8, `collectRefs()` +2 (not/contains) - `bootstrap.ts` — meta-schema +8 properties - `schema.test.ts` — 7 个新测试 - `schema-validation.test.ts` — meta-schema 结构断言更新 ### collectRefs 修复 `contains` 必须在 array 分支内处理(array 分支有 early return),不能放在外面。 ## 完成度 **已支持 40 个关键字**,覆盖 JSON Schema Draft 2020-12 常用子集。 仅 `$ref`/`$defs`/`$id`/`$schema` 未支持(P4,复杂度高,暂缓)。 ## Test 516 pass, 0 fail, build + lint clean ## Ref Closes #82
xiaoju added 1 commit 2026-06-01 02:32:20 +00:00
Add 8 new schema keywords:

Combinators (with collectRefs support):
- not: negation schema
- contains: array must contain matching item

Constraints:
- propertyNames: constrain object key names

Metadata (no collectRefs impact):
- examples, readOnly, writeOnly, deprecated, $comment

Total supported keywords: 40 (of ~45 commonly used).
Only $ref/$defs/$id/$schema remain unsupported (P4, deferred).

516 tests, 0 fail.

Closes #82
xingyue merged commit 0d09e3cb80 into main 2026-06-01 02:34:08 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#88