Validate JSON/YAML files against schemas (JSON Schema, OpenAPI, etc.)
The schema/@versions attribute uses comma-separated version tokens.
Parsers MUST split the value on commas and trim whitespace from each token.
Example: versions="3.0, 3.1" produces ["3.0", "3.1"]
Read file content
Detect file format (JSON or YAML)
Parse content into object
Return: "Syntax error: {error_message}"
Check for $schema property (JSON Schema)
Check for openapi property (OpenAPI)
Check for asyncapi property (AsyncAPI)
Set detected_type to matched schema type (if any)
HALT with error: "Unable to auto-detect schema type; provide schema_type or schema parameter"
Validate schema_type is in supported_schemas list
HALT with error: "Unsupported schema type '{schema_type}'; supported types: json-schema, openapi, asyncapi, yaml, json"
Verify {schema} file exists
HALT with error: "Schema file not found: {schema}"
Load schema from {schema} path
HALT with error: "Failed to parse schema: {error_message}"
Check if built-in meta-schema exists for {schema_type}
HALT with error: "No built-in schema available for '{schema_type}'; provide schema parameter"
Load built-in meta-schema for {schema_type}
HALT with error: "Cannot load schema: no schema provided and type could not be detected"
Run validation against schema
Collect all validation errors
Format error messages with line numbers (if possible)
HALT with error: "Cannot generate report: schema type was not determined"
HALT with error: "Cannot generate report: validation was not performed (schema not loaded)"
Return structured result:
status: "valid"
schema_type: {schema_type}
message: "Valid {schema_type} document"
Return structured result:
status: "invalid"
schema_type: {schema_type}
error_count: {error_count}
errors: {errors}
message: "Validation failed with {error_count} error(s)"