@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 +32 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
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
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
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
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
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.
|
|
4211
|
+
version: "7.9.1",
|
|
4204
4212
|
description: "OpenAPI generator for EventCatalog",
|
|
4205
4213
|
scripts: {
|
|
4206
4214
|
build: "tsup",
|