fix: CLI put @schema uses putSchema() for recursive validation (#82) #86

Merged
xingyue merged 1 commits from fix/82-meta-schema-nested-validation into main 2026-06-01 01:39:49 +00:00
Owner

What

修复 CLI ucas put @schema 无法存入带类型约束的嵌套 schema 的问题。

Why

meta-schema 的 properties 子项定义为 { type: "object", additionalProperties: false } 且没有声明 properties,导致 ajv 验证拒绝所有带 key 的子对象(包括合法的 {"type":"string","minLength":1})。

isValidSchema() 是正确的递归实现,但 CLI 的 cmdPut 走的是通用 ajv 路径。

Changes

  • cli-json-cas/src/index.tscmdPut 检测到目标为 meta-schema 时,走 putSchema() 路径(使用 isValidSchema() 递归验证),而非 ajv
  • cli-json-cas/src/cli.test.ts — 新增 E2E 测试:ucas put @schema 存入含 minLength/maximum/uniqueItems 等嵌套约束的 schema

Test

494 pass, 0 fail, build + lint clean

Ref

Refs #82

## What 修复 CLI `ucas put @schema` 无法存入带类型约束的嵌套 schema 的问题。 ## Why meta-schema 的 `properties` 子项定义为 `{ type: "object", additionalProperties: false }` 且没有声明 `properties`,导致 ajv 验证拒绝所有带 key 的子对象(包括合法的 `{"type":"string","minLength":1}`)。 `isValidSchema()` 是正确的递归实现,但 CLI 的 `cmdPut` 走的是通用 ajv 路径。 ## Changes - `cli-json-cas/src/index.ts` — `cmdPut` 检测到目标为 meta-schema 时,走 `putSchema()` 路径(使用 `isValidSchema()` 递归验证),而非 ajv - `cli-json-cas/src/cli.test.ts` — 新增 E2E 测试:`ucas put @schema` 存入含 `minLength`/`maximum`/`uniqueItems` 等嵌套约束的 schema ## Test 494 pass, 0 fail, build + lint clean ## Ref Refs #82
xiaoju added 1 commit 2026-06-01 01:35:55 +00:00
CLI 'ucas put @schema' now detects meta-schema target and routes
through putSchema() which uses isValidSchema() — a proper recursive
validator — instead of ajv against the meta-schema (which cannot
express recursive constraints for nested property sub-schemas).

This fixes the core issue where schemas with typed properties like
{"type":"string","minLength":1} were rejected by the CLI path.

Added CLI E2E test: put @schema with nested constraints (minLength,
maximum, uniqueItems).

494 tests, 0 fail.

Refs #82
xingyue merged commit b7fc03fa16 into main 2026-06-01 01:39:49 +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#86