Generator API
Overview
API for the EventCatalog AsyncAPI generator.
Example eventcatalog.config.js file
eventcatalog.config.js
---
import path from 'path';
import url from 'url';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
/** @type {import('@eventcatalog/core/bin/eventcatalog.config').Config} */
export default {
title: 'OurLogix',
tagline: 'A comprehensive logistics and shipping management company',
organizationName: 'OurLogix',
homepageLink: 'https://eventcatalog.dev/',
landingPage: '',
editUrl: 'https://github.com/boyney123/eventcatalog-demo/edit/master',
trailingSlash: false,
base: '/',
logo: {
alt: 'EventCatalog Logo',
src: '/logo.png',
text: 'OurLogix',
},
docs: {
sidebar: {
showPageHeadings: true,
},
},
generators: [
// Add single AsyncAPI file to a domain
[
'@eventcatalog/generator-asyncapi',
{
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'orders-service.yml')}
],
domain: { id: 'orders', name: 'Orders', version: '0.0.1' },
},
],
// Add many AsyncAPI files to a domain
[
'@eventcatalog/generator-asyncapi',
{
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'payment-service.yml')}
{ path: path.join(__dirname, 'asyncapi-files', 'fraud-detection-service.yml')}
],
domain: { id: 'payment', name: 'Payment', version: '0.0.1' },
},
],
],
};
warning
When importing node modules into your eventcatalog.config.js
file, you need to import the entire package.
import path from 'path'; //work
import { join } from 'path'; // will not work
This is currently a limitation and is being looked at. Any problems or issues feel free to raise a GitHub issue.
Required fields
services
- Type:
Service[]
List of services to add, these are your AsyncAPI files.
eventcatalog.config.js
[
'@eventcatalog/generator-asyncapi',
{
// Just one AsyncAPI file
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'orders-service.yml')}
],
domain: { id: 'payment', name: 'Payment', version: '0.0.1' },
},
'@eventcatalog/generator-asyncapi',
{
// Many AsyncAPI files
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'payment-service.yml')}
{ path: path.join(__dirname, 'asyncapi-files', 'fraud-detection-service.yml')}
],
domain: { id: 'payment', name: 'Payment', version: '0.0.1' },
},
{
// Set your own id for your services
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'payment-service.yml'), id: 'paymentservice'}
{ path: path.join(__dirname, 'asyncapi-files', 'fraud-detection-service.yml'), id: 'customservice'}
],
domain: { id: 'payment', name: 'Payment', version: '0.0.1' },
},
]
Service properties
Property name | Required | Description |
---|---|---|
path | true | The path to your AsyncAPI file |
id | optional | Specify your own id for the service. This will get written to the service as the id attribute. By default the id of your service is lowercased and turned into a slug using your AsyncAPI title (in the info object) |
Optional fields
domain
The domain you want the AsyncAPI file/s to be associated with in your catalog.
eventcatalog.config.js
[
'@eventcatalog/generator-asyncapi',
{
// No domain
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'orders-service.yml')}
]
},
'@eventcatalog/generator-asyncapi',
{
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'payment-service.yml')}
{ path: path.join(__dirname, 'asyncapi-files', 'fraud-detection-service.yml')}
],
// Add to the payment domain
domain: { id: 'payment', name: 'Payment', version: '0.0.1' },
},
]
debug
Debug flag that will log extra information. For example if your AsyncAPI file fails to parse, it will tell you why.
eventcatalog.config.js
[
'@eventcatalog/generator-asyncapi',
{
// No domain
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'orders-service.yml')}
]
},
'@eventcatalog/generator-asyncapi',
{
services: [
{ path: path.join(__dirname, 'asyncapi-files', 'payment-service.yml')}
{ path: path.join(__dirname, 'asyncapi-files', 'fraud-detection-service.yml')}
],
// Add to the payment domain
domain: { id: 'payment', name: 'Payment', version: '0.0.1' },
//debug flag
debug: true
},
]