event-schema-missing
The request leaves out the schema to register.
- Route:
register-event-schema - Description:
event schema is missing: expected a JSON schema with type 'object' - Details: None;
detailsis an empty object.
Why It Happens#
Registering a schema takes the event type in type and the JSON Schema in schema, and the request leaves out schema, for example because the client code had no schema at hand: in JavaScript, JSON.stringify leaves out a field whose value is undefined. A schema that is null or not a JSON object is rejected with 400 Bad Request instead, since the body then does not have the shape the route expects.
The event type is checked first, so a request that lacks both is reported as event-type-missing.
How to Fix It#
Send the schema in schema, as a JSON Schema with "type": "object" at its top level. Sending the same request again fails the same way, since the error depends on the request alone.
Example#
To register a schema for io.eventsourcingdb.library.book-acquired with a request that leaves out schema, EventSourcingDB answers with this error, as a line of the stream, and then ends the stream with its end item:
{
"type": "error",
"data": {
"code": "https://docs.eventsourcingdb.io/errors/event-schema-missing",
"description": "event schema is missing: expected a JSON schema with type 'object'",
"details": {}
}
}