Generates an AsyncAPI 3.0 document from a set of WebSocket subscription registrations.
Each subscription becomes:
send
receive
Named schemas (those with .schemaName() set) are automatically collected and emitted as components.schemas entries with $ref pointers.
.schemaName()
components.schemas
$ref
Configuration including subscription registrations and API info.
A plain AsyncAPI 3.0 document object suitable for JSON.stringify.
JSON.stringify
import { generateAsyncApiSpec } from '@cleverbrush/server-openapi';import { server } from './server.js';const spec = generateAsyncApiSpec({ server, info: { title: 'My API', version: '1.0.0' }, servers: { production: { host: 'api.example.com', protocol: 'wss' }, },}); Copy
import { generateAsyncApiSpec } from '@cleverbrush/server-openapi';import { server } from './server.js';const spec = generateAsyncApiSpec({ server, info: { title: 'My API', version: '1.0.0' }, servers: { production: { host: 'api.example.com', protocol: 'wss' }, },});
Generates an AsyncAPI 3.0 document from a set of WebSocket subscription registrations.
Each subscription becomes:
sendoperation for server→client events and/or areceiveoperation for client→server messages.Named schemas (those with
.schemaName()set) are automatically collected and emitted ascomponents.schemasentries with$refpointers.