@eventcatalog/generator-openapi 7.9.0 → 7.10.0
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 +51 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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.
|
|
4211
|
+
version: "7.10.0",
|
|
4204
4212
|
description: "OpenAPI generator for EventCatalog",
|
|
4205
4213
|
scripts: {
|
|
4206
4214
|
build: "tsup",
|
|
@@ -4237,7 +4245,7 @@ var package_default = {
|
|
|
4237
4245
|
dependencies: {
|
|
4238
4246
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
4239
4247
|
"@changesets/cli": "^2.27.7",
|
|
4240
|
-
"@eventcatalog/sdk": "2.
|
|
4248
|
+
"@eventcatalog/sdk": "^2.18.2",
|
|
4241
4249
|
chalk: "4.1.2",
|
|
4242
4250
|
"js-yaml": "^4.1.0",
|
|
4243
4251
|
"openapi-types": "^12.1.3",
|
|
@@ -4418,7 +4426,8 @@ var index_default = async (_, options) => {
|
|
|
4418
4426
|
getService,
|
|
4419
4427
|
versionService,
|
|
4420
4428
|
writeService,
|
|
4421
|
-
addFileToService
|
|
4429
|
+
addFileToService,
|
|
4430
|
+
getResourcePath
|
|
4422
4431
|
} = utils2(process.env.PROJECT_DIR);
|
|
4423
4432
|
const { services = [], saveParsedSpecFile = false } = options;
|
|
4424
4433
|
for (const serviceSpec of services) {
|
|
@@ -4475,10 +4484,6 @@ var index_default = async (_, options) => {
|
|
|
4475
4484
|
// @ts-ignore
|
|
4476
4485
|
isDomainMarkedAsDraft || document2.info?.["x-eventcatalog-draft"] || serviceSpec.draft || null
|
|
4477
4486
|
);
|
|
4478
|
-
let servicePath = options.domain ? join("../", "domains", options.domain.id, "services", service.id) : join("../", "services", service.id);
|
|
4479
|
-
if (options.writeFilesToRoot) {
|
|
4480
|
-
servicePath = service.id;
|
|
4481
|
-
}
|
|
4482
4487
|
if (options.domain) {
|
|
4483
4488
|
const { id: domainId, name: domainName, version: domainVersion } = options.domain;
|
|
4484
4489
|
const domain = await getDomain(options.domain.id, domainVersion || "latest");
|
|
@@ -4506,6 +4511,22 @@ Processing domain: ${domainName} (v${domainVersion})`));
|
|
|
4506
4511
|
}
|
|
4507
4512
|
await addServiceToDomain(domainId, { id: service.id, version: service.version }, domainVersion);
|
|
4508
4513
|
}
|
|
4514
|
+
let servicePath = join("../", "services", service.id);
|
|
4515
|
+
if (options.domain) {
|
|
4516
|
+
const domainResource = await getResourcePath(
|
|
4517
|
+
process.env.PROJECT_DIR,
|
|
4518
|
+
options.domain.id,
|
|
4519
|
+
options.domain.version
|
|
4520
|
+
);
|
|
4521
|
+
if (domainResource) {
|
|
4522
|
+
servicePath = join("../", domainResource.directory, "services", service.id);
|
|
4523
|
+
} else {
|
|
4524
|
+
servicePath = join("../", "domains", options.domain.id, "services", service.id);
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
if (options.writeFilesToRoot) {
|
|
4528
|
+
servicePath = service.id;
|
|
4529
|
+
}
|
|
4509
4530
|
const latestServiceInCatalog = await getService(service.id, "latest");
|
|
4510
4531
|
const versionTheService = latestServiceInCatalog && isVersionGreaterThan(version, latestServiceInCatalog.version);
|
|
4511
4532
|
console.log(chalk4.blue(`Processing service: ${document2.info.title} (v${version})`));
|