Documentation
¶
Overview ¶
Package schema serves specd's published JSON Schema document (embedded at build time via go:embed) and provides a minimal decoded view — SchemaDoc/SchemaDef — of its $defs and version ids. Full JSON Schema validation is intentionally out of scope to preserve the stdlib-only, no-validator-dependency invariant; callers use the structural definitions for conformance checks and format reporting, not generic schema enforcement.
Index ¶
Constants ¶
const DefaultSchemaVersion = SchemaVersionID
DefaultSchemaVersion is served when `specd schema` is invoked without an explicit --version.
const SchemaVersionID = "1"
SchemaVersionID is the explicit, user-visible version id of the open spec format. It is independent of the state.json SchemaVersion (which versions the on-disk migration shape); this versions the published JSON Schema contract.
Variables ¶
This section is empty.
Functions ¶
func Schema ¶
Schema returns the raw, embedded JSON Schema document for the given version. Passing "" yields DefaultSchemaVersion. Unknown versions are an error so the command surface fails closed rather than emitting an empty document.
func ValidateState ¶
ValidateState checks that a raw state.json document structurally conforms to the embedded schema of the given version ("" = default). It returns a sorted, stable list of human-readable violations (empty when conformant) and an error only when the inputs themselves are unusable (bad schema version or input that is not JSON). This is the `specd validate --schema` engine: a format check independent of the seven semantic gates.
Types ¶
type SchemaDef ¶
type SchemaDef struct {
Type string `json:"type"`
Required []string `json:"required"`
AdditionalProperties *bool `json:"additionalProperties"`
Properties map[string]json.RawMessage `json:"properties"`
}
SchemaDef is one named definition (a Go type's mirror) within the schema.
type SchemaDoc ¶
type SchemaDoc struct {
ID string `json:"$id"`
SpecdSchemaVersion string `json:"specdSchemaVersion"`
StateSchemaVersion int `json:"stateSchemaVersion"`
Defs map[string]SchemaDef `json:"$defs"`
Raw map[string]json.RawMessage `json:"-"`
}
SchemaDoc is the minimal decoded view of a JSON Schema document specd needs: its definitions and declared version ids. Full JSON Schema validation is intentionally out of scope (stdlib-only, no validator dependency); specd uses the structural definitions for conformance checks and format reporting.
func ParseSchema ¶
ParseSchema decodes an embedded schema document into a SchemaDoc.