@zuplo/openapi-tools 7.11.0 → 7.11.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/package.json +5 -2
- package/dist/file-format.spec.d.ts +0 -2
- package/dist/file-format.spec.d.ts.map +0 -1
- package/dist/file-format.spec.js +0 -289
- package/dist/file-format.spec.js.map +0 -1
- package/dist/merge-fixtures.spec.d.ts +0 -2
- package/dist/merge-fixtures.spec.d.ts.map +0 -1
- package/dist/merge-fixtures.spec.js +0 -181
- package/dist/merge-fixtures.spec.js.map +0 -1
- package/dist/merge.spec.d.ts +0 -2
- package/dist/merge.spec.d.ts.map +0 -1
- package/dist/merge.spec.js +0 -399
- package/dist/merge.spec.js.map +0 -1
- package/dist/overlay.spec.d.ts +0 -2
- package/dist/overlay.spec.d.ts.map +0 -1
- package/dist/overlay.spec.js +0 -779
- package/dist/overlay.spec.js.map +0 -1
- package/dist/path-transform.spec.d.ts +0 -2
- package/dist/path-transform.spec.d.ts.map +0 -1
- package/dist/path-transform.spec.js +0 -269
- package/dist/path-transform.spec.js.map +0 -1
- package/dist/url-utils.spec.d.ts +0 -2
- package/dist/url-utils.spec.d.ts.map +0 -1
- package/dist/url-utils.spec.js +0 -93
- package/dist/url-utils.spec.js.map +0 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@zuplo/openapi-tools",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "7.11.
|
|
5
|
+
"version": "7.11.1",
|
|
6
6
|
"description": "Tooling for OpenAPI files",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist/**/*",
|
|
19
19
|
"*.js",
|
|
20
|
-
"*.d.ts"
|
|
20
|
+
"*.d.ts",
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"!dist/**/*.spec.*",
|
|
23
|
+
"!dist/**/__tests__/**"
|
|
21
24
|
],
|
|
22
25
|
"author": "Zuplo",
|
|
23
26
|
"license": "Copyright 2021",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-format.spec.d.ts","sourceRoot":"","sources":["../src/file-format.spec.ts"],"names":[],"mappings":""}
|
package/dist/file-format.spec.js
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { convertDocument, detectFormatFromContent, detectFormatFromExtension, generateOutputPath, parseContent, serializeContent, } from "./file-format.js";
|
|
4
|
-
describe("File Format Utilities", () => {
|
|
5
|
-
describe("detectFormatFromExtension", () => {
|
|
6
|
-
it("should detect JSON format from .json extension", () => {
|
|
7
|
-
assert.strictEqual(detectFormatFromExtension("api.json"), "json");
|
|
8
|
-
assert.strictEqual(detectFormatFromExtension("/path/to/openapi.json"), "json");
|
|
9
|
-
assert.strictEqual(detectFormatFromExtension("FILE.JSON"), "json");
|
|
10
|
-
});
|
|
11
|
-
it("should detect YAML format from .yaml extension", () => {
|
|
12
|
-
assert.strictEqual(detectFormatFromExtension("api.yaml"), "yaml");
|
|
13
|
-
assert.strictEqual(detectFormatFromExtension("/path/to/openapi.yaml"), "yaml");
|
|
14
|
-
assert.strictEqual(detectFormatFromExtension("FILE.YAML"), "yaml");
|
|
15
|
-
});
|
|
16
|
-
it("should detect YAML format from .yml extension", () => {
|
|
17
|
-
assert.strictEqual(detectFormatFromExtension("api.yml"), "yaml");
|
|
18
|
-
assert.strictEqual(detectFormatFromExtension("/path/to/openapi.yml"), "yaml");
|
|
19
|
-
assert.strictEqual(detectFormatFromExtension("FILE.YML"), "yaml");
|
|
20
|
-
});
|
|
21
|
-
it("should return null for unknown extensions", () => {
|
|
22
|
-
assert.strictEqual(detectFormatFromExtension("api.txt"), null);
|
|
23
|
-
assert.strictEqual(detectFormatFromExtension("api"), null);
|
|
24
|
-
assert.strictEqual(detectFormatFromExtension("api.xml"), null);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe("detectFormatFromContent", () => {
|
|
28
|
-
it("should detect JSON content", () => {
|
|
29
|
-
const content = '{"openapi": "3.1.0"}';
|
|
30
|
-
assert.strictEqual(detectFormatFromContent(content), "json");
|
|
31
|
-
});
|
|
32
|
-
it("should detect YAML content", () => {
|
|
33
|
-
const content = "openapi: 3.1.0\ninfo:\n title: Test";
|
|
34
|
-
assert.strictEqual(detectFormatFromContent(content), "yaml");
|
|
35
|
-
});
|
|
36
|
-
it("should throw error for invalid content", () => {
|
|
37
|
-
const content = "not valid json or yaml: : :";
|
|
38
|
-
assert.throws(() => detectFormatFromContent(content), /Failed to parse content/);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe("parseContent", () => {
|
|
42
|
-
it("should parse JSON content", () => {
|
|
43
|
-
const content = '{"openapi": "3.1.0", "info": {"title": "Test"}}';
|
|
44
|
-
const result = parseContent(content, "json");
|
|
45
|
-
assert.deepStrictEqual(result, {
|
|
46
|
-
openapi: "3.1.0",
|
|
47
|
-
info: { title: "Test" },
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
it("should parse YAML content", () => {
|
|
51
|
-
const content = `openapi: 3.1.0
|
|
52
|
-
info:
|
|
53
|
-
title: Test
|
|
54
|
-
version: 1.0.0`;
|
|
55
|
-
const result = parseContent(content, "yaml");
|
|
56
|
-
assert.deepStrictEqual(result, {
|
|
57
|
-
openapi: "3.1.0",
|
|
58
|
-
info: { title: "Test", version: "1.0.0" },
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
it("should throw error for invalid JSON", () => {
|
|
62
|
-
const content = "{invalid json}";
|
|
63
|
-
assert.throws(() => parseContent(content, "json"), {
|
|
64
|
-
name: "SyntaxError",
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
it("should throw error for invalid YAML", () => {
|
|
68
|
-
const content = ":\ninvalid: : yaml";
|
|
69
|
-
assert.throws(() => parseContent(content, "yaml"));
|
|
70
|
-
});
|
|
71
|
-
it("should handle arrays", () => {
|
|
72
|
-
const jsonContent = "[1, 2, 3]";
|
|
73
|
-
const yamlContent = "- 1\n- 2\n- 3";
|
|
74
|
-
assert.deepStrictEqual(parseContent(jsonContent, "json"), [1, 2, 3]);
|
|
75
|
-
assert.deepStrictEqual(parseContent(yamlContent, "yaml"), [1, 2, 3]);
|
|
76
|
-
});
|
|
77
|
-
it("should handle nested structures", () => {
|
|
78
|
-
const content = {
|
|
79
|
-
openapi: "3.1.0",
|
|
80
|
-
paths: {
|
|
81
|
-
"/users": {
|
|
82
|
-
get: {
|
|
83
|
-
summary: "Get users",
|
|
84
|
-
parameters: [{ name: "limit", in: "query" }],
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
const jsonContent = JSON.stringify(content);
|
|
90
|
-
const result = parseContent(jsonContent, "json");
|
|
91
|
-
assert.deepStrictEqual(result, content);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe("serializeContent", () => {
|
|
95
|
-
const testDocument = {
|
|
96
|
-
openapi: "3.1.0",
|
|
97
|
-
info: {
|
|
98
|
-
title: "Test API",
|
|
99
|
-
version: "1.0.0",
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
it("should serialize to JSON with proper formatting", () => {
|
|
103
|
-
const result = serializeContent(testDocument, "json");
|
|
104
|
-
assert.strictEqual(typeof result, "string");
|
|
105
|
-
assert.strictEqual(result.includes('"openapi": "3.1.0"'), true);
|
|
106
|
-
assert.strictEqual(result.includes('"title": "Test API"'), true);
|
|
107
|
-
assert.strictEqual(result.endsWith("\n"), true);
|
|
108
|
-
// Verify it's valid JSON
|
|
109
|
-
const parsed = JSON.parse(result);
|
|
110
|
-
assert.deepStrictEqual(parsed, testDocument);
|
|
111
|
-
});
|
|
112
|
-
it("should serialize to YAML with proper formatting", () => {
|
|
113
|
-
const result = serializeContent(testDocument, "yaml");
|
|
114
|
-
assert.strictEqual(typeof result, "string");
|
|
115
|
-
assert.strictEqual(result.includes("openapi: 3.1.0"), true);
|
|
116
|
-
assert.strictEqual(result.includes("title: Test API"), true);
|
|
117
|
-
assert.strictEqual(result.includes("version: 1.0.0"), true);
|
|
118
|
-
});
|
|
119
|
-
it("should handle arrays in JSON", () => {
|
|
120
|
-
const doc = { items: [1, 2, 3] };
|
|
121
|
-
const result = serializeContent(doc, "json");
|
|
122
|
-
assert.strictEqual(result.includes('"items": [\n'), true);
|
|
123
|
-
const parsed = JSON.parse(result);
|
|
124
|
-
assert.deepStrictEqual(parsed, doc);
|
|
125
|
-
});
|
|
126
|
-
it("should handle arrays in YAML", () => {
|
|
127
|
-
const doc = { items: [1, 2, 3] };
|
|
128
|
-
const result = serializeContent(doc, "yaml");
|
|
129
|
-
assert.strictEqual(result.includes("items:"), true);
|
|
130
|
-
assert.strictEqual(result.includes("- 1"), true);
|
|
131
|
-
});
|
|
132
|
-
it("should handle special characters in YAML", () => {
|
|
133
|
-
const doc = {
|
|
134
|
-
description: 'This has a colon: and quotes "test"',
|
|
135
|
-
};
|
|
136
|
-
const result = serializeContent(doc, "yaml");
|
|
137
|
-
assert.strictEqual(typeof result, "string");
|
|
138
|
-
// Should be properly escaped
|
|
139
|
-
assert.strictEqual(result.includes("description:"), true);
|
|
140
|
-
});
|
|
141
|
-
it("should handle null values", () => {
|
|
142
|
-
const doc = { value: null };
|
|
143
|
-
const jsonResult = serializeContent(doc, "json");
|
|
144
|
-
const yamlResult = serializeContent(doc, "yaml");
|
|
145
|
-
assert.strictEqual(jsonResult.includes('"value": null'), true);
|
|
146
|
-
assert.strictEqual(yamlResult.includes("value:"), true);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
describe("convertDocument", () => {
|
|
150
|
-
const testDocument = {
|
|
151
|
-
openapi: "3.1.0",
|
|
152
|
-
info: {
|
|
153
|
-
title: "Test API",
|
|
154
|
-
version: "1.0.0",
|
|
155
|
-
},
|
|
156
|
-
paths: {},
|
|
157
|
-
};
|
|
158
|
-
it("should convert from JSON to YAML", () => {
|
|
159
|
-
const jsonContent = JSON.stringify(testDocument);
|
|
160
|
-
const result = convertDocument(jsonContent, "json", "yaml");
|
|
161
|
-
assert.strictEqual(result.format, "yaml");
|
|
162
|
-
assert.strictEqual(typeof result.content, "string");
|
|
163
|
-
assert.strictEqual(result.content.includes("openapi: 3.1.0"), true);
|
|
164
|
-
assert.strictEqual(result.content.includes("title: Test API"), true);
|
|
165
|
-
});
|
|
166
|
-
it("should convert from YAML to JSON", () => {
|
|
167
|
-
const yamlContent = `openapi: 3.1.0
|
|
168
|
-
info:
|
|
169
|
-
title: Test API
|
|
170
|
-
version: 1.0.0
|
|
171
|
-
paths: {}`;
|
|
172
|
-
const result = convertDocument(yamlContent, "yaml", "json");
|
|
173
|
-
assert.strictEqual(result.format, "json");
|
|
174
|
-
assert.strictEqual(typeof result.content, "string");
|
|
175
|
-
const parsed = JSON.parse(result.content);
|
|
176
|
-
assert.strictEqual(parsed.openapi, "3.1.0");
|
|
177
|
-
assert.strictEqual(parsed.info.title, "Test API");
|
|
178
|
-
});
|
|
179
|
-
it("should preserve data through JSON to YAML to JSON conversion", () => {
|
|
180
|
-
const originalJson = JSON.stringify(testDocument);
|
|
181
|
-
// JSON -> YAML
|
|
182
|
-
const yamlResult = convertDocument(originalJson, "json", "yaml");
|
|
183
|
-
// YAML -> JSON
|
|
184
|
-
const jsonResult = convertDocument(yamlResult.content, "yaml", "json");
|
|
185
|
-
const finalDocument = JSON.parse(jsonResult.content);
|
|
186
|
-
assert.deepStrictEqual(finalDocument, testDocument);
|
|
187
|
-
});
|
|
188
|
-
it("should preserve data through YAML to JSON to YAML conversion", () => {
|
|
189
|
-
const originalYaml = `openapi: 3.1.0
|
|
190
|
-
info:
|
|
191
|
-
title: Test API
|
|
192
|
-
version: 1.0.0
|
|
193
|
-
paths: {}`;
|
|
194
|
-
// Parse original to compare
|
|
195
|
-
const originalDoc = parseContent(originalYaml, "yaml");
|
|
196
|
-
// YAML -> JSON
|
|
197
|
-
const jsonResult = convertDocument(originalYaml, "yaml", "json");
|
|
198
|
-
// JSON -> YAML
|
|
199
|
-
const yamlResult = convertDocument(jsonResult.content, "json", "yaml");
|
|
200
|
-
const finalDocument = parseContent(yamlResult.content, "yaml");
|
|
201
|
-
assert.deepStrictEqual(finalDocument, originalDoc);
|
|
202
|
-
});
|
|
203
|
-
it("should handle complex nested structures", () => {
|
|
204
|
-
const complexDoc = {
|
|
205
|
-
openapi: "3.1.0",
|
|
206
|
-
paths: {
|
|
207
|
-
"/users/{id}": {
|
|
208
|
-
get: {
|
|
209
|
-
parameters: [
|
|
210
|
-
{ name: "id", in: "path", required: true },
|
|
211
|
-
{ name: "fields", in: "query", required: false },
|
|
212
|
-
],
|
|
213
|
-
responses: {
|
|
214
|
-
"200": {
|
|
215
|
-
description: "Success",
|
|
216
|
-
content: {
|
|
217
|
-
"application/json": {
|
|
218
|
-
schema: {
|
|
219
|
-
type: "object",
|
|
220
|
-
properties: {
|
|
221
|
-
id: { type: "string" },
|
|
222
|
-
name: { type: "string" },
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
};
|
|
233
|
-
const jsonContent = JSON.stringify(complexDoc);
|
|
234
|
-
const yamlResult = convertDocument(jsonContent, "json", "yaml");
|
|
235
|
-
const backToJson = convertDocument(yamlResult.content, "yaml", "json");
|
|
236
|
-
const finalDoc = JSON.parse(backToJson.content);
|
|
237
|
-
assert.deepStrictEqual(finalDoc, complexDoc);
|
|
238
|
-
});
|
|
239
|
-
it("should handle empty objects and arrays", () => {
|
|
240
|
-
const doc = {
|
|
241
|
-
empty_object: {},
|
|
242
|
-
empty_array: [],
|
|
243
|
-
nested: {
|
|
244
|
-
also_empty: {},
|
|
245
|
-
},
|
|
246
|
-
};
|
|
247
|
-
const jsonContent = JSON.stringify(doc);
|
|
248
|
-
const yamlResult = convertDocument(jsonContent, "json", "yaml");
|
|
249
|
-
const backToJson = convertDocument(yamlResult.content, "yaml", "json");
|
|
250
|
-
const finalDoc = JSON.parse(backToJson.content);
|
|
251
|
-
assert.deepStrictEqual(finalDoc, doc);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
describe("generateOutputPath", () => {
|
|
255
|
-
it("should replace .json with .yaml", () => {
|
|
256
|
-
assert.strictEqual(generateOutputPath("api.json", "yaml"), "api.yaml");
|
|
257
|
-
});
|
|
258
|
-
it("should replace .yaml with .json", () => {
|
|
259
|
-
assert.strictEqual(generateOutputPath("api.yaml", "json"), "api.json");
|
|
260
|
-
});
|
|
261
|
-
it("should replace .yml with .json", () => {
|
|
262
|
-
assert.strictEqual(generateOutputPath("api.yml", "json"), "api.json");
|
|
263
|
-
});
|
|
264
|
-
it("should handle paths with directories", () => {
|
|
265
|
-
assert.strictEqual(generateOutputPath("/path/to/api.json", "yaml"), "/path/to/api.yaml");
|
|
266
|
-
assert.strictEqual(generateOutputPath("/path/to/api.yaml", "json"), "/path/to/api.json");
|
|
267
|
-
});
|
|
268
|
-
it("should handle relative paths", () => {
|
|
269
|
-
assert.strictEqual(generateOutputPath("./docs/api.json", "yaml"), "./docs/api.yaml");
|
|
270
|
-
assert.strictEqual(generateOutputPath("../specs/api.yaml", "json"), "../specs/api.json");
|
|
271
|
-
});
|
|
272
|
-
it("should handle files with multiple dots in name", () => {
|
|
273
|
-
assert.strictEqual(generateOutputPath("api.v1.0.json", "yaml"), "api.v1.0.yaml");
|
|
274
|
-
assert.strictEqual(generateOutputPath("my.api.spec.yaml", "json"), "my.api.spec.json");
|
|
275
|
-
});
|
|
276
|
-
it("should append extension if file has no extension", () => {
|
|
277
|
-
assert.strictEqual(generateOutputPath("api", "json"), "api.json");
|
|
278
|
-
assert.strictEqual(generateOutputPath("openapi", "yaml"), "openapi.yaml");
|
|
279
|
-
});
|
|
280
|
-
it("should handle Windows-style paths", () => {
|
|
281
|
-
assert.strictEqual(generateOutputPath("C:\\Users\\docs\\api.json", "yaml"), "C:\\Users\\docs\\api.yaml");
|
|
282
|
-
});
|
|
283
|
-
it("should always use .yaml extension (not .yml) for yaml output", () => {
|
|
284
|
-
assert.strictEqual(generateOutputPath("api.yml", "yaml"), "api.yaml");
|
|
285
|
-
assert.strictEqual(generateOutputPath("api.json", "yaml"), "api.yaml");
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
//# sourceMappingURL=file-format.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-format.spec.js","sourceRoot":"","sources":["../src/file-format.spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACzC,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,CAAC,WAAW,CAAC,yBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;YAClE,MAAM,CAAC,WAAW,CAChB,yBAAyB,CAAC,uBAAuB,CAAC,EAClD,MAAM,CACP,CAAC;YACF,MAAM,CAAC,WAAW,CAAC,yBAAyB,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,CAAC,WAAW,CAAC,yBAAyB,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;YAClE,MAA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C;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;YACtE,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;YACtE,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-fixtures.spec.d.ts","sourceRoot":"","sources":["../src/merge-fixtures.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { describe, it } from "node:test";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { mergeOpenApiDocuments } from "./merge.js";
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
// Test fixtures are in the package root
|
|
10
|
-
// When running from dist/, __dirname is packages/openapi-tools/dist
|
|
11
|
-
const testFixturesPath = path.join(__dirname, "..", "test-fixtures");
|
|
12
|
-
/**
|
|
13
|
-
* Determine merge options based on fixture directory name
|
|
14
|
-
*/
|
|
15
|
-
function getMergeOptionsFromFixtureName(fixtureName) {
|
|
16
|
-
// Check for operation-id merge mode
|
|
17
|
-
if (fixtureName.includes("operation-id")) {
|
|
18
|
-
return { mergeMode: "operation-id" };
|
|
19
|
-
}
|
|
20
|
-
// Check for path transformation options
|
|
21
|
-
if (fixtureName.includes("path-transformation-prepend")) {
|
|
22
|
-
return { mergeMode: "operation-id", prependServerPath: true };
|
|
23
|
-
}
|
|
24
|
-
// Default to path-method merge mode
|
|
25
|
-
return { mergeMode: "path-method" };
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Recursively sort object keys for consistent comparison
|
|
29
|
-
* Also removes undefined values to match JSON.stringify behavior
|
|
30
|
-
*/
|
|
31
|
-
function sortObjectKeys(obj) {
|
|
32
|
-
if (obj === null || typeof obj !== "object") {
|
|
33
|
-
return obj;
|
|
34
|
-
}
|
|
35
|
-
if (Array.isArray(obj)) {
|
|
36
|
-
return obj.map(sortObjectKeys);
|
|
37
|
-
}
|
|
38
|
-
const sortedObj = {};
|
|
39
|
-
const keys = Object.keys(obj).sort();
|
|
40
|
-
for (const key of keys) {
|
|
41
|
-
const value = obj[key];
|
|
42
|
-
// Skip undefined values (matching JSON.stringify behavior)
|
|
43
|
-
if (value !== undefined) {
|
|
44
|
-
sortedObj[key] = sortObjectKeys(value);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return sortedObj;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Deep comparison that provides useful diff information
|
|
51
|
-
*/
|
|
52
|
-
function deepCompare(actual, expected, path = "") {
|
|
53
|
-
if (actual === expected) {
|
|
54
|
-
return { equal: true };
|
|
55
|
-
}
|
|
56
|
-
if (typeof actual !== typeof expected) {
|
|
57
|
-
return {
|
|
58
|
-
equal: false,
|
|
59
|
-
message: `Type mismatch at ${path || "root"}: expected ${typeof expected}, got ${typeof actual}`,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
if (actual === null || expected === null) {
|
|
63
|
-
return {
|
|
64
|
-
equal: false,
|
|
65
|
-
message: `Null mismatch at ${path || "root"}: expected ${expected}, got ${actual}`,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
if (typeof actual !== "object") {
|
|
69
|
-
return {
|
|
70
|
-
equal: false,
|
|
71
|
-
message: `Value mismatch at ${path || "root"}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (Array.isArray(actual) !== Array.isArray(expected)) {
|
|
75
|
-
return {
|
|
76
|
-
equal: false,
|
|
77
|
-
message: `Array/Object mismatch at ${path || "root"}`,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
if (Array.isArray(actual) && Array.isArray(expected)) {
|
|
81
|
-
if (actual.length !== expected.length) {
|
|
82
|
-
return {
|
|
83
|
-
equal: false,
|
|
84
|
-
message: `Array length mismatch at ${path || "root"}: expected ${expected.length}, got ${actual.length}`,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
for (let i = 0; i < actual.length; i++) {
|
|
88
|
-
const result = deepCompare(actual[i], expected[i], `${path}[${i}]`);
|
|
89
|
-
if (!result.equal) {
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return { equal: true };
|
|
94
|
-
}
|
|
95
|
-
const actualObj = actual;
|
|
96
|
-
const expectedObj = expected;
|
|
97
|
-
const actualKeys = Object.keys(actualObj).sort();
|
|
98
|
-
const expectedKeys = Object.keys(expectedObj).sort();
|
|
99
|
-
// Check for missing keys
|
|
100
|
-
for (const key of expectedKeys) {
|
|
101
|
-
if (!(key in actualObj)) {
|
|
102
|
-
return {
|
|
103
|
-
equal: false,
|
|
104
|
-
message: `Missing key at ${path ? `${path}.${key}` : key}`,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// Check for extra keys
|
|
109
|
-
for (const key of actualKeys) {
|
|
110
|
-
if (!(key in expectedObj)) {
|
|
111
|
-
return {
|
|
112
|
-
equal: false,
|
|
113
|
-
message: `Extra key at ${path ? `${path}.${key}` : key}`,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
// Recursively compare values
|
|
118
|
-
for (const key of expectedKeys) {
|
|
119
|
-
const result = deepCompare(actualObj[key], expectedObj[key], path ? `${path}.${key}` : key);
|
|
120
|
-
if (!result.equal) {
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return { equal: true };
|
|
125
|
-
}
|
|
126
|
-
describe("OpenAPI Merge Fixtures", async () => {
|
|
127
|
-
// Discover all fixture directories
|
|
128
|
-
let fixtureDirectories;
|
|
129
|
-
try {
|
|
130
|
-
const entries = await fs.readdir(testFixturesPath, { withFileTypes: true });
|
|
131
|
-
fixtureDirectories = entries
|
|
132
|
-
.filter((entry) => entry.isDirectory())
|
|
133
|
-
.map((entry) => entry.name)
|
|
134
|
-
.filter((name) => /^\d{2}-/.test(name)) // Only include numbered directories
|
|
135
|
-
.sort();
|
|
136
|
-
}
|
|
137
|
-
catch (error) {
|
|
138
|
-
console.error("Failed to read test fixtures directory:", error);
|
|
139
|
-
fixtureDirectories = [];
|
|
140
|
-
}
|
|
141
|
-
for (const fixtureName of fixtureDirectories) {
|
|
142
|
-
it(`should merge correctly: ${fixtureName}`, async () => {
|
|
143
|
-
const fixtureDir = path.join(testFixturesPath, fixtureName);
|
|
144
|
-
// Read fixture files
|
|
145
|
-
const [sourceContent, destinationContent, expectedMergedContent] = await Promise.all([
|
|
146
|
-
fs.readFile(path.join(fixtureDir, "source.json"), "utf-8"),
|
|
147
|
-
fs.readFile(path.join(fixtureDir, "destination.json"), "utf-8"),
|
|
148
|
-
fs.readFile(path.join(fixtureDir, "merged.json"), "utf-8"),
|
|
149
|
-
]);
|
|
150
|
-
const source = JSON.parse(sourceContent);
|
|
151
|
-
const destination = JSON.parse(destinationContent);
|
|
152
|
-
const expectedMerged = JSON.parse(expectedMergedContent);
|
|
153
|
-
// Determine merge options from fixture name
|
|
154
|
-
const config = getMergeOptionsFromFixtureName(fixtureName);
|
|
155
|
-
const mergeOptions = {
|
|
156
|
-
mergeMode: config.mergeMode,
|
|
157
|
-
prependServerPath: config.prependServerPath,
|
|
158
|
-
prependPath: config.prependPath,
|
|
159
|
-
};
|
|
160
|
-
// Perform the merge
|
|
161
|
-
const { mergedDocument } = mergeOpenApiDocuments(destination, source, mergeOptions);
|
|
162
|
-
// Compare the merged result with the expected result
|
|
163
|
-
// Sort keys for consistent comparison
|
|
164
|
-
const sortedActual = sortObjectKeys(mergedDocument);
|
|
165
|
-
const sortedExpected = sortObjectKeys(expectedMerged);
|
|
166
|
-
const comparison = deepCompare(sortedActual, sortedExpected);
|
|
167
|
-
if (!comparison.equal) {
|
|
168
|
-
// Provide detailed diff for debugging
|
|
169
|
-
console.log("\n--- Fixture:", fixtureName, "---");
|
|
170
|
-
console.log("Merge options:", JSON.stringify(mergeOptions));
|
|
171
|
-
console.log("Difference:", comparison.message);
|
|
172
|
-
console.log("\nExpected:");
|
|
173
|
-
console.log(JSON.stringify(sortedExpected, null, 2));
|
|
174
|
-
console.log("\nActual:");
|
|
175
|
-
console.log(JSON.stringify(sortedActual, null, 2));
|
|
176
|
-
}
|
|
177
|
-
assert.ok(comparison.equal, `Merge result does not match expected: ${comparison.message}`);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
//# sourceMappingURL=merge-fixtures.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-fixtures.spec.js","sourceRoot":"","sources":["../src/merge-fixtures.spec.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAqB,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,wCAAwC;AACxC,oEAAoE;AACpE,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,SAA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,UAAU,GAAG,WAAW,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;YAE7D,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;gBACtB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;gBAClD,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;gBAC5D,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;gBAC/C,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBACrD,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;gBACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACrD,CAAC;YAED,MAAM,CAAC,EAAE,CACP,UAAU,CAAC,KAAK,EAChB,yCAAyC,UAAU,CAAC,OAAO,EAAE,CAC9D,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/dist/merge.spec.d.ts
DELETED
package/dist/merge.spec.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge.spec.d.ts","sourceRoot":"","sources":["../src/merge.spec.ts"],"names":[],"mappings":""}
|