What the error means
A JSON Schema's required keyword lists the property names that an object must contain. Ajv, the validator most JavaScript tooling uses, reports a missing one as must have required property 'email', together with an instancePath that says which object is missing it — an empty path for the root object, /user/address for something nested — and a params.missingProperty field naming the key. The data is otherwise fine; it simply lacks a key the schema insists on.
In the example, the schema requires both id and email, and the data has only id. Validation fails on email at the root.
Why it happens
- The schema is stricter than the data. Often the schema was written from documentation, or generated from a complete sample, while real documents omit the key for some records.
- The key is optional in practice but was put in
requiredby default. Many schema generators mark every key seen as required. - A nested object is missing the key. The
instancePathpoints at the inner object; the fix belongs there, not at the root. - A composition keyword (
allOf,oneOf,anyOf) contributes arequiredlist you did not expect, so the key looks optional in one place and required in another. - A misspelt key in the data —
emial— which the schema correctly treats as missing.
How to fix it
- Paste the schema and data into the validator above, as one object with
schemaanddatakeys or separated by a=== DATA ===line. The report lists every failing property with its path, not just the first. - Read
instancePathandmissingPropertytogether./orders/2plusemailmeans the third order lacksemail. - Decide which side is wrong. If the key must be present, fix the data or the producer. If the key is genuinely optional, remove it from
required— leave it inpropertiesso its type is still checked when it appears. - To generate a schema whose
requiredlist reflects reality, paste several representative records into JSON to JSON Schema: a key absent from any record is left out ofrequired.
The schema that accepts the example:
{
"type": "object",
"required": ["id"],
"properties": {
"id": { "type": "integer" },
"email": { "type": "string", "format": "email" }
}
}
If it still fails
- With
allErrorsoff, Ajv stops at the first failure; the validator above reports all of them, so fix the whole list in one pass. - A
requiredentry that is not declared underpropertiesis legal and still enforced — the key must exist, whatever its type. - Pydantic's
Field required, serde'smissing field, and kotlinx'sMissingFieldExceptionare the same contract enforced at the language level; JSON Schema to TypeScript shows which properties become optional (?) from the same schema.
Related errors
must match format
Correct the value to the format's syntax (RFC 5322 email, RFC 3339 date-time, RFC 4122 uuid), or remove the format keyword if the field is not meant to be validated that strictly.
Field required
Declare the field with a default (nickname: Optional[str] = None); the generator does this for any key absent from at least one sample.