@eventcatalog/generator-asyncapi 6.1.0 → 6.1.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 CHANGED
@@ -1543,7 +1543,7 @@ var import_path3 = __toESM(require("path"));
1543
1543
  // package.json
1544
1544
  var package_default = {
1545
1545
  name: "@eventcatalog/generator-asyncapi",
1546
- version: "6.1.0",
1546
+ version: "6.1.1",
1547
1547
  description: "AsyncAPI generator for EventCatalog",
1548
1548
  scripts: {
1549
1549
  build: "tsup",
@@ -1584,7 +1584,7 @@ var package_default = {
1584
1584
  "@eventcatalog/sdk": "2.17.4",
1585
1585
  chalk: "4.1.2",
1586
1586
  "fs-extra": "^11.2.0",
1587
- glob: "^11.0.0",
1587
+ glob: "^12.0.0",
1588
1588
  "gray-matter": "^4.0.3",
1589
1589
  "js-yaml": "^4.1.0",
1590
1590
  lodash: "^4.17.23",
@@ -4071,6 +4071,26 @@ Failed to verify license key`));
4071
4071
  // src/index.ts
4072
4072
  var import_node_path = require("path");
4073
4073
  var parser = new import_parser.Parser();
4074
+ var safeStringify = (obj, indent) => {
4075
+ const seen = /* @__PURE__ */ new WeakSet();
4076
+ return JSON.stringify(
4077
+ obj,
4078
+ (_key, value) => {
4079
+ if (typeof value === "object" && value !== null) {
4080
+ if (seen.has(value)) {
4081
+ const schemaId = value["x-parser-schema-id"];
4082
+ if (schemaId && typeof schemaId === "string") {
4083
+ return { $ref: `#/components/schemas/${schemaId}` };
4084
+ }
4085
+ return { $ref: "#" };
4086
+ }
4087
+ seen.add(value);
4088
+ }
4089
+ return value;
4090
+ },
4091
+ indent
4092
+ );
4093
+ };
4074
4094
  parser.registerSchemaParser((0, import_avro_schema_parser.AvroSchemaParser)());
4075
4095
  var cliArgs = (0, import_minimist.default)(process.argv.slice(2));
4076
4096
  var optionsSchema = import_zod.z.object({
@@ -4440,7 +4460,7 @@ Processing domain: ${domainName} (v${domainVersion})`));
4440
4460
  messageId,
4441
4461
  {
4442
4462
  fileName: getSchemaFileName(message2),
4443
- schema: JSON.stringify(schema, null, 4)
4463
+ schema: safeStringify(schema, 4)
4444
4464
  },
4445
4465
  messageVersion,
4446
4466
  { path: cleanedMessagePath }
@@ -4562,7 +4582,7 @@ Finished generating event catalog for AsyncAPI ${serviceId} (v${version})`));
4562
4582
  };
4563
4583
  var getParsedSpecFile = (service, document2) => {
4564
4584
  const isSpecFileJSON = service.path.endsWith(".json");
4565
- return isSpecFileJSON ? JSON.stringify(document2.meta().asyncapi.parsed, null, 4) : import_js_yaml.default.dump(document2.meta().asyncapi.parsed, { noRefs: true });
4585
+ return isSpecFileJSON ? safeStringify(document2.meta().asyncapi.parsed, 4) : import_js_yaml.default.dump(document2.meta().asyncapi.parsed, { noRefs: true });
4566
4586
  };
4567
4587
  var getRawSpecFile = async (service) => {
4568
4588
  if (service.path.startsWith("http")) {