@eventcatalog/generator-openapi 7.9.0 → 7.9.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
@@ -1610,15 +1610,19 @@ async function getSchemasByOperationId(filePath, operationId, parsedDocument) {
1610
1610
  }
1611
1611
  if (typedOperation.requestBody && typedOperation.requestBody.content) {
1612
1612
  const contentType = Object.keys(typedOperation.requestBody.content)[0];
1613
- schemas.requestBody = typedOperation.requestBody.content[contentType].schema;
1613
+ if (contentType) {
1614
+ schemas.requestBody = typedOperation.requestBody.content[contentType].schema;
1615
+ }
1614
1616
  }
1615
1617
  if (typedOperation.responses) {
1616
1618
  for (const [statusCode, response] of Object.entries(typedOperation.responses)) {
1617
1619
  if (response.content) {
1618
1620
  const contentType = Object.keys(response.content)[0];
1619
- const schemaOrContent = response.content[contentType].schema || response.content[contentType];
1620
- schemas.responses[statusCode] = { ...schemaOrContent };
1621
- schemas.responses[statusCode].isSchema = !!response.content[contentType].schema;
1621
+ if (contentType) {
1622
+ const schemaOrContent = response.content[contentType].schema || response.content[contentType];
1623
+ schemas.responses[statusCode] = { ...schemaOrContent };
1624
+ schemas.responses[statusCode].isSchema = !!response.content[contentType].schema;
1625
+ }
1622
1626
  }
1623
1627
  }
1624
1628
  }
@@ -1641,14 +1645,16 @@ async function getExamplesByOperationId(filePath, operationId, parsedDocument) {
1641
1645
  if (typedOperation.operationId !== operationId) continue;
1642
1646
  if (typedOperation.requestBody?.content) {
1643
1647
  const contentType = Object.keys(typedOperation.requestBody.content)[0];
1644
- const mediaType = typedOperation.requestBody.content[contentType];
1645
- if (mediaType.example) {
1646
- examples.push({ fileName: "example.json", content: JSON.stringify(mediaType.example, null, 2) });
1647
- }
1648
- if (mediaType.examples) {
1649
- for (const [name, exampleObj] of Object.entries(mediaType.examples)) {
1650
- if (exampleObj.value) {
1651
- examples.push({ fileName: `${name}.json`, content: JSON.stringify(exampleObj.value, null, 2) });
1648
+ if (contentType) {
1649
+ const mediaType = typedOperation.requestBody.content[contentType];
1650
+ if (mediaType.example) {
1651
+ examples.push({ fileName: "example.json", content: JSON.stringify(mediaType.example, null, 2) });
1652
+ }
1653
+ if (mediaType.examples) {
1654
+ for (const [name, exampleObj] of Object.entries(mediaType.examples)) {
1655
+ if (exampleObj.value) {
1656
+ examples.push({ fileName: `${name}.json`, content: JSON.stringify(exampleObj.value, null, 2) });
1657
+ }
1652
1658
  }
1653
1659
  }
1654
1660
  }
@@ -1657,17 +1663,19 @@ async function getExamplesByOperationId(filePath, operationId, parsedDocument) {
1657
1663
  for (const [statusCode, response] of Object.entries(typedOperation.responses)) {
1658
1664
  if (response.content) {
1659
1665
  const contentType = Object.keys(response.content)[0];
1660
- const mediaType = response.content[contentType];
1661
- if (mediaType.example) {
1662
- examples.push({ fileName: `response-${statusCode}.json`, content: JSON.stringify(mediaType.example, null, 2) });
1663
- }
1664
- if (mediaType.examples) {
1665
- for (const [name, exampleObj] of Object.entries(mediaType.examples)) {
1666
- if (exampleObj.value) {
1667
- examples.push({
1668
- fileName: `response-${statusCode}-${name}.json`,
1669
- content: JSON.stringify(exampleObj.value, null, 2)
1670
- });
1666
+ if (contentType) {
1667
+ const mediaType = response.content[contentType];
1668
+ if (mediaType.example) {
1669
+ examples.push({ fileName: `response-${statusCode}.json`, content: JSON.stringify(mediaType.example, null, 2) });
1670
+ }
1671
+ if (mediaType.examples) {
1672
+ for (const [name, exampleObj] of Object.entries(mediaType.examples)) {
1673
+ if (exampleObj.value) {
1674
+ examples.push({
1675
+ fileName: `response-${statusCode}-${name}.json`,
1676
+ content: JSON.stringify(exampleObj.value, null, 2)
1677
+ });
1678
+ }
1671
1679
  }
1672
1680
  }
1673
1681
  }
@@ -4205,7 +4213,7 @@ var import_node_path = require("path");
4205
4213
  // package.json
4206
4214
  var package_default = {
4207
4215
  name: "@eventcatalog/generator-openapi",
4208
- version: "7.9.0",
4216
+ version: "7.9.1",
4209
4217
  description: "OpenAPI generator for EventCatalog",
4210
4218
  scripts: {
4211
4219
  build: "tsup",