360 Secure SkillHub
360 安全技能中心

Json Schema Toolkit

该 Skill 基于 scripts/json_schema.py 提供 JSON Schema 校验、从样例 JSON 生成 Schema,以及将 Schema 转换为 TypeScript 接口、Python dataclass 或 Markdown 文档;支持标准输入,纯 Python 无外部依赖,可报告校验错误路径并以退出码表示失败。

johnnywang2001
johnnywang2001
热度 81.19
最近更新 2026-05-11 17:33:53
分类:开发依赖:代码执行 / 读写文件应用场景:代码生成 / 数据处理 / API 集成

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add json-schema-toolkit
Metadata
name
json-schema-toolkit
description
Validate JSON data against JSON Schema, generate schemas from sample JSON, and convert schemas to TypeScript interfaces, Python dataclasses, or Markdown docs. Use when working with JSON validation, API contract testing, schema generation from examples, or converting JSON Schema to typed code. No external dependencies — pure Python.

JSON Schema Toolkit

Validate, generate, and convert JSON Schemas with zero dependencies.

Commands

All commands use scripts/json_schema.py.

Generate Schema from Sample Data

python3 scripts/json_schema.py generate --input sample.json
python3 scripts/json_schema.py generate --input sample.json --output schema.json
echo '{"name":"Jo","age":25}' | python3 scripts/json_schema.py generate --input -

Auto-detects string formats (email, date-time, date, uri, ipv4).

Validate JSON Against Schema

python3 scripts/json_schema.py validate --schema schema.json --data data.json

Reports all validation errors with JSON paths. Exit code 1 on failure.

Convert Schema to Code

python3 scripts/json_schema.py convert --input schema.json --format typescript
python3 scripts/json_schema.py convert --input schema.json --format python-dataclass
python3 scripts/json_schema.py convert --input schema.json --format markdown --name User

Supported formats: typescript, python-dataclass, markdown.

Supported Validation Keywords

type, enum, required, properties, additionalProperties, items, minLength, maxLength, pattern, minimum, maximum, minItems, maxItems, format.

Stdin Support

Use --input - to pipe JSON from stdin for both generate and validate --data.