Skip to content

Add JSON Schema validation of parsed JSON#265

Merged
JE-Chen merged 1 commit into
devfrom
feat/json-schema-validator
Jun 20, 2026
Merged

Add JSON Schema validation of parsed JSON#265
JE-Chen merged 1 commit into
devfrom
feat/json-schema-validator

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

The framework only ever generated JSON Schema (action-lint, tool-use schema), and data_quality.validate_rows is a flat, per-column table checker — neither could validate a nested API request/response body against a real schema. This adds the missing consumer: a pure-stdlib JSON Schema (Draft 2020-12 subset) validator.

  • validate_json(instance, schema) -> SchemaValidationResult — collects every violation as {path, keyword, message} (e.g. $.age maximum, $.extra additionalProperties).
  • is_valid(...) boolean shortcut; assert_schema(...) raises AutoControlAssertionException with a joined summary.
  • Keywords: type (incl. integer matching integral floats but never bools), enum/const (keeps True/1 distinct), numeric & string bounds, array keywords (items/prefixItems/contains/uniqueItems/size), object keywords (required/properties/patternProperties/additionalProperties/size), combinators (allOf/anyOf/oneOf/not), boolean schemas, and local $ref (#/$defs/...). Remote $ref and format are out of scope.

Pure standard library (re); imports no PySide6. Pairs with the existing json_query and http_request helpers.

Five-layer wiring

  • Headless core: je_auto_control/utils/json_schema/
  • Facade: re-exported from je_auto_control/__init__.py + __all__
  • Executor: AC_validate_json
  • MCP: ac_validate_json
  • Script Builder: "JSON Schema: Validate" under Data

Tests & docs

  • test/unit_test/headless/test_json_schema_batch.py (16 tests, all green; full headless suite passes)
  • v57 feature docs (EN + Zh) + toctree registration
  • What's-new sections in all three READMEs

Lint clean: ruff / pylint / bandit / radon (no function CC > 10).

The framework only generated JSON Schema and data_quality is a flat
per-column checker, so nested API request/response bodies could not be
validated. Add a Draft 2020-12 subset validator that reports every
violation with a readable path, wired through the facade, AC_validate_json
executor command, ac_validate_json MCP tool and the Script Builder.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 143 complexity · 0 duplication

Metric Results
Complexity 143
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 9074652 into dev Jun 20, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/json-schema-validator branch June 20, 2026 16:43
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant