@eventcatalog/generator-openapi 7.5.5 → 7.6.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.js +28 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -15
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1570,7 +1570,7 @@ var buildService = (serviceOptions, document2, generateMarkdown) => {
|
|
|
1570
1570
|
const generatedMarkdownForService = defaultMarkdown2(document2, schemaPath);
|
|
1571
1571
|
return {
|
|
1572
1572
|
id: serviceId,
|
|
1573
|
-
version: document2.info.version,
|
|
1573
|
+
version: serviceOptions.version || document2.info.version,
|
|
1574
1574
|
name: document2.info.title,
|
|
1575
1575
|
summary: getSummary(document2),
|
|
1576
1576
|
schemaPath,
|
|
@@ -1809,7 +1809,7 @@ var getSummary2 = (message2) => {
|
|
|
1809
1809
|
}
|
|
1810
1810
|
return escapeSpecialCharactersThatBreakMarkdown(eventCatalogMessageSummary);
|
|
1811
1811
|
};
|
|
1812
|
-
var buildMessage = async (pathToFile, document2, operation, generateMarkdown, messageIdConfig, serviceId) => {
|
|
1812
|
+
var buildMessage = async (pathToFile, document2, operation, generateMarkdown, messageIdConfig, serviceId, serviceVersion) => {
|
|
1813
1813
|
const requestBodiesAndResponses = await getSchemasByOperationId(pathToFile, operation.operationId);
|
|
1814
1814
|
const extensions = operation.extensions || {};
|
|
1815
1815
|
const operationTags = operation.tags.map((badge) => ({
|
|
@@ -1831,13 +1831,14 @@ var buildMessage = async (pathToFile, document2, operation, generateMarkdown, me
|
|
|
1831
1831
|
uniqueIdentifier = [messageIdConfig.prefix, uniqueIdentifier].join(separator);
|
|
1832
1832
|
}
|
|
1833
1833
|
const messageName = extensions["x-eventcatalog-message-id"] || uniqueIdentifier;
|
|
1834
|
+
const messageVersion = extensions["x-eventcatalog-message-version"] || serviceVersion || document2.info.version;
|
|
1834
1835
|
if (messageIdConfig?.prefixWithServiceId) {
|
|
1835
1836
|
const separator = messageIdConfig.separator || "-";
|
|
1836
1837
|
uniqueIdentifier = [serviceId, uniqueIdentifier].join(separator);
|
|
1837
1838
|
}
|
|
1838
1839
|
return {
|
|
1839
1840
|
id: extensions["x-eventcatalog-message-id"] || uniqueIdentifier,
|
|
1840
|
-
version:
|
|
1841
|
+
version: messageVersion,
|
|
1841
1842
|
name: extensions["x-eventcatalog-message-name"] || messageName,
|
|
1842
1843
|
summary: getSummary2(operation),
|
|
1843
1844
|
markdown: generateMarkdown ? generateMarkdown({ operation, markdown: generatedMarkdownForMessage }) : generatedMarkdownForMessage,
|
|
@@ -4066,7 +4067,7 @@ import { join } from "path";
|
|
|
4066
4067
|
// package.json
|
|
4067
4068
|
var package_default = {
|
|
4068
4069
|
name: "@eventcatalog/generator-openapi",
|
|
4069
|
-
version: "7.
|
|
4070
|
+
version: "7.6.1",
|
|
4070
4071
|
description: "OpenAPI generator for EventCatalog",
|
|
4071
4072
|
scripts: {
|
|
4072
4073
|
build: "tsup",
|
|
@@ -4103,7 +4104,7 @@ var package_default = {
|
|
|
4103
4104
|
dependencies: {
|
|
4104
4105
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
4105
4106
|
"@changesets/cli": "^2.27.7",
|
|
4106
|
-
"@eventcatalog/sdk": "^2.
|
|
4107
|
+
"@eventcatalog/sdk": "^2.9.2",
|
|
4107
4108
|
chalk: "4.1.2",
|
|
4108
4109
|
"js-yaml": "^4.1.0",
|
|
4109
4110
|
"openapi-types": "^12.1.3",
|
|
@@ -4201,7 +4202,8 @@ var index_default = async (_, options) => {
|
|
|
4201
4202
|
const document2 = await SwaggerParser2.dereference(specFile);
|
|
4202
4203
|
return {
|
|
4203
4204
|
document: document2,
|
|
4204
|
-
path: specFile
|
|
4205
|
+
path: specFile,
|
|
4206
|
+
version: serviceSpec.version || document2.info.version
|
|
4205
4207
|
};
|
|
4206
4208
|
} catch (error) {
|
|
4207
4209
|
console.error(chalk4.red(`Failed to parse OpenAPI file: ${specFile}`));
|
|
@@ -4212,15 +4214,19 @@ var index_default = async (_, options) => {
|
|
|
4212
4214
|
const validSpecs = await Promise.all(specs);
|
|
4213
4215
|
const validSpecFiles = validSpecs.filter((v) => v !== null);
|
|
4214
4216
|
const orderedSpecs = validSpecFiles.sort((a, b) => {
|
|
4215
|
-
const versionA = a?.
|
|
4216
|
-
const versionB = b?.
|
|
4217
|
+
const versionA = a?.version ?? "";
|
|
4218
|
+
const versionB = b?.version ?? "";
|
|
4217
4219
|
return versionA.localeCompare(versionB);
|
|
4218
4220
|
});
|
|
4219
4221
|
for (const specification of orderedSpecs) {
|
|
4220
4222
|
const document2 = specification.document;
|
|
4221
|
-
const version =
|
|
4223
|
+
const version = specification.version;
|
|
4222
4224
|
const specPath = specification.path;
|
|
4223
|
-
const service = buildService(
|
|
4225
|
+
const service = buildService(
|
|
4226
|
+
{ ...serviceSpec, path: specPath, version: specification.version },
|
|
4227
|
+
document2,
|
|
4228
|
+
serviceSpec.generateMarkdown
|
|
4229
|
+
);
|
|
4224
4230
|
let serviceMarkdown = service.markdown;
|
|
4225
4231
|
let serviceSpecificationsFiles = [];
|
|
4226
4232
|
let serviceSpecifications = service.specifications;
|
|
@@ -4265,6 +4271,11 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4265
4271
|
await addServiceToDomain(domainId, { id: service.id, version: service.version }, domainVersion);
|
|
4266
4272
|
}
|
|
4267
4273
|
const latestServiceInCatalog = await getService(service.id, "latest");
|
|
4274
|
+
let latestVersionSpecificationFiles = [];
|
|
4275
|
+
try {
|
|
4276
|
+
latestVersionSpecificationFiles = await getSpecificationFilesForService(service.id, "latest");
|
|
4277
|
+
} catch (error) {
|
|
4278
|
+
}
|
|
4268
4279
|
const versionTheService = latestServiceInCatalog && isVersionGreaterThan(version, latestServiceInCatalog.version);
|
|
4269
4280
|
console.log(chalk4.blue(`Processing service: ${document2.info.title} (v${version})`));
|
|
4270
4281
|
if (latestServiceInCatalog && isVersionLessThan(version, latestServiceInCatalog.version)) {
|
|
@@ -4279,7 +4290,8 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4279
4290
|
owners: service.setMessageOwnersToServiceOwners ? service.owners : [],
|
|
4280
4291
|
serviceHasMultipleSpecFiles: Array.isArray(serviceSpec.path),
|
|
4281
4292
|
isDraft: isServiceMarkedAsDraft,
|
|
4282
|
-
serviceId: service.id
|
|
4293
|
+
serviceId: service.id,
|
|
4294
|
+
serviceVersion: service.version
|
|
4283
4295
|
});
|
|
4284
4296
|
let owners = service.owners || [];
|
|
4285
4297
|
let repository = null;
|
|
@@ -4287,7 +4299,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4287
4299
|
const persistPreviousSpecificationFiles = Array.isArray(serviceSpec.path) === false;
|
|
4288
4300
|
if (latestServiceInCatalog) {
|
|
4289
4301
|
serviceMarkdown = latestServiceInCatalog.markdown;
|
|
4290
|
-
serviceSpecificationsFiles =
|
|
4302
|
+
serviceSpecificationsFiles = latestVersionSpecificationFiles;
|
|
4291
4303
|
sends = latestServiceInCatalog.sends || [];
|
|
4292
4304
|
owners = latestServiceInCatalog.owners || [];
|
|
4293
4305
|
repository = latestServiceInCatalog.repository || null;
|
|
@@ -4349,7 +4361,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4349
4361
|
var processMessagesForOpenAPISpec = async (pathToSpec, document2, servicePath, options) => {
|
|
4350
4362
|
const operations = await getOperationsByType(pathToSpec, options.httpMethodsToMessages);
|
|
4351
4363
|
const sidebarBadgeType = options.sidebarBadgeType || "HTTP_METHOD";
|
|
4352
|
-
const version = document2.info.version;
|
|
4364
|
+
const version = options.serviceVersion || document2.info.version;
|
|
4353
4365
|
const preserveExistingMessages = options.preserveExistingMessages ?? true;
|
|
4354
4366
|
const isDraft = options.isDraft ?? null;
|
|
4355
4367
|
let receives = [], sends = [];
|
|
@@ -4360,7 +4372,8 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document2, servicePath, o
|
|
|
4360
4372
|
operation,
|
|
4361
4373
|
options.messages?.generateMarkdown,
|
|
4362
4374
|
options.messages?.id,
|
|
4363
|
-
options.serviceId
|
|
4375
|
+
options.serviceId,
|
|
4376
|
+
version
|
|
4364
4377
|
);
|
|
4365
4378
|
let messageMarkdown = message2.markdown;
|
|
4366
4379
|
const messageType = operation.type;
|
|
@@ -4382,7 +4395,7 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document2, servicePath, o
|
|
|
4382
4395
|
if (preserveExistingMessages) {
|
|
4383
4396
|
messageMarkdown = catalogedMessage.markdown;
|
|
4384
4397
|
}
|
|
4385
|
-
if (catalogedMessage.version !== version) {
|
|
4398
|
+
if (catalogedMessage.version !== message2.version) {
|
|
4386
4399
|
console.log("versioning message", message2.id);
|
|
4387
4400
|
await versionMessage(message2.id);
|
|
4388
4401
|
console.log(chalk4.cyan(` - Versioned previous message: ${message2.id} (v${catalogedMessage.version})`));
|