2. Compilation
Compiling a schema rewrites every subschema that has estype into a standard JSON Schema 2020-12 subschema that accepts the value in its ECSON form or in its plain JSON form, as described by the declared schema. A compiled schema accepts both forms in any validator that treats unknown keywords as annotations (JSON Schema Core, section 6.5), since estype stays in it (COMPILE_OUTSIDE_KEYWORDS). A strict validator such as Ajv must be configured to accept estype (for example with ajv.addKeyword("estype")).
COMPILE_REWRITE MUST
Compilation MUST replace each subschema S with estype T by a subschema with the keyword oneOf holding two subschemas, the ECSON branch (COMPILE_ECSON_BRANCH) and the plain branch (COMPILE_PLAIN_BRANCH), plus the keywords of S that stay outside (COMPILE_OUTSIDE_KEYWORDS).
COMPILE_ECSON_BRANCH MUST
The ECSON branch MUST be { "type": "object", "required": [TAG], "properties": { TAG: true }, "additionalProperties": false }, where TAG is the tag of T with its leading $.
COMPILE_PLAIN_BRANCH MUST
The plain branch MUST be an allOf of two subschemas: the declared schema without the keywords that stay outside (or, when the declared schema has no keyword other than those of COMPILE_OUTSIDE_KEYWORDS, the default plain schema of T from the table below), and the exclusion schema { "not": E }, where E is the ECSON branch.
COMPILE_NO_DEFAULT MUST
When T has no default plain schema in the table below (for example an application type) and the declared schema has no keyword other than those of COMPILE_OUTSIDE_KEYWORDS, compilation MUST fail.
Compilation MUST fail for a schema with an estype that breaks ESTYPE_KEYWORD, ESTYPE_EXCLUDED, ESTYPE_SUBSCHEMA or ESTYPE_CONFLICT.
The keywords estype, $schema, $vocabulary, $id, $anchor, $dynamicAnchor, $defs, $comment and the keywords of the Meta-Data vocabulary (JSON Schema Validation, section 9: title, description, default, deprecated, readOnly, writeOnly, examples) MUST stay outside the oneOf, in the compiled subschema.
COMPILE_IDEMPOTENT MUST
Compiling a compiled schema MUST NOT change it.
COMPILE_DETECT MUST
A subschema with estype T MUST be treated as compiled, and left as it is, when its only keywords are oneOf and keywords of COMPILE_OUTSIDE_KEYWORDS, and the oneOf holds exactly two subschemas: the first equal to the ECSON branch of T, and the second a schema whose only keyword is an allOf of a schema and { "not": E }, where E is the ECSON branch of T.
2.1 Default plain schemas
Section titled “2.1 Default plain schemas”| ES type | Default plain schema |
|---|---|
date, instant |
{ "type": "string", "format": "date-time" } |
plaindate |
{ "type": "string", "format": "date" } |
zoneddatetime, plaindatetime, plaintime, plainyearmonth, plainmonthday, duration, regexp, symbol, oid, numberDecimal |
{ "type": "string" } |
bigint |
{ "type": "integer" } |
number |
{ "type": "number" } |
set, map |
{ "type": "array" } |
bytes, binary |
{ "type": "string", "contentEncoding": "base64" } |
error |
{ "type": "object", "required": ["name", "message"] } |
timestamp |
{ "type": "object", "required": ["t", "i"] } |
rel |
{ "type": ["string", "object", "array"] } |
Source: lingodata/estype@0cbfb46 · spec/sections/02-compilation.md · estype 0.1.0 (draft)
LingoData specifications, reference implementations and this site are licensed under the Apache License 2.0. Copyright 2026 Gustavo Gondim.