@eventcatalog/generator-openapi 4.0.5 → 4.0.7

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.mjs CHANGED
@@ -608,7 +608,7 @@ import chalk from "chalk";
608
608
  // package.json
609
609
  var package_default = {
610
610
  name: "@eventcatalog/generator-openapi",
611
- version: "4.0.5",
611
+ version: "4.0.7",
612
612
  description: "OpenAPI generator for EventCatalog",
613
613
  scripts: {
614
614
  build: "tsup",
@@ -1516,7 +1516,8 @@ var getInstalledVersionOfPackage = (packageName) => {
1516
1516
  const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd();
1517
1517
  const pkg = fs.readFileSync(path2.join(PROJECT_DIR, "package.json"), "utf8");
1518
1518
  const json = JSON.parse(pkg);
1519
- return json.dependencies[packageName];
1519
+ const version = json.dependencies[packageName];
1520
+ return version?.replace(/[\^~><=]/g, "");
1520
1521
  } catch (error) {
1521
1522
  return null;
1522
1523
  }
@@ -1733,11 +1734,29 @@ var processMessagesForOpenAPISpec = async (pathToSpec, document, servicePath, op
1733
1734
  }
1734
1735
  if (requestBodiesAndResponses?.responses) {
1735
1736
  for (const [statusCode, schema] of Object.entries(requestBodiesAndResponses.responses)) {
1737
+ const getContent = () => {
1738
+ try {
1739
+ return JSON.stringify(schema, null, 2);
1740
+ } catch (error) {
1741
+ const seen = /* @__PURE__ */ new WeakSet();
1742
+ return JSON.stringify(
1743
+ schema,
1744
+ (key, value) => {
1745
+ if (typeof value === "object" && value !== null) {
1746
+ if (seen.has(value)) return "[Circular]";
1747
+ seen.add(value);
1748
+ }
1749
+ return value;
1750
+ },
1751
+ 2
1752
+ );
1753
+ }
1754
+ };
1736
1755
  await addFileToMessage(
1737
1756
  message.id,
1738
1757
  {
1739
1758
  fileName: `response-${statusCode}.json`,
1740
- content: JSON.stringify(schema, null, 2)
1759
+ content: getContent()
1741
1760
  },
1742
1761
  message.version
1743
1762
  );