JSON Schema pro validaci¶
Každá specifikace musí být validovatelná proti JSON Schema:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "AutoERP Module Specification",
"type": "object",
"required": ["module", "entities"],
"properties": {
"module": {
"type": "object",
"required": ["name", "version"],
"properties": {
"name": {
"type": "string",
"pattern": "^[A-Z][a-zA-Z0-9]+$"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+$"
},
"dependencies": {
"type": "array",
"items": {"type": "string"}
}
}
},
"entities": {
"type": "object",
"patternProperties": {
"^[A-Z][a-zA-Z0-9]+$": {
"$ref": "#/definitions/entity"
}
}
}
},
"definitions": {
"entity": {
"type": "object",
"required": ["label", "fields"],
"properties": {
"label": {"type": "string"},
"type": {"enum": ["Base", "BasePlus", "Event", "Person", "Company"]},
"fields": {"type": "object"},
"links": {"type": "object"},
"layouts": {"type": "object"}
}
}
}
}
Validace¶
# Validace specifikace proti schématu
openspec validate spec.yaml --schema
# Výstup
✓ spec.yaml is valid
➡️ Pokračujte na Naming Conventions.