json-machete 0.6.0-alpha-63f903dfd.0 → 0.6.0-alpha-d4888db4e.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 +23 -0
- package/index.mjs +23 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -484,6 +484,21 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
|
|
|
484
484
|
|
|
485
485
|
const asArray = (value) => (Array.isArray(value) ? value : [value]);
|
|
486
486
|
const reservedTypeNames = ['Query', 'Mutation', 'Subscription'];
|
|
487
|
+
const JSONSchemaStringFormats = [
|
|
488
|
+
'date',
|
|
489
|
+
'hostname',
|
|
490
|
+
'regex',
|
|
491
|
+
'json-pointer',
|
|
492
|
+
'relative-json-pointer',
|
|
493
|
+
'uri-reference',
|
|
494
|
+
'uri-template',
|
|
495
|
+
'date-time',
|
|
496
|
+
'time',
|
|
497
|
+
'email',
|
|
498
|
+
'ipv4',
|
|
499
|
+
'ipv6',
|
|
500
|
+
'uri',
|
|
501
|
+
];
|
|
487
502
|
function deduplicateJSONSchema(schema, seenMap = new Map()) {
|
|
488
503
|
if (typeof schema === 'object' && schema != null) {
|
|
489
504
|
if (!schema.$comment) {
|
|
@@ -580,6 +595,14 @@ async function healJSONSchema(schema) {
|
|
|
580
595
|
}
|
|
581
596
|
}
|
|
582
597
|
}
|
|
598
|
+
if (subSchema.format === 'dateTime') {
|
|
599
|
+
subSchema.format = 'date-time';
|
|
600
|
+
}
|
|
601
|
+
if (subSchema.format) {
|
|
602
|
+
if (!JSONSchemaStringFormats.includes(subSchema.format)) {
|
|
603
|
+
delete subSchema.format;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
583
606
|
// If it is an object type but no properties given while example is available
|
|
584
607
|
if (subSchema.type === 'object' && !subSchema.properties && subSchema.example) {
|
|
585
608
|
const generatedSchema = toJsonSchema(subSchema.example, {
|
package/index.mjs
CHANGED
|
@@ -479,6 +479,21 @@ async function dereferenceObject(obj, { cwd = process.cwd(), externalFileCache =
|
|
|
479
479
|
|
|
480
480
|
const asArray = (value) => (Array.isArray(value) ? value : [value]);
|
|
481
481
|
const reservedTypeNames = ['Query', 'Mutation', 'Subscription'];
|
|
482
|
+
const JSONSchemaStringFormats = [
|
|
483
|
+
'date',
|
|
484
|
+
'hostname',
|
|
485
|
+
'regex',
|
|
486
|
+
'json-pointer',
|
|
487
|
+
'relative-json-pointer',
|
|
488
|
+
'uri-reference',
|
|
489
|
+
'uri-template',
|
|
490
|
+
'date-time',
|
|
491
|
+
'time',
|
|
492
|
+
'email',
|
|
493
|
+
'ipv4',
|
|
494
|
+
'ipv6',
|
|
495
|
+
'uri',
|
|
496
|
+
];
|
|
482
497
|
function deduplicateJSONSchema(schema, seenMap = new Map()) {
|
|
483
498
|
if (typeof schema === 'object' && schema != null) {
|
|
484
499
|
if (!schema.$comment) {
|
|
@@ -575,6 +590,14 @@ async function healJSONSchema(schema) {
|
|
|
575
590
|
}
|
|
576
591
|
}
|
|
577
592
|
}
|
|
593
|
+
if (subSchema.format === 'dateTime') {
|
|
594
|
+
subSchema.format = 'date-time';
|
|
595
|
+
}
|
|
596
|
+
if (subSchema.format) {
|
|
597
|
+
if (!JSONSchemaStringFormats.includes(subSchema.format)) {
|
|
598
|
+
delete subSchema.format;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
578
601
|
// If it is an object type but no properties given while example is available
|
|
579
602
|
if (subSchema.type === 'object' && !subSchema.properties && subSchema.example) {
|
|
580
603
|
const generatedSchema = toJsonSchema(subSchema.example, {
|