Skip to content

JSON Schema for Validation

Each specification must be validated against a 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"}
      }
    }
  }
}

Validation

# Validate spec against schema
openspec validate spec.yaml --schema

# Output
 spec.yaml is valid

➡️ Continue with Naming Conventions.