Event Schema
The Hermodr.Schema package adds the ability to formally describe the structure of your events — what properties they carry, their types, and constraints — and to validate CloudEvent instances against those descriptions before publishing.
Installation
dotnet add package Hermodr.Schema
What's included
| Type | Role |
|---|---|
IEventSchema / EventSchema | The schema model |
EventSchemaBuilder | Fluent API for building a schema in code |
EventSchemaCreator | Derives a schema from an annotated class using reflection |
IEventSchemaFactory | DI-friendly factory wrapping EventSchemaCreator |
IEventSchemaWriter | Abstraction for schema serialisation (JSON, YAML, AsyncAPI) |
EventSchemaJsonWriter | Serialises a schema to JSON |
IEventSchemaValidator | Validates a CloudEvent against a schema |
Pages in this section
| Page | Description |
|---|---|
| Fluent Builder | Build a schema programmatically |
| From Annotations | Derive a schema from [Event]-annotated classes |
| Export as JSON | Serialise a schema to a JSON document |
| Export as YAML | Serialise a schema to a YAML document |
| Export as AsyncAPI | Generate complete AsyncAPI 2.x documents |
| Validation | Validate CloudEvent instances against a schema |
Schema model at a glance
An IEventSchema carries:
Type— the event type string (e.g."order.placed")Version— the SemVer version of the schemaContentType— MIME type of the event dataDescription— human-readable descriptionProperties— a collection ofIEventPropertyentries, each with:Name,DataType,Description- Constraints:
Required,Nullable,Range<T>,Enum