@eventcatalog/generator-openapi 5.0.1 → 5.0.2
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Service, Domain } from './types.mjs';
|
|
2
2
|
import 'openapi-types';
|
|
3
3
|
|
|
4
|
+
type MESSAGE_TYPE = 'command' | 'query' | 'event';
|
|
5
|
+
type HTTP_METHOD = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
6
|
+
type HTTP_METHOD_TO_MESSAGE_TYPE = Partial<Record<HTTP_METHOD, MESSAGE_TYPE>>;
|
|
4
7
|
type Props = {
|
|
5
8
|
services: Service[];
|
|
6
9
|
domain?: Domain;
|
|
@@ -9,7 +12,8 @@ type Props = {
|
|
|
9
12
|
licenseKey?: string;
|
|
10
13
|
writeFilesToRoot?: boolean;
|
|
11
14
|
sidebarBadgeType?: 'HTTP_METHOD' | 'MESSAGE_TYPE';
|
|
15
|
+
httpMethodsToMessages?: HTTP_METHOD_TO_MESSAGE_TYPE;
|
|
12
16
|
};
|
|
13
17
|
declare const _default: (_: any, options: Props) => Promise<void>;
|
|
14
18
|
|
|
15
|
-
export { _default as default };
|
|
19
|
+
export { type HTTP_METHOD, type HTTP_METHOD_TO_MESSAGE_TYPE, _default as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Service, Domain } from './types.js';
|
|
2
2
|
import 'openapi-types';
|
|
3
3
|
|
|
4
|
+
type MESSAGE_TYPE = 'command' | 'query' | 'event';
|
|
5
|
+
type HTTP_METHOD = 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
6
|
+
type HTTP_METHOD_TO_MESSAGE_TYPE = Partial<Record<HTTP_METHOD, MESSAGE_TYPE>>;
|
|
4
7
|
type Props = {
|
|
5
8
|
services: Service[];
|
|
6
9
|
domain?: Domain;
|
|
@@ -9,7 +12,8 @@ type Props = {
|
|
|
9
12
|
licenseKey?: string;
|
|
10
13
|
writeFilesToRoot?: boolean;
|
|
11
14
|
sidebarBadgeType?: 'HTTP_METHOD' | 'MESSAGE_TYPE';
|
|
15
|
+
httpMethodsToMessages?: HTTP_METHOD_TO_MESSAGE_TYPE;
|
|
12
16
|
};
|
|
13
17
|
declare const _default: (_: any, options: Props) => Promise<void>;
|
|
14
18
|
|
|
15
|
-
export { _default as default };
|
|
19
|
+
export { type HTTP_METHOD, type HTTP_METHOD_TO_MESSAGE_TYPE, _default as default };
|
package/dist/index.js
CHANGED
|
@@ -387,7 +387,7 @@ async function getSchemasByOperationId(filePath, operationId) {
|
|
|
387
387
|
return;
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
async function getOperationsByType(openApiPath) {
|
|
390
|
+
async function getOperationsByType(openApiPath, httpMethodsToMessages) {
|
|
391
391
|
try {
|
|
392
392
|
const api = await import_swagger_parser.default.validate(openApiPath);
|
|
393
393
|
const operations = [];
|
|
@@ -395,7 +395,8 @@ async function getOperationsByType(openApiPath) {
|
|
|
395
395
|
const pathItem = api.paths[path3];
|
|
396
396
|
for (const method in pathItem) {
|
|
397
397
|
const openAPIOperation = pathItem[method];
|
|
398
|
-
const
|
|
398
|
+
const defaultMessageType = httpMethodsToMessages?.[method.toUpperCase()] || DEFAULT_MESSAGE_TYPE;
|
|
399
|
+
const messageType = openAPIOperation["x-eventcatalog-message-type"] || defaultMessageType;
|
|
399
400
|
const messageAction = openAPIOperation["x-eventcatalog-message-action"] === "sends" ? "sends" : "receives";
|
|
400
401
|
const extensions = Object.keys(openAPIOperation).reduce((acc, key) => {
|
|
401
402
|
if (key.startsWith("x-eventcatalog-")) {
|
|
@@ -623,7 +624,7 @@ var import_chalk = __toESM(require("chalk"));
|
|
|
623
624
|
// package.json
|
|
624
625
|
var package_default = {
|
|
625
626
|
name: "@eventcatalog/generator-openapi",
|
|
626
|
-
version: "5.0.
|
|
627
|
+
version: "5.0.2",
|
|
627
628
|
description: "OpenAPI generator for EventCatalog",
|
|
628
629
|
scripts: {
|
|
629
630
|
build: "tsup",
|
|
@@ -1694,7 +1695,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
1694
1695
|
}
|
|
1695
1696
|
};
|
|
1696
1697
|
var processMessagesForOpenAPISpec = async (pathToSpec, document, servicePath, options) => {
|
|
1697
|
-
const operations = await getOperationsByType(pathToSpec);
|
|
1698
|
+
const operations = await getOperationsByType(pathToSpec, options.httpMethodsToMessages);
|
|
1698
1699
|
const sidebarBadgeType = options.sidebarBadgeType || "HTTP_METHOD";
|
|
1699
1700
|
const version = document.info.version;
|
|
1700
1701
|
let receives = [], sends = [];
|