json-machete 0.2.1 → 0.3.3-alpha-b6b65b0d4.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/index.js +17 -4
- package/index.mjs +17 -4
- package/package.json +5 -4
package/index.js
CHANGED
|
@@ -175,6 +175,19 @@ async function visitJSONSchema(schema, visitorFn, { visitedSubschemaResultMap, p
|
|
|
175
175
|
onCircularReference,
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
+
if (schema.components) {
|
|
179
|
+
visitedSchema.components = keepObjectRef ? visitedSchema.components : {};
|
|
180
|
+
visitedSchema.components.schemas = keepObjectRef ? visitedSchema.components.schemas : {};
|
|
181
|
+
const entries = Object.entries(schema.components.schemas);
|
|
182
|
+
for (const [schemaName, subSchema] of entries) {
|
|
183
|
+
visitedSchema.components.schemas[schemaName] = await visitJSONSchema(subSchema, visitorFn, {
|
|
184
|
+
visitedSubschemaResultMap,
|
|
185
|
+
path: path + '/components/schemas/' + schemaName,
|
|
186
|
+
keepObjectRef,
|
|
187
|
+
onCircularReference,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
178
191
|
const visitorResult = await visitorFn(visitedSchema, {
|
|
179
192
|
visitedSubschemaResultMap,
|
|
180
193
|
path,
|
|
@@ -349,10 +362,10 @@ async function healJSONSchema(schema) {
|
|
|
349
362
|
}
|
|
350
363
|
if (!subSchema.title && !subSchema.$ref) {
|
|
351
364
|
// Try to get definition name if missing
|
|
352
|
-
const splitByDefinitions = path.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
365
|
+
const splitByDefinitions = path.includes('/components/schemas/')
|
|
366
|
+
? path.split('/components/schemas/')
|
|
367
|
+
: path.split('/definitions/');
|
|
368
|
+
const maybeDefinitionBasedPath = splitByDefinitions.length > 1 ? splitByDefinitions[splitByDefinitions.length - 1] : path;
|
|
356
369
|
let pathBasedName = maybeDefinitionBasedPath
|
|
357
370
|
.split('/properties')
|
|
358
371
|
.join('')
|
package/index.mjs
CHANGED
|
@@ -170,6 +170,19 @@ async function visitJSONSchema(schema, visitorFn, { visitedSubschemaResultMap, p
|
|
|
170
170
|
onCircularReference,
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
+
if (schema.components) {
|
|
174
|
+
visitedSchema.components = keepObjectRef ? visitedSchema.components : {};
|
|
175
|
+
visitedSchema.components.schemas = keepObjectRef ? visitedSchema.components.schemas : {};
|
|
176
|
+
const entries = Object.entries(schema.components.schemas);
|
|
177
|
+
for (const [schemaName, subSchema] of entries) {
|
|
178
|
+
visitedSchema.components.schemas[schemaName] = await visitJSONSchema(subSchema, visitorFn, {
|
|
179
|
+
visitedSubschemaResultMap,
|
|
180
|
+
path: path + '/components/schemas/' + schemaName,
|
|
181
|
+
keepObjectRef,
|
|
182
|
+
onCircularReference,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
173
186
|
const visitorResult = await visitorFn(visitedSchema, {
|
|
174
187
|
visitedSubschemaResultMap,
|
|
175
188
|
path,
|
|
@@ -344,10 +357,10 @@ async function healJSONSchema(schema) {
|
|
|
344
357
|
}
|
|
345
358
|
if (!subSchema.title && !subSchema.$ref) {
|
|
346
359
|
// Try to get definition name if missing
|
|
347
|
-
const splitByDefinitions = path.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
360
|
+
const splitByDefinitions = path.includes('/components/schemas/')
|
|
361
|
+
? path.split('/components/schemas/')
|
|
362
|
+
: path.split('/definitions/');
|
|
363
|
+
const maybeDefinitionBasedPath = splitByDefinitions.length > 1 ? splitByDefinitions[splitByDefinitions.length - 1] : path;
|
|
351
364
|
let pathBasedName = maybeDefinitionBasedPath
|
|
352
365
|
.split('/properties')
|
|
353
366
|
.join('')
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-machete",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.3-alpha-b6b65b0d4.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@graphql-mesh/utils": "0.
|
|
6
|
+
"@graphql-mesh/utils": "0.24.2-alpha-b6b65b0d4.0",
|
|
7
7
|
"@json-schema-tools/meta-schema": "1.6.19",
|
|
8
|
-
"cross-undici-fetch": "0.1.
|
|
8
|
+
"cross-undici-fetch": "0.1.12",
|
|
9
9
|
"json-ptr": "3.0.1",
|
|
10
10
|
"url-join": "4.0.1"
|
|
11
11
|
},
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"./*": {
|
|
25
25
|
"require": "./*.js",
|
|
26
26
|
"import": "./*.mjs"
|
|
27
|
-
}
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
28
29
|
}
|
|
29
30
|
}
|