@acmekit/acmekit-oas-cli 2.13.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.
Files changed (44) hide show
  1. package/README.md +155 -0
  2. package/dist/command-docs.d.ts +13 -0
  3. package/dist/command-docs.d.ts.map +1 -0
  4. package/dist/command-docs.js +233 -0
  5. package/dist/command-docs.js.map +1 -0
  6. package/dist/command-oas.d.ts +13 -0
  7. package/dist/command-oas.d.ts.map +1 -0
  8. package/dist/command-oas.js +210 -0
  9. package/dist/command-oas.js.map +1 -0
  10. package/dist/index.d.ts +4 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +37 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/tsconfig.tsbuildinfo +1 -0
  15. package/dist/types.d.ts +10 -0
  16. package/dist/types.d.ts.map +1 -0
  17. package/dist/types.js +1 -0
  18. package/dist/types.js.map +1 -0
  19. package/dist/utils/circular-patch-utils.d.ts +8 -0
  20. package/dist/utils/circular-patch-utils.d.ts.map +1 -0
  21. package/dist/utils/circular-patch-utils.js +70 -0
  22. package/dist/utils/circular-patch-utils.js.map +1 -0
  23. package/dist/utils/combine-oas.d.ts +3 -0
  24. package/dist/utils/combine-oas.d.ts.map +1 -0
  25. package/dist/utils/combine-oas.js +97 -0
  26. package/dist/utils/combine-oas.js.map +1 -0
  27. package/dist/utils/fs-utils.d.ts +4 -0
  28. package/dist/utils/fs-utils.d.ts.map +1 -0
  29. package/dist/utils/fs-utils.js +69 -0
  30. package/dist/utils/fs-utils.js.map +1 -0
  31. package/dist/utils/json-utils.d.ts +3 -0
  32. package/dist/utils/json-utils.d.ts.map +1 -0
  33. package/dist/utils/json-utils.js +18 -0
  34. package/dist/utils/json-utils.js.map +1 -0
  35. package/dist/utils/merge-oas.d.ts +4 -0
  36. package/dist/utils/merge-oas.d.ts.map +1 -0
  37. package/dist/utils/merge-oas.js +87 -0
  38. package/dist/utils/merge-oas.js.map +1 -0
  39. package/dist/utils/yaml-utils.d.ts +6 -0
  40. package/dist/utils/yaml-utils.d.ts.map +1 -0
  41. package/dist/utils/yaml-utils.js +67 -0
  42. package/dist/utils/yaml-utils.js.map +1 -0
  43. package/oas/default.oas.base.yaml +5 -0
  44. package/package.json +43 -0
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ #! /usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getBaseCommand = getBaseCommand;
5
+ const commander_1 = require("commander");
6
+ const command_oas_1 = require("./command-oas");
7
+ const command_docs_1 = require("./command-docs");
8
+ const run = async () => {
9
+ const program = getBaseCommand();
10
+ /**
11
+ * Alias to command-oas.ts
12
+ */
13
+ program.addCommand((0, command_oas_1.getCommand)());
14
+ /**
15
+ * Alias to command-docs.ts
16
+ */
17
+ program.addCommand((0, command_docs_1.getCommand)());
18
+ /**
19
+ * Run CLI
20
+ */
21
+ await program.parseAsync();
22
+ };
23
+ function getBaseCommand() {
24
+ const command = new commander_1.Command();
25
+ command.name("acmekit-oas");
26
+ command.action(async () => {
27
+ console.log("No command provided.");
28
+ command.outputHelp({ error: true });
29
+ });
30
+ command.showHelpAfterError(true);
31
+ command.helpOption(false);
32
+ return command;
33
+ }
34
+ void (async () => {
35
+ await run();
36
+ })();
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAyBA,wCAUC;AAjCD,yCAAmC;AACnC,+CAA2D;AAC3D,iDAA6D;AAE7D,MAAM,GAAG,GAAG,KAAK,IAAI,EAAE;IACrB,MAAM,OAAO,GAAG,cAAc,EAAE,CAAA;IAEhC;;OAEG;IACH,OAAO,CAAC,UAAU,CAAC,IAAA,wBAAa,GAAE,CAAC,CAAA;IAEnC;;OAEG;IACH,OAAO,CAAC,UAAU,CAAC,IAAA,yBAAc,GAAE,CAAC,CAAA;IAEpC;;OAEG;IACH,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA;AAC5B,CAAC,CAAA;AAED,SAAgB,cAAc;IAC5B,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAA;IAC7B,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA;QACnC,OAAO,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;IAChC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACzB,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,KAAK,CAAC,KAAK,IAAI,EAAE;IACf,MAAM,GAAG,EAAE,CAAA;AACb,CAAC,CAAC,EAAE,CAAA"}
@@ -0,0 +1 @@
1
+ {"root":["../src/command-docs.ts","../src/command-oas.ts","../src/index.ts","../src/types.ts","../src/utils/circular-patch-utils.ts","../src/utils/combine-oas.ts","../src/utils/fs-utils.ts","../src/utils/json-utils.ts","../src/utils/merge-oas.ts","../src/utils/yaml-utils.ts"],"version":"5.9.3"}
@@ -0,0 +1,10 @@
1
+ type ApiType = "store" | "admin" | "combined";
2
+ type CircularReferenceSchema = Record<string, string[]>;
3
+ type CircularReferenceConfig = {
4
+ decorators: {
5
+ "acmekit/circular-patch": {
6
+ schemas: CircularReferenceSchema;
7
+ };
8
+ };
9
+ };
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAA;AAE7C,KAAK,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAEvD,KAAK,uBAAuB,GAAG;IAC7B,UAAU,EAAE;QACV,wBAAwB,EAAE;YACxB,OAAO,EAAE,uBAAuB,CAAA;SACjC,CAAA;KACF,CAAA;CACF,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { OpenAPIObject } from "openapi3-ts";
2
+ export declare const getCircularReferences: (srcFile: string) => Promise<{
3
+ circularRefs: string[];
4
+ oas: OpenAPIObject;
5
+ }>;
6
+ export declare const getCircularPatchRecommendation: (circularRefs: string[], oas: OpenAPIObject) => CircularReferenceSchema;
7
+ export declare const formatHintRecommendation: (recommendation: CircularReferenceSchema) => string;
8
+ //# sourceMappingURL=circular-patch-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circular-patch-utils.d.ts","sourceRoot":"","sources":["../../src/utils/circular-patch-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAA;AAKzD,eAAO,MAAM,qBAAqB,GAChC,SAAS,MAAM,KACd,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,aAAa,CAAA;CAAE,CAiBxD,CAAA;AAED,eAAO,MAAM,8BAA8B,GACzC,cAAc,MAAM,EAAE,EACtB,KAAK,aAAa,KACjB,uBA+CF,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,gBAAgB,uBAAuB,WAKxC,CAAA"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatHintRecommendation = exports.getCircularPatchRecommendation = exports.getCircularReferences = void 0;
7
+ const openapi_parser_1 = __importDefault(require("@readme/openapi-parser"));
8
+ const yaml_utils_1 = require("./yaml-utils");
9
+ const getCircularReferences = async (srcFile) => {
10
+ const parser = new openapi_parser_1.default();
11
+ const oas = (await parser.validate(srcFile, {
12
+ dereference: {
13
+ circular: "ignore",
14
+ },
15
+ }));
16
+ if (parser.$refs.circular) {
17
+ const $refs = parser.$refs;
18
+ let circularRefs = $refs.circularRefs.map((ref) => ref.match(/#\/components\/schemas\/.*/)[0]);
19
+ circularRefs = [...new Set(circularRefs)];
20
+ circularRefs.sort();
21
+ return { circularRefs, oas };
22
+ }
23
+ return { circularRefs: [], oas };
24
+ };
25
+ exports.getCircularReferences = getCircularReferences;
26
+ const getCircularPatchRecommendation = (circularRefs, oas) => {
27
+ const matches = circularRefs
28
+ .map((ref) => {
29
+ var _a;
30
+ let match = (_a = ref.match(/(?:.*)(?:#\/components\/schemas\/)(.*)(?:\/properties\/?)(.*)/)) !== null && _a !== void 0 ? _a : [];
31
+ let schema = match[1];
32
+ let property = match[2];
33
+ let isArray = false;
34
+ if (property.endsWith("/items")) {
35
+ property = property.replace("/items", "");
36
+ isArray = true;
37
+ }
38
+ return { schema, property, isArray };
39
+ })
40
+ .filter((match) => match.property !== "")
41
+ .map((match) => {
42
+ const baseSchema = oas.components.schemas[match.schema];
43
+ const propertySpec = match.isArray
44
+ ? baseSchema.properties[match.property].items
45
+ : baseSchema.properties[match.property];
46
+ const referencedSchema = propertySpec["$ref"].match(/(?:#\/components\/schemas\/)(.*)/)[1];
47
+ return {
48
+ schema: match.schema,
49
+ property: match.property,
50
+ isArray: match.isArray,
51
+ referencedSchema,
52
+ };
53
+ });
54
+ const schemas = {};
55
+ for (const match of matches) {
56
+ if (!schemas.hasOwnProperty(match.schema)) {
57
+ schemas[match.schema] = [];
58
+ }
59
+ schemas[match.schema].push(match.referencedSchema);
60
+ }
61
+ return schemas;
62
+ };
63
+ exports.getCircularPatchRecommendation = getCircularPatchRecommendation;
64
+ const formatHintRecommendation = (recommendation) => {
65
+ return (0, yaml_utils_1.jsonObjectToYamlString)({
66
+ decorators: { "acmekit/circular-patch": { schemas: recommendation } },
67
+ });
68
+ };
69
+ exports.formatHintRecommendation = formatHintRecommendation;
70
+ //# sourceMappingURL=circular-patch-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circular-patch-utils.js","sourceRoot":"","sources":["../../src/utils/circular-patch-utils.ts"],"names":[],"mappings":";;;;;;AACA,4EAAkD;AAElD,6CAAqD;AAE9C,MAAM,qBAAqB,GAAG,KAAK,EACxC,OAAe,EAC0C,EAAE;IAC3D,MAAM,MAAM,GAAG,IAAI,wBAAa,EAAE,CAAA;IAClC,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE;QAC1C,WAAW,EAAE;YACX,QAAQ,EAAE,QAAQ;SACnB;KACF,CAAC,CAAkB,CAAA;IACpB,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAc,CAAA;QACnC,IAAI,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,CACvC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,4BAA4B,CAAE,CAAC,CAAC,CAAC,CACrD,CAAA;QACD,YAAY,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;QACzC,YAAY,CAAC,IAAI,EAAE,CAAA;QACnB,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;IAC9B,CAAC;IACD,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,GAAG,EAAE,CAAA;AAClC,CAAC,CAAA;AAnBY,QAAA,qBAAqB,yBAmBjC;AAEM,MAAM,8BAA8B,GAAG,CAC5C,YAAsB,EACtB,GAAkB,EACO,EAAE;IAO3B,MAAM,OAAO,GAA6B,YAAY;SACnD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;;QACX,IAAI,K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IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;QAC5B,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAlDY,QAAA,8BAA8B,kCAkD1C;AAEM,MAAM,wBAAwB,GAAG,CACtC,cAAuC,EACvC,EAAE;IACF,OAAO,IAAA,mCAAsB,EAAC;QAC5B,UAAU,EAAE,EAAE,wBAAwB,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE;KACtE,CAAC,CAAA;AACJ,CAAC,CAAA;AANY,QAAA,wBAAwB,4BAMpC"}
@@ -0,0 +1,3 @@
1
+ import { OpenAPIObject } from "openapi3-ts";
2
+ export declare function combineOAS(adminOAS: OpenAPIObject, storeOAS: OpenAPIObject): Promise<OpenAPIObject>;
3
+ //# sourceMappingURL=combine-oas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combine-oas.d.ts","sourceRoot":"","sources":["../../src/utils/combine-oas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,aAAa,CAAC,CA4DxB"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.combineOAS = combineOAS;
4
+ const utils_1 = require("@acmekit/utils");
5
+ async function combineOAS(adminOAS, storeOAS) {
6
+ prepareOASForCombine(adminOAS, "admin");
7
+ prepareOASForCombine(storeOAS, "store");
8
+ const combinedOAS = {
9
+ openapi: "3.0.0",
10
+ info: { title: "AcmeKit API", version: "1.0.0" },
11
+ servers: [],
12
+ paths: {},
13
+ tags: [],
14
+ components: {
15
+ callbacks: {},
16
+ examples: {},
17
+ headers: {},
18
+ links: {},
19
+ parameters: {},
20
+ requestBodies: {},
21
+ responses: {},
22
+ schemas: {},
23
+ securitySchemes: {},
24
+ },
25
+ };
26
+ for (const oas of [adminOAS, storeOAS]) {
27
+ /**
28
+ * Combine paths
29
+ */
30
+ Object.assign(combinedOAS.paths, oas.paths);
31
+ /**
32
+ * Combine tags
33
+ */
34
+ if (oas.tags) {
35
+ combinedOAS.tags = [...combinedOAS.tags, ...oas.tags];
36
+ }
37
+ /**
38
+ * Combine components
39
+ */
40
+ if (oas.components) {
41
+ for (const componentGroup of [
42
+ "callbacks",
43
+ "examples",
44
+ "headers",
45
+ "links",
46
+ "parameters",
47
+ "requestBodies",
48
+ "responses",
49
+ "schemas",
50
+ "securitySchemes",
51
+ ]) {
52
+ if (Object.keys(oas.components).includes(componentGroup)) {
53
+ Object.assign(combinedOAS.components[componentGroup], oas.components[componentGroup]);
54
+ }
55
+ }
56
+ }
57
+ }
58
+ return combinedOAS;
59
+ }
60
+ function prepareOASForCombine(oas, apiType) {
61
+ console.log(`🔵 Prefixing ${apiType} tags and operationId with ${(0, utils_1.upperCaseFirst)(apiType)}`);
62
+ for (const pathKey in oas.paths) {
63
+ for (const operationKey in oas.paths[pathKey]) {
64
+ /**
65
+ * Prefix tags declared on routes
66
+ * e.g.: Admin Customer, Store Customer
67
+ */
68
+ if (oas.paths[pathKey][operationKey].tags) {
69
+ oas.paths[pathKey][operationKey].tags = oas.paths[pathKey][operationKey].tags.map((tag) => getPrefixedTagName(tag, apiType));
70
+ }
71
+ /**
72
+ * Prefix operationId
73
+ * e.g.: AdminGetCustomers, StoreGetCustomers
74
+ */
75
+ if (oas.paths[pathKey][operationKey].operationId) {
76
+ oas.paths[pathKey][operationKey].operationId = getPrefixedOperationId(oas.paths[pathKey][operationKey].operationId, apiType);
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ * Prefix tags globally
82
+ * e.g.: Admin Customer, Store Customer
83
+ */
84
+ if (oas.tags) {
85
+ for (const tag of oas.tags) {
86
+ tag.name = getPrefixedTagName(tag.name, apiType);
87
+ }
88
+ }
89
+ return oas;
90
+ }
91
+ function getPrefixedTagName(tagName, apiType) {
92
+ return `${(0, utils_1.upperCaseFirst)(apiType)} ${tagName}`;
93
+ }
94
+ function getPrefixedOperationId(operationId, apiType) {
95
+ return `${(0, utils_1.upperCaseFirst)(apiType)}${operationId}`;
96
+ }
97
+ //# sourceMappingURL=combine-oas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combine-oas.js","sourceRoot":"","sources":["../../src/utils/combine-oas.ts"],"names":[],"mappings":";;AAGA,gCA+DC;AAlED,0CAA+C;AAGxC,KAAK,UAAU,UAAU,CAC9B,QAAuB,EACvB,QAAuB;IAEvB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACvC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAEvC,MAAM,WAAW,GAAkB;QACjC,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,EAAE;QAChD,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE;QACR,UAAU,EAAE;YACV,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,aAAa,EAAE,EAAE;YACjB,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,eAAe,EAAE,EAAE;SACpB;KACF,CAAA;IAED,KAAK,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;QACvC;;WAEG;QACH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,KAA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,CACxD,YAAY,CACb,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAA;YACvD,CAAC;YACD;;;eAGG;YACH,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;gBACjD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,WAAW,GAAG,sBAAsB,CACnE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,WAAW,EAC5C,OAAO,CACR,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;YAC3B,GAAG,CAAC,IAAI,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAClD,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAe,EAAE,OAAgB;IAC3D,OAAO,GAAG,IAAA,sBAAc,EAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAA;AAChD,CAAC;AAED,SAAS,sBAAsB,CAAC,WAAmB,EAAE,OAAgB;IACnE,OAAO,GAAG,IAAA,sBAAc,EAAC,OAAO,CAAC,GAAG,WAAW,EAAE,CAAA;AACnD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function isFile(filePath: string): Promise<boolean>;
2
+ export declare function exists(filePath: string): Promise<boolean>;
3
+ export declare const getTmpDirectory: () => Promise<string>;
4
+ //# sourceMappingURL=fs-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-utils.d.ts","sourceRoot":"","sources":["../../src/utils/fs-utils.ts"],"names":[],"mappings":"AAIA,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO/D;AAED,eAAO,MAAM,eAAe,uBAM3B,CAAA"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getTmpDirectory = void 0;
37
+ exports.isFile = isFile;
38
+ exports.exists = exists;
39
+ const promises_1 = require("fs/promises");
40
+ const path_1 = __importStar(require("path"));
41
+ const os_1 = require("os");
42
+ async function isFile(filePath) {
43
+ try {
44
+ return (await (0, promises_1.lstat)(path_1.default.resolve(filePath))).isFile();
45
+ }
46
+ catch (err) {
47
+ console.log(err);
48
+ return false;
49
+ }
50
+ }
51
+ async function exists(filePath) {
52
+ try {
53
+ await (0, promises_1.access)(path_1.default.resolve(filePath));
54
+ return true;
55
+ }
56
+ catch (err) {
57
+ return false;
58
+ }
59
+ }
60
+ const getTmpDirectory = async () => {
61
+ var _a;
62
+ /**
63
+ * RUNNER_TEMP: GitHub action, the path to a temporary directory on the runner.
64
+ */
65
+ const tmpDir = (_a = process.env["RUNNER_TEMP"]) !== null && _a !== void 0 ? _a : (0, os_1.tmpdir)();
66
+ return await (0, promises_1.mkdtemp)(`${tmpDir}${path_1.sep}`);
67
+ };
68
+ exports.getTmpDirectory = getTmpDirectory;
69
+ //# sourceMappingURL=fs-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-utils.js","sourceRoot":"","sources":["../../src/utils/fs-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wBAOC;AAED,wBAOC;AApBD,0CAAoD;AACpD,6CAAgC;AAChC,2BAA2B;AAEpB,KAAK,UAAU,MAAM,CAAC,QAAgB;IAC3C,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,IAAA,gBAAK,EAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;IACvD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,MAAM,CAAC,QAAgB;IAC3C,IAAI,CAAC;QACH,MAAM,IAAA,iBAAM,EAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;QACpC,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAEM,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;;IACxC;;OAEG;IACH,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,mCAAI,IAAA,WAAM,GAAE,CAAA;IACrD,OAAO,MAAM,IAAA,kBAAO,EAAC,GAAG,MAAM,GAAG,UAAG,EAAE,CAAC,CAAA;AACzC,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B"}
@@ -0,0 +1,3 @@
1
+ export declare const readJson: (filePath: string) => Promise<unknown>;
2
+ export declare const writeJson: (filePath: string, jsonObject: unknown) => Promise<void>;
3
+ //# sourceMappingURL=json-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-utils.d.ts","sourceRoot":"","sources":["../../src/utils/json-utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CAGhE,CAAA;AAED,eAAO,MAAM,SAAS,GACpB,UAAU,MAAM,EAChB,YAAY,OAAO,KAClB,OAAO,CAAC,IAAI,CAGd,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.writeJson = exports.readJson = void 0;
7
+ const promises_1 = __importDefault(require("fs/promises"));
8
+ const readJson = async (filePath) => {
9
+ const jsonString = await promises_1.default.readFile(filePath, "utf8");
10
+ return JSON.parse(jsonString);
11
+ };
12
+ exports.readJson = readJson;
13
+ const writeJson = async (filePath, jsonObject) => {
14
+ const jsonString = JSON.stringify(jsonObject);
15
+ await promises_1.default.writeFile(filePath, jsonString, "utf8");
16
+ };
17
+ exports.writeJson = writeJson;
18
+ //# sourceMappingURL=json-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-utils.js","sourceRoot":"","sources":["../../src/utils/json-utils.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA4B;AAErB,MAAM,QAAQ,GAAG,KAAK,EAAE,QAAgB,EAAoB,EAAE;IACnE,MAAM,UAAU,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACtD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;AAC/B,CAAC,CAAA;AAHY,QAAA,QAAQ,YAGpB;AAEM,MAAM,SAAS,GAAG,KAAK,EAC5B,QAAgB,EAChB,UAAmB,EACJ,EAAE;IACjB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IAC7C,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC,CAAA;AANY,QAAA,SAAS,aAMrB"}
@@ -0,0 +1,4 @@
1
+ import { OpenAPIObject } from "openapi3-ts";
2
+ export declare function mergeBaseIntoOAS(targetOAS: OpenAPIObject, sourceOAS: OpenAPIObject): void;
3
+ export declare function mergePathsAndSchemasIntoOAS(targetOAS: OpenAPIObject, sourceOAS: OpenAPIObject): void;
4
+ //# sourceMappingURL=merge-oas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-oas.d.ts","sourceRoot":"","sources":["../../src/utils/merge-oas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,aAAa,CAAA;AAEtD,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,aAAa,GACvB,IAAI,CAgEN;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,aAAa,GACvB,IAAI,CAkBN"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeBaseIntoOAS = mergeBaseIntoOAS;
4
+ exports.mergePathsAndSchemasIntoOAS = mergePathsAndSchemasIntoOAS;
5
+ function mergeBaseIntoOAS(targetOAS, sourceOAS) {
6
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
7
+ /**
8
+ * replace strategy for OpenAPIObject properties
9
+ */
10
+ targetOAS.openapi = (_a = sourceOAS.openapi) !== null && _a !== void 0 ? _a : targetOAS.openapi;
11
+ targetOAS.info = (_b = sourceOAS.info) !== null && _b !== void 0 ? _b : targetOAS.info;
12
+ targetOAS.servers = (_c = sourceOAS.servers) !== null && _c !== void 0 ? _c : targetOAS.servers;
13
+ targetOAS.security = (_d = sourceOAS.security) !== null && _d !== void 0 ? _d : targetOAS.security;
14
+ targetOAS.externalDocs = (_e = sourceOAS.externalDocs) !== null && _e !== void 0 ? _e : targetOAS.externalDocs;
15
+ targetOAS.webhooks = (_f = sourceOAS.webhooks) !== null && _f !== void 0 ? _f : targetOAS.webhooks;
16
+ /**
17
+ * merge + concat strategy for tags
18
+ */
19
+ const targetTags = (_g = targetOAS.tags) !== null && _g !== void 0 ? _g : [];
20
+ const sourceTags = (_h = sourceOAS.tags) !== null && _h !== void 0 ? _h : [];
21
+ const combinedTags = [];
22
+ const sourceIndexes = [];
23
+ for (const targetTag of targetTags) {
24
+ for (const [sourceTagIndex, sourceTag] of sourceTags.entries()) {
25
+ if (targetTag.name === sourceTag.name) {
26
+ combinedTags.push(sourceTag);
27
+ sourceIndexes.push(sourceTagIndex);
28
+ continue;
29
+ }
30
+ combinedTags.push(targetTag);
31
+ }
32
+ }
33
+ for (const [sourceTagIndex, sourceTag] of sourceTags.entries()) {
34
+ if (!sourceIndexes.includes(sourceTagIndex)) {
35
+ combinedTags.push(sourceTag);
36
+ }
37
+ }
38
+ targetOAS.tags = combinedTags;
39
+ /**
40
+ * merge strategy for paths
41
+ */
42
+ targetOAS.paths = Object.assign((_j = targetOAS.paths) !== null && _j !== void 0 ? _j : {}, (_k = sourceOAS.paths) !== null && _k !== void 0 ? _k : {});
43
+ /**
44
+ * merge strategy for components
45
+ */
46
+ if (!sourceOAS.components) {
47
+ return;
48
+ }
49
+ if (!targetOAS.components) {
50
+ targetOAS.components = {};
51
+ }
52
+ for (const componentGroup of [
53
+ "callbacks",
54
+ "examples",
55
+ "headers",
56
+ "links",
57
+ "parameters",
58
+ "requestBodies",
59
+ "responses",
60
+ "schemas",
61
+ "securitySchemes",
62
+ ]) {
63
+ if (Object.keys(sourceOAS.components).includes(componentGroup)) {
64
+ targetOAS.components[componentGroup] = Object.assign((_l = targetOAS.components[componentGroup]) !== null && _l !== void 0 ? _l : {}, sourceOAS.components[componentGroup]);
65
+ }
66
+ }
67
+ }
68
+ function mergePathsAndSchemasIntoOAS(targetOAS, sourceOAS) {
69
+ var _a;
70
+ /**
71
+ * merge paths
72
+ */
73
+ Object.assign(targetOAS.paths, sourceOAS.paths);
74
+ /**
75
+ * merge components.schemas
76
+ */
77
+ if ((_a = sourceOAS.components) === null || _a === void 0 ? void 0 : _a.schemas) {
78
+ if (!targetOAS.components) {
79
+ targetOAS.components = {};
80
+ }
81
+ if (!targetOAS.components.schemas) {
82
+ targetOAS.components.schemas = {};
83
+ }
84
+ Object.assign(targetOAS.components.schemas, sourceOAS.components.schemas);
85
+ }
86
+ }
87
+ //# sourceMappingURL=merge-oas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge-oas.js","sourceRoot":"","sources":["../../src/utils/merge-oas.ts"],"names":[],"mappings":";;AAEA,4CAmEC;AAED,kEAqBC;AA1FD,SAAgB,gBAAgB,CAC9B,SAAwB,EACxB,SAAwB;;IAExB;;OAEG;IACH,SAAS,CAAC,OAAO,GAAG,MAAA,SAAS,CAAC,OAAO,mCAAI,SAAS,CAAC,OAAO,CAAA;IAC1D,SAAS,CAAC,IAAI,GAAG,MAAA,SAAS,CAAC,IAAI,mCAAI,SAAS,CAAC,IAAI,CAAA;IACjD,SAAS,CAAC,OAAO,GAAG,MAAA,SAAS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C,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAC3E,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const readYaml: (filePath: any) => Promise<unknown>;
2
+ export declare const writeYaml: (filePath: string, yamlContent: string) => Promise<void>;
3
+ export declare const writeYamlFromJson: (filePath: any, jsonObject: any) => Promise<void>;
4
+ export declare const jsonObjectToYamlString: (jsonObject: any) => string;
5
+ export declare const jsonFileToYamlFile: (inputJsonFile: any, outputYamlFile: any) => Promise<void>;
6
+ //# sourceMappingURL=yaml-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-utils.d.ts","sourceRoot":"","sources":["../../src/utils/yaml-utils.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ,GAAU,aAAQ,KAAG,OAAO,CAAC,OAAO,CAGxD,CAAA;AAED,eAAO,MAAM,SAAS,GACpB,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,OAAO,CAAC,IAAI,CAEd,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,aAAQ,EACR,eAAU,KACT,OAAO,CAAC,IAAI,CAGd,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,eAAU,KAAG,MAEnD,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAU,kBAAa,EAAE,mBAAc,kBAKrE,CAAA"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.jsonFileToYamlFile = exports.jsonObjectToYamlString = exports.writeYamlFromJson = exports.writeYaml = exports.readYaml = void 0;
40
+ const promises_1 = __importDefault(require("fs/promises"));
41
+ const yaml = __importStar(require("js-yaml"));
42
+ const readYaml = async (filePath) => {
43
+ const yamlString = await promises_1.default.readFile(filePath, "utf8");
44
+ return yaml.load(yamlString);
45
+ };
46
+ exports.readYaml = readYaml;
47
+ const writeYaml = async (filePath, yamlContent) => {
48
+ await promises_1.default.writeFile(filePath, yamlContent, "utf8");
49
+ };
50
+ exports.writeYaml = writeYaml;
51
+ const writeYamlFromJson = async (filePath, jsonObject) => {
52
+ const yamlString = yaml.dump(jsonObject);
53
+ await promises_1.default.writeFile(filePath, yamlString, "utf8");
54
+ };
55
+ exports.writeYamlFromJson = writeYamlFromJson;
56
+ const jsonObjectToYamlString = (jsonObject) => {
57
+ return yaml.dump(jsonObject);
58
+ };
59
+ exports.jsonObjectToYamlString = jsonObjectToYamlString;
60
+ const jsonFileToYamlFile = async (inputJsonFile, outputYamlFile) => {
61
+ const jsonString = await promises_1.default.readFile(inputJsonFile, "utf8");
62
+ const jsonObject = JSON.parse(jsonString);
63
+ const yamlString = yaml.dump(jsonObject);
64
+ await promises_1.default.writeFile(outputYamlFile, yamlString, "utf8");
65
+ };
66
+ exports.jsonFileToYamlFile = jsonFileToYamlFile;
67
+ //# sourceMappingURL=yaml-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml-utils.js","sourceRoot":"","sources":["../../src/utils/yaml-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA4B;AAC5B,8CAA+B;AAExB,MAAM,QAAQ,GAAG,KAAK,EAAE,QAAQ,EAAoB,EAAE;IAC3D,MAAM,UAAU,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACtD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AAC9B,CAAC,CAAA;AAHY,QAAA,QAAQ,YAGpB;AAEM,MAAM,SAAS,GAAG,KAAK,EAC5B,QAAgB,EAChB,WAAmB,EACJ,EAAE;IACjB,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,CAAA;AACnD,CAAC,CAAA;AALY,QAAA,SAAS,aAKrB;AAEM,MAAM,iBAAiB,GAAG,KAAK,EACpC,QAAQ,EACR,UAAU,EACK,EAAE;IACjB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACxC,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC,CAAA;AANY,QAAA,iBAAiB,qBAM7B;AAEM,MAAM,sBAAsB,GAAG,CAAC,UAAU,EAAU,EAAE;IAC3D,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AAC9B,CAAC,CAAA;AAFY,QAAA,sBAAsB,0BAElC;AAEM,MAAM,kBAAkB,GAAG,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE;IACxE,MAAM,UAAU,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACxC,MAAM,kBAAE,CAAC,SAAS,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;AACxD,CAAC,CAAA;AALY,QAAA,kBAAkB,sBAK9B"}
@@ -0,0 +1,5 @@
1
+ openapi: 3.0.0
2
+ info:
3
+ version: 1.0.0
4
+ title: AcmeKit API
5
+ paths: { }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@acmekit/acmekit-oas-cli",
3
+ "version": "2.13.1",
4
+ "description": "OAS CLI",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "acmekit-oas": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "oas"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/acmekit/acmekit",
16
+ "directory": "packages/cli/oas/acmekit-oas-cli"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "author": "AcmeKit",
22
+ "license": "MIT",
23
+ "devDependencies": {
24
+ "@acmekit/types": "2.13.1"
25
+ },
26
+ "scripts": {
27
+ "build": "yarn run -T tsc --build",
28
+ "acmekit-oas": "ts-node src/index.ts"
29
+ },
30
+ "dependencies": {
31
+ "@acmekit/acmekit": "2.13.1",
32
+ "@acmekit/utils": "2.13.1",
33
+ "@readme/json-schema-ref-parser": "^1.2.0",
34
+ "@readme/openapi-parser": "^2.4.0",
35
+ "@redocly/cli": "1.25.3",
36
+ "commander": "^11.0.0",
37
+ "execa": "^5.1.1",
38
+ "lodash.mergewith": "^4.6.2",
39
+ "openapi3-ts": "^3.1.2",
40
+ "swagger-inline": "^6.1.0",
41
+ "yargs": "^17.7.2"
42
+ }
43
+ }