Source code for vibesketch.document.schema
"""The JSON schema of the document, generated from the model.
``schema/vibe-sketch-1.schema.json`` is this function's output, committed so
that clients outside Python (the browser shell, other programs) can validate
a ``.vsk`` without the package. ``vibe-sketch schema --output`` regenerates
it; ``tests/test_document_schema.py`` fails when the two drift apart.
"""
from __future__ import annotations
from typing import Any
from vibesketch.document.model import Document
#: Where the schema is published once the documentation site is.
SCHEMA_URI = "https://vibe-qc.com/vibe-sketch/schema/vibe-sketch-1.schema.json"
#: The committed file, relative to the repository root.
SCHEMA_FILE = "schema/vibe-sketch-1.schema.json"
[docs]
def document_json_schema() -> dict[str, Any]:
"""The JSON schema (draft 2020-12) of a version-1 document."""
body = Document.model_json_schema(by_alias=True, mode="validation")
return {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": SCHEMA_URI,
**body,
}