@eventcatalog/generator-openapi 7.2.0 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Service, Domain } from './types.mjs';
1
+ import { Service, Message, Domain } from './types.mjs';
2
2
  import 'openapi-types';
3
3
 
4
4
  type MESSAGE_TYPE = 'command' | 'query' | 'event';
@@ -6,6 +6,7 @@ type HTTP_METHOD = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIO
6
6
  type HTTP_METHOD_TO_MESSAGE_TYPE = Partial<Record<HTTP_METHOD, MESSAGE_TYPE>>;
7
7
  type Props = {
8
8
  services: Service[];
9
+ messages?: Message;
9
10
  domain?: Domain;
10
11
  debug?: boolean;
11
12
  saveParsedSpecFile?: boolean;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Service, Domain } from './types.js';
1
+ import { Service, Message, Domain } from './types.js';
2
2
  import 'openapi-types';
3
3
 
4
4
  type MESSAGE_TYPE = 'command' | 'query' | 'event';
@@ -6,6 +6,7 @@ type HTTP_METHOD = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIO
6
6
  type HTTP_METHOD_TO_MESSAGE_TYPE = Partial<Record<HTTP_METHOD, MESSAGE_TYPE>>;
7
7
  type Props = {
8
8
  services: Service[];
9
+ messages?: Message;
9
10
  domain?: Domain;
10
11
  debug?: boolean;
11
12
  saveParsedSpecFile?: boolean;
package/dist/index.js CHANGED
@@ -6644,6 +6644,7 @@ var buildService = (serviceOptions, document2, generateMarkdown) => {
6644
6644
  const schemaPath = import_path.default.basename(serviceOptions.path) || "openapi.yml";
6645
6645
  const documentTags = document2.tags || [];
6646
6646
  const serviceId = serviceOptions.id || (0, import_slugify.default)(document2.info.title, { lower: true, strict: true });
6647
+ const generatedMarkdownForService = defaultMarkdown2(document2, schemaPath);
6647
6648
  return {
6648
6649
  id: serviceId,
6649
6650
  version: document2.info.version,
@@ -6653,7 +6654,7 @@ var buildService = (serviceOptions, document2, generateMarkdown) => {
6653
6654
  specifications: {
6654
6655
  openapiPath: schemaPath
6655
6656
  },
6656
- markdown: generateMarkdown ? generateMarkdown(document2, schemaPath) : defaultMarkdown2(document2, schemaPath),
6657
+ markdown: generateMarkdown ? generateMarkdown({ service: serviceOptions, document: document2, markdown: generatedMarkdownForService }) : generatedMarkdownForService,
6657
6658
  badges: documentTags.map((tag) => ({ content: tag.name, textColor: "blue", backgroundColor: "blue" })),
6658
6659
  owners: serviceOptions.owners || [],
6659
6660
  setMessageOwnersToServiceOwners: serviceOptions.setMessageOwnersToServiceOwners || true
@@ -6867,7 +6868,7 @@ var getSummary2 = (message) => {
6867
6868
  }
6868
6869
  return eventCatalogMessageSummary;
6869
6870
  };
6870
- var buildMessage = async (pathToFile, document2, operation) => {
6871
+ var buildMessage = async (pathToFile, document2, operation, generateMarkdown) => {
6871
6872
  const requestBodiesAndResponses = await getSchemasByOperationId(pathToFile, operation.operationId);
6872
6873
  const extensions = operation.extensions || {};
6873
6874
  const operationTags = operation.tags.map((badge) => ({
@@ -6883,12 +6884,13 @@ var buildMessage = async (pathToFile, document2, operation) => {
6883
6884
  uniqueIdentifier = uniqueIdentifier.concat(`_${path3}`);
6884
6885
  }
6885
6886
  const httpVerb = operation.method.toUpperCase() || "";
6887
+ const generatedMarkdownForMessage = defaultMarkdown3(operation, requestBodiesAndResponses);
6886
6888
  return {
6887
6889
  id: extensions["x-eventcatalog-message-id"] || uniqueIdentifier,
6888
6890
  version: extensions["x-eventcatalog-message-version"] || document2.info.version,
6889
6891
  name: extensions["x-eventcatalog-message-name"] || uniqueIdentifier,
6890
6892
  summary: getSummary2(operation),
6891
- markdown: defaultMarkdown3(operation, requestBodiesAndResponses),
6893
+ markdown: generateMarkdown ? generateMarkdown({ operation, markdown: generatedMarkdownForMessage }) : generatedMarkdownForMessage,
6892
6894
  schemaPath: requestBodiesAndResponses?.requestBody ? "request-body.json" : "",
6893
6895
  badges,
6894
6896
  requestBodiesAndResponses,
@@ -8293,7 +8295,7 @@ var import_node_path2 = require("path");
8293
8295
  // package.json
8294
8296
  var package_default = {
8295
8297
  name: "@eventcatalog/generator-openapi",
8296
- version: "7.2.0",
8298
+ version: "7.2.1",
8297
8299
  description: "OpenAPI generator for EventCatalog",
8298
8300
  scripts: {
8299
8301
  build: "tsup",
@@ -9275,11 +9277,12 @@ Processing domain: ${domainName} (v${domainVersion})`));
9275
9277
  console.log(import_chalk3.default.cyan(` - Versioned previous domain (v${currentDomain.version})`));
9276
9278
  }
9277
9279
  if (!domain || domain && domain.version !== domainVersion) {
9280
+ const generatedMarkdownForDomain = defaultMarkdown();
9278
9281
  await writeDomain({
9279
9282
  id: domainId,
9280
9283
  name: domainName,
9281
9284
  version: domainVersion,
9282
- markdown: defaultMarkdown(),
9285
+ markdown: options.domain?.generateMarkdown ? options.domain.generateMarkdown({ domain: options.domain, markdown: generatedMarkdownForDomain }) : generatedMarkdownForDomain,
9283
9286
  ...options.domain?.owners ? { owners: options.domain.owners } : {}
9284
9287
  });
9285
9288
  console.log(import_chalk3.default.cyan(` - Domain (v${domainVersion}) created`));
@@ -9365,7 +9368,12 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document2, servicePath, o
9365
9368
  const preserveExistingMessages = options.preserveExistingMessages ?? true;
9366
9369
  let receives = [], sends = [];
9367
9370
  for (const operation of operations) {
9368
- const { requestBodiesAndResponses, sidebar, ...message } = await buildMessage(pathToSpec, document2, operation);
9371
+ const { requestBodiesAndResponses, sidebar, ...message } = await buildMessage(
9372
+ pathToSpec,
9373
+ document2,
9374
+ operation,
9375
+ options.messages?.generateMarkdown
9376
+ );
9369
9377
  let messageMarkdown = message.markdown;
9370
9378
  const messageType = operation.type;
9371
9379
  const messageAction = operation.action;