Schema Validation
Provide a JSON Schema and Shim will validate and coerce types during repair.Why Use Schemas
Without a schema, Shim only fixes syntax (brackets, commas, markdown fences). With a schema, Shim also:- Coerces types (
"30"→30) - Detects missing required fields
- Removes extra fields (strict mode)
- Validates nested objects
Basic Schema
Type Coercion
Shim coerces types when safe:| From | To | Example |
|---|---|---|
"30" | 30 | String to number |
"true" | true | String to boolean |
30 | "30" | Number to string |
true | "true" | Boolean to string |
"abc"→number(not a valid number)"maybe"→boolean(not"true"or"false")
Required Fields
Mark fields as required:Strict vs Lenient Mode
Strict Mode (default)
Removes extra fields not in schema:Lenient Mode
Keeps extra fields:Nested Objects
Validate nested structures:Arrays
Validate array items:Enums
Restrict values to specific options:Default Values
Shim does NOT add default values. If a field is missing and not required, it stays missing. Use your application logic to add defaults after repair.Schema Repairs in Metadata
All schema repairs are logged:Best Practices
- Start with lenient mode during development
- Switch to strict mode in production (prevents data leakage)
- Mark critical fields as required
- Use enums for status fields
- Review
metadata.schema_repairsif confidence is"medium"or"low"
Next Steps
Batch Endpoint
API reference for batch repair
Response Object
Full response schema
Error Handling
Handle validation failures
TypeScript SDK
Use the official SDK
