-
Notifications
You must be signed in to change notification settings - Fork 0
Schema Reference
LoSkroefie edited this page Jan 21, 2025
·
1 revision
This document provides detailed information about the JSON schemas used in FlexonCLI.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["prompt", "metadata"],
"properties": {
"prompt": {
"type": "string",
"minLength": 1,
"maxLength": 32768
},
"metadata": {
"type": "object",
"required": ["model", "timestamp", "version"],
"properties": {
"model": {
"type": "string",
"minLength": 1
},
"timestamp": {
"type": "string",
"format": "date-time"
},
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+$"
}
}
}
}
}{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["dataset", "metadata"],
"properties": {
"dataset": {
"type": "array",
"items": {
"type": "object",
"required": ["input", "output", "metadata"],
"properties": {
"input": {
"type": "string",
"minLength": 1
},
"output": {
"type": "string",
"minLength": 1
},
"metadata": {
"type": "object",
"required": ["timestamp", "source"],
"properties": {
"timestamp": {
"type": "string",
"format": "date-time"
},
"source": {
"type": "string"
}
}
}
}
}
}
}
}{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["gameState", "metadata"],
"properties": {
"gameState": {
"type": "object",
"required": ["player", "world", "inventory"],
"properties": {
"player": {
"type": "object",
"required": ["position", "stats"],
"properties": {
"position": {
"type": "object",
"required": ["x", "y", "z"],
"properties": {
"x": { "type": "number" },
"y": { "type": "number" },
"z": { "type": "number" }
}
},
"stats": {
"type": "object",
"required": ["health", "level"],
"properties": {
"health": {
"type": "number",
"minimum": 0,
"maximum": 100
},
"level": {
"type": "integer",
"minimum": 1
}
}
}
}
}
}
}
}
}# Validate against schema
flexon-cli validate data.flexon schema.json
# Serialize with schema validation
flexon-cli serialize -i data.json -o output.flexon -s schema.json# Generate schema from example
flexon-cli schema-gen -i example.json -o schema.json
# Create schema with defaults
flexon-cli schema-create -t prompt -o prompt_schema.json{
"type": "object",
"properties": {
"vector": {
"type": "array",
"items": {
"type": "number"
},
"minItems": 1
}
}
}{
"type": "object",
"properties": {
"binary": {
"type": "string",
"contentEncoding": "base64"
}
}
}-
Version Control
- Include schema version
- Document changes
- Maintain compatibility
-
Validation
- Use strict types
- Set appropriate limits
- Include required fields
-
Documentation
- Comment schemas
- Provide examples
- List dependencies
-
Performance
- Optimize schema size
- Use appropriate types
- Consider validation cost
{
"type": "object",
"properties": {
"metadata": {
"type": "object",
"required": ["version", "timestamp"],
"properties": {
"version": {
"type": "string",
"pattern": "^\\d+\\.\\d+\\.\\d+$"
},
"timestamp": {
"type": "string",
"format": "date-time"
}
}
}
}
}{
"type": "object",
"properties": {
"security": {
"type": "object",
"required": ["fingerprint", "auditTrail"],
"properties": {
"fingerprint": {
"type": "string"
},
"auditTrail": {
"type": "array",
"items": {
"type": "object",
"required": ["timestamp", "action"],
"properties": {
"timestamp": {
"type": "string",
"format": "date-time"
},
"action": {
"type": "string"
}
}
}
}
}
}
}
}Common validation errors and their solutions:
- Required Field Missing
{
"error": "required property missing: metadata",
"path": "$.metadata",
"schemaPath": "#/required/1"
}- Type Mismatch
{
"error": "expected number, got string",
"path": "$.value",
"schemaPath": "#/properties/value/type"
}- Pattern Mismatch
{
"error": "string does not match pattern",
"path": "$.version",
"schemaPath": "#/properties/version/pattern"
}-
Documentation
-
Tools
- Schema validators
- Schema generators
- Documentation tools
-
Examples
- Schema patterns
- Validation cases
- Error handling