Register a schema for an event type, and every commit of exactly that type is validated against it. Schemas are optional and immutable: a type that already has a schema answers 409 on a second registration.
curl localhost:8080/api/v2/schemas \
-H "Authorization: Bearer $GENESISDB_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "io.genesisdb.app.customer-added",
"schema": {
"type": "object",
"properties": {
"firstName": { "type": "string" },
"lastName": { "type": "string" },
"age": { "type": "integer" }
},
"required": ["firstName", "lastName"],
"additionalProperties": true
}
}'GET /api/v2/schemas lists every registered schema. Registration needs the administrator token.
Supported subset
GenesisDB validates a strict subset of JSON Schema, not a complete draft:
- Types:
string,number,integer,boolean,null,object,array. - Keywords:
type,properties,required,additionalProperties,allowAdditionalProperties,items,description,title. requiredis an array of field names, or a boolean on a single property.itemstakes one schema object.
Unsupported keywords and types are rejected at registration. $ref, formats, patterns, numeric bounds, enum and schema composition are not implemented.
Additional properties
Unlike standard JSON Schema, additional object fields are rejected by default. Allow them explicitly with additionalProperties: true or its alias allowAdditionalProperties: true.
Violations
A commit that violates its schema is rejected with 400 and nothing of the batch is written.