Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): added message description to markdown contents #42

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-worms-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eventcatalog/generator-openapi": patch
---

fix(core): added message description to markdown contents
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dependencies": {
"@apidevtools/swagger-parser": "^10.1.0",
"@changesets/cli": "^2.27.7",
"@eventcatalog/sdk": "^1.1.3",
"@eventcatalog/sdk": "^1.4.1",
"chalk": "^4",
"js-yaml": "^4.1.0",
"openapi-types": "^12.1.3",
Expand Down
28 changes: 13 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export default async (_: any, options: Props) => {
addServiceToDomain,
getService,
versionService,
rmServiceById,
writeService,
addFileToService,
getSpecificationFilesForService,
Expand Down Expand Up @@ -119,7 +118,6 @@ export default async (_: any, options: Props) => {
// Match found, override it
if (latestServiceInCatalog.version === version) {
receives = latestServiceInCatalog.receives ? [...latestServiceInCatalog.receives, ...receives] : receives;
await rmServiceById(service.id);
}
}

Expand All @@ -131,7 +129,7 @@ export default async (_: any, options: Props) => {
sends,
receives,
},
{ path: service.id }
{ path: service.id, override: true }
);

// What files need added to the service (speficiation files)
Expand Down Expand Up @@ -176,7 +174,7 @@ const processMessagesForOpenAPISpec = async (pathToSpec: string, document: OpenA

console.log(chalk.blue(`Processing message: ${message.name} (v${version})`));

const { addFileToMessage, writeMessage, rmMessageById, getMessage, versionMessage } = getMessageTypeUtils(
const { addFileToMessage, writeMessage, getMessage, versionMessage } = getMessageTypeUtils(
process.env.PROJECT_DIR as string,
messageType
);
Expand All @@ -187,17 +185,15 @@ const processMessagesForOpenAPISpec = async (pathToSpec: string, document: OpenA
if (catalogedMessage) {
messageMarkdown = catalogedMessage.markdown;
// if the version matches, we can override the message but keep markdown as it was
if (catalogedMessage.version === version) {
await rmMessageById(message.id, version);
} else {
if (catalogedMessage.version !== version) {
// if the version does not match, we need to version the message
await versionMessage(message.id);
console.log(chalk.cyan(` - Versioned previous message: (v${catalogedMessage.version})`));
}
}

// Write the message to the catalog
await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.name });
await writeMessage({ ...message, markdown: messageMarkdown }, { path: message.name, override: true });

// If the message send or recieved by the service?
if (messageAction === 'sends') {
Expand Down
9 changes: 9 additions & 0 deletions src/utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ export const defaultMarkdown = (message: Operation, openAPIOperation: OpenAPIOpe
## Architecture
<NodeGraph />

${
message.description
? `
## Overview
${message.description}
`
: ''
}

${
message.externalDocs
? `
Expand Down