@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.mjs CHANGED
@@ -1605,15 +1605,19 @@ async function getSchemasByOperationId(filePath, operationId, parsedDocument) {
1605
1605
  }
1606
1606
  if (typedOperation.requestBody && typedOperation.requestBody.content) {
1607
1607
  const contentType = Object.keys(typedOperation.requestBody.content)[0];
1608
- schemas.requestBody = typedOperation.requestBody.content[contentType].schema;
1608
+ if (contentType) {
1609
+ schemas.requestBody = typedOperation.requestBody.content[contentType].schema;
1610
+ }
1609
1611
  }
1610
1612
  if (typedOperation.responses) {
1611
1613
  for (const [statusCode, response] of Object.entries(typedOperation.responses)) {
1612
1614
  if (response.content) {
1613
1615
  const contentType = Object.keys(response.content)[0];
1614
- const schemaOrContent = response.content[contentType].schema || response.content[contentType];
1615
- schemas.responses[statusCode] = { ...schemaOrContent };
1616
- schemas.responses[statusCode].isSchema = !!response.content[contentType].schema;
1616
+ if (contentType) {
1617
+ const schemaOrContent = response.content[contentType].schema || response.content[contentType];
1618
+ schemas.responses[statusCode] = { ...schemaOrContent };
1619
+ schemas.responses[statusCode].isSchema = !!response.content[contentType].schema;
1620
+ }
1617
1621
  }
1618
1622
  }
1619
1623
  }
@@ -1636,14 +1640,16 @@ async function getExamplesByOperationId(filePath, operationId, parsedDocument) {
1636
1640
  if (typedOperation.operationId !== operationId) continue;
1637
1641
  if (typedOperation.requestBody?.content) {
1638
1642
  const contentType = Object.keys(typedOperation.requestBody.content)[0];
1639
- const mediaType = typedOperation.requestBody.content[contentType];
1640
- if (mediaType.example) {
1641
- examples.push({ fileName: "example.json", content: JSON.stringify(mediaType.example, null, 2) });
1642
- }
1643
- if (mediaType.examples) {
1644
- for (const [name, exampleObj] of Object.entries(mediaType.examples)) {
1645
- if (exampleObj.value) {
1646
- examples.push({ fileName: `${name}.json`, content: JSON.stringify(exampleObj.value, null, 2) });
1643
+ if (contentType) {
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) });
1652
+ }
1647
1653
  }
1648
1654
  }
1649
1655
  }
@@ -1652,17 +1658,19 @@ async function getExamplesByOperationId(filePath, operationId, parsedDocument) {
1652
1658
  for (const [statusCode, response] of Object.entries(typedOperation.responses)) {
1653
1659
  if (response.content) {
1654
1660
  const contentType = Object.keys(response.content)[0];
1655
- const mediaType = response.content[contentType];
1656
- if (mediaType.example) {
1657
- examples.push({ fileName: `response-${statusCode}.json`, content: JSON.stringify(mediaType.example, null, 2) });
1658
- }
1659
- if (mediaType.examples) {
1660
- for (const [name, exampleObj] of Object.entries(mediaType.examples)) {
1661
- if (exampleObj.value) {
1662
- examples.push({
1663
- fileName: `response-${statusCode}-${name}.json`,
1664
- content: JSON.stringify(exampleObj.value, null, 2)
1665
- });
1661
+ if (contentType) {
1662
+ const mediaType = response.content[contentType];
1663
+ if (mediaType.example) {
1664
+ examples.push({ fileName: `response-${statusCode}.json`, content: JSON.stringify(mediaType.example, null, 2) });
1665
+ }
1666
+ if (mediaType.examples) {
1667
+ for (const [name, exampleObj] of Object.entries(mediaType.examples)) {
1668
+ if (exampleObj.value) {
1669
+ examples.push({
1670
+ fileName: `response-${statusCode}-${name}.json`,
1671
+ content: JSON.stringify(exampleObj.value, null, 2)
1672
+ });
1673
+ }
1666
1674
  }
1667
1675
  }
1668
1676
  }
@@ -4200,7 +4208,7 @@ import { join } from "path";
4200
4208
  // package.json
4201
4209
  var package_default = {
4202
4210
  name: "@eventcatalog/generator-openapi",
4203
- version: "7.9.0",
4211
+ version: "7.9.1",
4204
4212
  description: "OpenAPI generator for EventCatalog",
4205
4213
  scripts: {
4206
4214
  build: "tsup",