Skip to main content

Add schemas to messages

View as Markdown

Schemas can be added to any message type (Event, Command or Query).

Adding a schema to a message​

Add the schema file next to the message and reference it with schemaPath in the message frontmatter.

/events/InventoryAdjusted/index.mdx
---
id: InventoryAdjusted
version: 0.0.4
schemaPath: schema.avro
---

Rendering schemas​

You can render schema files inside the message page with the schema components.

/events/InventoryAdjusted/index.mdx
<!-- Raw codeblock for your schema -->
<Schema file="schema.avro" />

<!-- Richer UI experinece for your schemas -->
<SchemaViewer file="schema.avro" />

Use <Schema /> when you want to render the raw schema as a code block. Use <SchemaViewer /> when you want a richer schema viewer for supported formats.

Next steps​

Once schemas are attached to your messages, you can use the Schema Explorer, Fields Explorer, and Schema API to make them easier to find and use.