Skip to main content

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

TypeRole
IEventSchema / EventSchemaThe schema model
EventSchemaBuilderFluent API for building a schema in code
EventSchemaCreatorDerives a schema from an annotated class using reflection
IEventSchemaFactoryDI-friendly factory wrapping EventSchemaCreator
IEventSchemaWriterAbstraction for schema serialisation (JSON, YAML, AsyncAPI)
EventSchemaJsonWriterSerialises a schema to JSON
IEventSchemaValidatorValidates a CloudEvent against a schema

Pages in this section

PageDescription
Fluent BuilderBuild a schema programmatically
From AnnotationsDerive a schema from [Event]-annotated classes
Export as JSONSerialise a schema to a JSON document
Export as YAMLSerialise a schema to a YAML document
Export as AsyncAPIGenerate complete AsyncAPI 2.x documents
ValidationValidate 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 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