Skip to content
OpenSmartRoute
Skillv1.0.0

json-schema-design

Design and validate JSON Schemas for API contracts, configuration files, and data exchange formats. Covers schema composition, conditional validation, and code generation from schemas. Triggers on JSO

by organvm-iv-taxis(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from organvm-iv-taxis/a-i--skills (skills/development/json-schema-design/SKILL.md). Install upstream with npx skills add organvm-iv-taxis/a-i--skills --skill json-schema-design. Copyright stays with the author (MIT).

JSON Schema Design

Define precise data contracts with JSON Schema for validation, documentation, and code generation.

Schema Fundamentals

Basic Types

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://organvm.dev/schemas/repo.json",
  "title": "Repository",
  "description": "An ORGANVM repository entry",
  "type": "object",
  "required": ["name", "organ", "tier", "status"],
  "properties": {
    "name": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*$",
      "minLength": 2,
      "maxLength": 64
    },
    "organ": {
      "type": "string",
      "enum": ["I", "II", "III", "IV", "V", "VI", "VII", "META"]
    },
    "tier": {
      "type": "string",
      "enum": ["flagship", "standard", "infrastructure"]
    },
    "status": {
      "type": "string",
      "enum": ["LOCAL", "CANDIDATE", "PUBLIC_PROCESS", "GRADUATED", "ARCHIVED"]
    },
    "tags": {
      "type": "array",
      "items": { "type": "string" },
      "uniqueItems": true
    }
  },
  "additionalProperties": false
}

Numeric Constraints

{
  "priority": {
    "type": "integer",
    "minimum": 1,
    "maximum": 10
  },
  "score": {
    "type": "number",
    "exclusiveMinimum": 0,
    "maximum": 1.0
  }
}

Composition

$ref (Reuse)

{
  "$defs": {
    "organ": {
      "type": "string",
      "enum": ["I", "II", "III", "IV", "V", "VI", "VII", "META"]
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    }
  },
  "properties": {
    "source_organ": { "$ref": "#/$defs/organ" },
    "target_organ": { "$ref": "#/$defs/organ" },
    "created_at": { "$ref": "#/$defs/timestamp" }
  }
}

allOf (Intersection / Extension)

{
  "allOf": [
    { "$ref": "#/$defs/base-entity" },
    {
      "properties": {
        "extra_field": { "type": "string" }
      }
    }
  ]
}

oneOf (Discriminated Union)

{
  "oneOf": [
    {
      "properties": {
        "type": { "const": "skill" },
        "category": { "type": "string" }
      },
      "required": ["type", "category"]
    },
    {
      "properties": {
        "type": { "const": "bundle" },
        "includes": { "type": "array", "items": { "type": "string" } }
      },
      "required": ["type", "includes"]
    }
  ],
  "discriminator": { "propertyName": "type" }
}

if/then/else (Conditional)

{
  "if": {
    "properties": { "tier": { "const": "flagship" } }
  },
  "then": {
    "required": ["ci_url", "docs_url"]
  }
}

Patterns for Common Needs

Extensible Enums

{
  "status": {
    "anyOf": [
      { "enum": ["active", "archived", "draft"] },
      { "type": "string", "pattern": "^x-" }
    ]
  }
}

Maps / Dictionaries

{
  "metadata": {
    "type": "object",
    "additionalProperties": { "type": "string" },
    "propertyNames": { "pattern": "^[a-z_]+$" }
  }
}

Nullable Fields

{
  "description": {
    "oneOf": [
      { "type": "string" },
      { "type": "null" }
    ]
  }
}

Validation in Python

import jsonschema
import json
from pathlib import Path

def validate_entry(data: dict, schema_path: str) -> list[str]:
    schema = json.loads(Path(schema_path).read_text())
    validator = jsonschema.Draft202012Validator(schema)
    errors = sorted(validator.iter_errors(data), key=lambda e: list(e.path))
    return [f"{'.'.join(str(p) for p in e.path)}: {e.message}" for e in errors]

Schema Evolution

Change Safe? Strategy
Add optional field Yes No version bump needed
Add required field No Major version, provide default
Remove field No Deprecate first, then remove
Widen type (string → string|number) Yes Backward compatible
Narrow type No Major version
Add enum value Yes Consumers should handle unknown
Remove enum value No Deprecate first

Anti-Patterns

  • No additionalProperties: false — Typos in field names pass silently
  • Overly permissive types — Use specific types and constraints
  • Inline definitions everywhere — Extract to $defs for reuse
  • No $id or $schema — Always specify schema version and identity
  • Validating only on write — Validate on both read and write boundaries

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/organvm-iv-taxis-a-i-skills-json-schema-design/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

organvm-iv-taxis-a-i-skills-json-schema-design.ocm.jsonjson
{
  "ocm": "1",
  "id": "organvm-iv-taxis-a-i-skills-json-schema-design",
  "kind": "skill",
  "name": "json-schema-design",
  "description": "Design and validate JSON Schemas for API contracts, configuration files, and data exchange formats. Covers schema composition, conditional validation, and code generation from schemas. Triggers on JSON Schema creation, data validation, or API contract design requests.",
  "publisher": "organvm-iv-taxis",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding",
      "legal"
    ],
    "tags": [
      "skill-md",
      "json-schema",
      "validation",
      "api-contracts",
      "data-modeling",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Design and validate JSON Schemas for API contracts, configuration files, and data exchange formats. Covers schema composition, conditional validation, and code generation from schemas. Triggers on JSON Schema creation, data validation, or API contract design requests."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/organvm-iv-taxis/a-i--skills",
      "path": "skills/development/json-schema-design/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/organvm-iv-taxis/a-i--skills/blob/HEAD/skills/development/json-schema-design/SKILL.md",
      "key": "organvm-iv-taxis/a-i--skills/skills/development/json-schema-design/SKILL.md"
    },
    "license": "MIT"
  },
  "instructions": "# JSON Schema Design\n\nDefine precise data contracts with JSON Schema for validation, documentation, and code generation.\n\n## Schema Fundamentals\n\n### Basic Types\n\n```json\n{\n  \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n  \"$id\": \"https://organvm.dev/schemas/repo.json\",\n  \"title\": \"Repository\",\n  \"description\": \"An ORGANVM repository entry\",\n  \"type\": \"object\",\n  \"required\": [\"name\", \"organ\", \"tier\", \"status\"],\n  \"properties\": {\n    \"name\": {\n      \"type\": \"string\",\n      \"pattern\": \"^[a-z][a-z0-9-]*$\",\n      \"minLength\": 2,\n      \"maxLength\": 64\n    },\n    \"organ\": {\n      \"type\"",
  "cost": {
    "context_tokens": 1079
  }
}

Fetch it by URL: GET /api/v1/registry/organvm-iv-taxis-a-i-skills-json-schema-design/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.