Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 2.13 KB

File metadata and controls

48 lines (37 loc) · 2.13 KB

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
Validation at Publish Time Automatic schema validation via middleware
Compatibility Compare schema versions and detect breaking changes
Upcasting Migrate legacy event payloads to newer schema versions

Schema model at a glance

An IEventSchema carries:

  • Type — the event type string (e.g. "order.placed")
  • Version — the SemVer version of the schema
  • ContentType — MIME type of the event data
  • Description — human-readable description
  • Properties — a collection of IEventProperty entries, each with:
    • Name, DataType, Description
    • Constraints: Required, Nullable, Range<T>, Enum