Skip to main content
View as Markdown

Function: getSchemaForMessage()

getSchemaForMessage(directory): (id, version?) => Promise<{ fileName: string; schema: string; }>

Defined in: messages.ts:194

Returns the schema for a given message (event, command or query) by its id and version.

If no version is given, the latest version is used.

Parameters

ParameterType
directorystring

Returns

Function

Parameters

ParameterType
idstring
version?string

Returns

Promise<{ fileName: string; schema: string; }>

Example

import utils from '@eventcatalog/utils';

const { getSchemaForMessage } = utils('/path/to/eventcatalog');

// Get the schema for the latest version of the message
const schema = await getSchemaForMessage('InventoryAdjusted');

// Get the schema for a specific version
const schema = await getSchemaForMessage('InventoryAdjusted', '0.0.1');