Messaging · AsyncAPI
NATS subject contracts.
Emits broker-facing contracts so publishers and subscribers validate against one message definition.
What it emits
Subject constantsMessage schemasInferred payload types
Options
Options this generator adds on top of its base set. Set them under generator: in the target.
| Option | Description | Values | Default |
|---|---|---|---|
prefix | Namespace prepended to every generated subject. | string, e.g. io.sumr | unset |
Example
type: asyncapi-natsgeneratesMessage payloads arrive as Zod schemas with both the parsed and input types inferred, so publishers and subscribers share one definition.
targets:
- name: api-nats
output: ./apps/api/src/contracts
generator:
type: asyncapi-nats
prefix: io.sumrimport { z } from 'zod';
export namespace OrganizationsSchema {
export const CreateOrganizationMessage = z.object({
name: z.string().min(1).max(255),
slug: z.string(),
});
export type CreateOrganizationMessage = z.infer<typeof CreateOrganizationMessage>;
export type CreateOrganizationMessageInput = z.input<typeof CreateOrganizationMessage>;
}