Strict mode
A schema can be valid JSON Schema and still be a mistake. Validators ignore these, so the schema silently accepts more, or less, than it appears to. Strict mode (the default) fails on them with a GeneverStrictModeError, whose pointer names the schema at fault, rather than generating a type that hides the problem.
Keywords that do nothing
- An unknown keyword, such as a misspelled
maxLenght. Keywords starting withx-are allowed, as are OpenAPI's keywords in an OpenAPI document or withopenApi30. - A type specific keyword in a schema without a
type, or whosetypeit doesn't apply to, such asmaxLengthon a number. Subschemas ofallOf,anyOf,oneOf,if/then/elseandnotinherit their parent's type. - A
requiredproperty that isn't inproperties, of the schema or a parent. thenorelsewithoutif.- A
discriminatorwhose property isn't required, by the schema or by everyoneOf/anyOfbranch, or whosemappingnames a schema that doesn't exist. Its values aren't checked, as OpenAPI may take them from component names.
Schemas that accept nothing, or less than they declare
minLengthgreater thanmaxLength, and the same forminItems/maxItems,minProperties/maxPropertiesandminContains/maxContains.minimum/exclusiveMinimumandmaximum/exclusiveMaximumthat no number fits between, or no integer fortype: "integer".- An
enumorconstvalue that isn't of the schema'stype. - A
requiredproperty whose schema is never valid (such asfalse), or more required properties thanmaxPropertiesallows. minPropertiesmore than an object withadditionalProperties: falsecan have.- A tuple (
prefixItemswithitems: false) shorter thanminItems, or longer thanmaxItems. - A
$refback to a schema it is part of, without a property or item in between, such as{ "anyOf": [{ "$ref": "#" }, { "type": "string" }] }. It applies to the same value again, so a validator never finishes checking it, and JSON Schema leaves its behaviour undefined.
Every schema Juniper builds passes.
Without strict mode
For schemas you don't control, disable strict mode with --no-strict (or strict: false). The type then follows what a validator accepts, and is never narrower:
- Unknown keywords, and keywords that don't apply to the type, are ignored, as validators ignore them.
- A schema without a
typeaccepts every type.{ "properties": { "a": … } }is the object, or any string, number, boolean,nullor array. - A type whose constraints contradict each other is
never. For{ "type": ["string", "null"], "minLength": 3, "maxLength": 2 }, onlynullis valid. - Tuple items beyond
maxItemsare left out. - A
$refback to a schema it is part of, without a property or item in between, isnever: it can't be why a value is valid. TheanyOfabove isstring. A schema it passes through on the way back is inlined, as TypeScript rejects a type that refers to itself outside an object or array.
Some features are unsupported in either mode, as ignoring them would loosen the type: $dynamicRef and $recursiveRef throw a GeneverUnsupportedError.