Skip to content

Commit a00b1ee

Browse files
committed
fix: update to latest json schema meta schema
1 parent 831c224 commit a00b1ee

File tree

3 files changed

+33
-35
lines changed

3 files changed

+33
-35
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"!build/**/*.test.*"
2828
],
2929
"devDependencies": {
30-
"@json-schema-tools/meta-schema": "^1.6.10",
30+
"@json-schema-tools/meta-schema": "^1.6.18",
3131
"@types/jest": "^26.0.23",
3232
"@types/node": "^15.12.3",
3333
"@typescript-eslint/eslint-plugin": "^4.27.0",

src/index.test.ts

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("traverse", () => {
1414
it("default mutate", () => {
1515
const testSchema = {
1616
type: "string"
17-
};
17+
} as JSONSchema;
1818
const mutator = () => ({ hello: "world" });
1919

2020
const result = traverse(testSchema, mutator) as any;
@@ -26,7 +26,7 @@ describe("traverse", () => {
2626
it("mutate does not affect traversal", () => {
2727
const testSchema = {
2828
type: "object"
29-
};
29+
} as JSONSchema;
3030

3131
const mutator = jest.fn((s: JSONSchemaObject) => ({
3232
...s,
@@ -45,7 +45,7 @@ describe("traverse", () => {
4545
it("merge does not affect traversal", () => {
4646
const testSchema = {
4747
type: "object"
48-
};
48+
} as JSONSchema;
4949
const mergeProducer = jest.fn((s: JSONSchemaObject) => ({
5050
...s,
5151
properties: {
@@ -106,7 +106,7 @@ describe("traverse", () => {
106106
});
107107

108108
it("accepts boolean as valid schema in a nested schema", () => {
109-
const schema = { type: "object", properties: { a: true, b: false } };
109+
const schema = { type: "object", properties: { a: true, b: false } } as JSONSchema;
110110
const mockMutation = jest.fn((s) => s);
111111
traverse(schema, mockMutation);
112112
expect(mockMutation).toHaveBeenCalledTimes(3);
@@ -121,7 +121,7 @@ describe("traverse", () => {
121121
const schema = {
122122
type: "object",
123123
patternProperties: { "*.": a, "x-^": b }
124-
};
124+
} as JSONSchema;
125125
const mockMutation = jest.fn((s) => s);
126126
traverse(schema, mockMutation);
127127
expect(mockMutation).toHaveBeenCalledTimes(3);
@@ -133,7 +133,7 @@ describe("traverse", () => {
133133
it("allows booleans that are created via boolean class and new", () => {
134134
const a = new Boolean(true);
135135
const b = new Boolean(false);
136-
const schema = { type: "object", properties: { a, b } };
136+
const schema = { type: "object", properties: { a, b } } as JSONSchema;
137137
const mockMutation = jest.fn((s) => s);
138138
traverse(schema, mockMutation);
139139
expect(mockMutation).toHaveBeenCalledTimes(3);
@@ -148,7 +148,7 @@ describe("traverse", () => {
148148
});
149149

150150
it("items is a boolean", () => {
151-
const schema = { type: "array", items: true };
151+
const schema = { type: "array", items: true } as JSONSchema;
152152
const mockMutation = jest.fn((s) => s);
153153
traverse(schema, mockMutation);
154154
expect(mockMutation).toHaveBeenCalledTimes(2);
@@ -168,7 +168,7 @@ describe("traverse", () => {
168168
}
169169
}
170170
}
171-
};
171+
} as JSONSchema;
172172
const mockMutation = jest.fn((s) => s);
173173
traverse(schema, mockMutation);
174174
expect(mockMutation).toHaveBeenCalledTimes(6);
@@ -266,7 +266,7 @@ describe("traverse", () => {
266266

267267
describe("schema.type being an array", () => {
268268
it("allows type to be an array", () => {
269-
const schema = { type: ["boolean", "string"], title: "gotimebucko" };
269+
const schema = { type: ["boolean", "string"], title: "gotimebucko" } as JSONSchema;
270270
const mockMutation = jest.fn((s) => s);
271271
traverse(schema, mockMutation);
272272
expect(mockMutation).toHaveBeenCalledTimes(1);
@@ -281,7 +281,7 @@ describe("traverse", () => {
281281
b: { type: "integer" }
282282
},
283283
items: { type: "string" }
284-
};
284+
} as JSONSchema;
285285
const mockMutation = jest.fn((s) => s);
286286
traverse(schema, mockMutation);
287287
expect(mockMutation).toHaveBeenCalledTimes(4);
@@ -293,12 +293,12 @@ describe("traverse", () => {
293293
const schema = { type: "object", properties: { foo: {} } };
294294
schema.properties.foo = schema;
295295
const mockMutation = jest.fn((s) => s);
296-
traverse(schema, mockMutation);
296+
traverse(schema as JSONSchema, mockMutation);
297297
expect(mockMutation).toHaveBeenCalledTimes(1);
298298
});
299299

300300
it("does not follow $refs", () => {
301-
const schema = { type: "object", properties: { foo: { $ref: "#" } } };
301+
const schema = { type: "object", properties: { foo: { $ref: "#" } } } as JSONSchema;
302302
const mockMutation = jest.fn((s) => s);
303303
traverse(schema, mockMutation);
304304
expect(mockMutation).toHaveBeenCalledTimes(2);
@@ -323,7 +323,7 @@ describe("traverse", () => {
323323
};
324324
schema.properties.foo.items[0].items = schema;
325325
const mockMutation = jest.fn((s) => s);
326-
traverse(schema, mockMutation);
326+
traverse(schema as JSONSchema, mockMutation);
327327
expect(mockMutation).toHaveBeenCalledTimes(3);
328328
});
329329

@@ -351,7 +351,7 @@ describe("traverse", () => {
351351
};
352352
schema.properties.foo.anyOf[0].items.properties.baz = schema.properties.foo;
353353
const mockMutation = jest.fn((s) => s);
354-
traverse(schema, mockMutation);
354+
traverse(schema as JSONSchema, mockMutation);
355355
expect(mockMutation).toHaveBeenCalledTimes(4);
356356
});
357357

@@ -387,7 +387,7 @@ describe("traverse", () => {
387387
schema.properties.foo.anyOf[0].items.properties.baz = schema;
388388
schema.properties.bar.allOf[0].properties.baz = schema.properties.foo.anyOf[0];
389389
const mockMutation = jest.fn((s) => s);
390-
traverse(schema, mockMutation);
390+
traverse(schema as JSONSchema, mockMutation);
391391
expect(mockMutation).toHaveBeenCalledTimes(6);
392392
});
393393

@@ -471,7 +471,7 @@ describe("traverse", () => {
471471
};
472472
schema.properties.foo.anyOf[0].items.properties.baz = schema.properties.foo;
473473
const mockMutation = jest.fn((s) => s);
474-
traverse(schema, mockMutation);
474+
traverse(schema as JSONSchema, mockMutation);
475475
expect(mockMutation).toHaveBeenCalledTimes(4);
476476
});
477477

@@ -550,7 +550,7 @@ describe("traverse", () => {
550550

551551
const mockMutation = jest.fn((mockS) => mockS);
552552

553-
traverse(testSchema, mockMutation, { mutable: true });
553+
traverse(testSchema as JSONSchema, mockMutation, { mutable: true });
554554

555555
expect(mockMutation).toHaveBeenCalledWith(testSchema.properties.foo, true, "/properties/foo");
556556
expect(mockMutation).not.toHaveBeenCalledWith(testSchema.properties.foo, false, "/properties/foo");
@@ -568,7 +568,7 @@ describe("traverse", () => {
568568

569569
const mockMutation = jest.fn((mockS) => mockS);
570570

571-
traverse(testSchema, mockMutation, { mutable: true });
571+
traverse(testSchema as JSONSchema, mockMutation, { mutable: true });
572572

573573
expect(mockMutation).toHaveBeenCalledWith(testSchema, true, "");
574574
expect(mockMutation).not.toHaveBeenCalledWith(testSchema, false, "");
@@ -589,7 +589,7 @@ describe("traverse", () => {
589589

590590
const mockMutation = jest.fn((mockS) => mockS);
591591

592-
traverse(testSchema, mockMutation, { mutable: false });
592+
traverse(testSchema as JSONSchema, mockMutation, { mutable: false });
593593

594594
expect(mockMutation).toHaveBeenCalledWith(testSchema, true, "");
595595
expect(mockMutation).not.toHaveBeenCalledWith(testSchema, false, "");
@@ -612,7 +612,7 @@ describe("traverse", () => {
612612
};
613613
const mockMutation = jest.fn((mockS) => mockS);
614614

615-
traverse(testSchema, mockMutation, { bfs: true, });
615+
traverse(testSchema as JSONSchema, mockMutation, { bfs: true, });
616616

617617
const expectedPath1 = "/properties/foo/items/0";
618618
const expectedPath2 = "/properties/foo/items/1";
@@ -637,7 +637,7 @@ describe("traverse", () => {
637637
};
638638
const mockMutation = jest.fn((mockS) => mockS);
639639

640-
traverse(testSchema, mockMutation, { bfs: true, mutable: true });
640+
traverse(testSchema as JSONSchema, mockMutation, { bfs: true, mutable: true });
641641

642642
const expectedPath1 = "/properties/foo/items/0";
643643
const expectedPath2 = "/properties/foo/items/1";
@@ -657,7 +657,7 @@ describe("Mutability settings", () => {
657657
foo: { type: "string" },
658658
bar: { type: "number" }
659659
}
660-
};
660+
} as JSONSchema;
661661

662662
const frozenS = Object.freeze(s);
663663

@@ -681,7 +681,7 @@ describe("Mutability settings", () => {
681681

682682
const frozenS = Object.freeze(s);
683683

684-
const result = traverse(frozenS, (ss) => ss, { mutable: false }) as JSONSchemaObject;
684+
const result = traverse(frozenS as JSONSchema, (ss) => ss, { mutable: false }) as JSONSchemaObject;
685685

686686
expect(frozenS).not.toBe(result);
687687
expect((result.properties as Properties).foo).toBe(result);
@@ -700,7 +700,7 @@ describe("Mutability settings", () => {
700700

701701
const frozenS = Object.freeze(s);
702702

703-
const result = traverse(frozenS, (ss) => ss, { mutable: false, skipFirstMutation: true }) as JSONSchemaObject;
703+
const result = traverse(frozenS as JSONSchema, (ss) => ss, { mutable: false, skipFirstMutation: true }) as JSONSchemaObject;
704704

705705
expect(frozenS).not.toBe(result);
706706
expect((result.properties as Properties).foo).not.toBe(frozenS.properties.foo);
@@ -723,7 +723,7 @@ describe("Mutability settings", () => {
723723

724724
const frozenS = Object.freeze(s);
725725

726-
const result = traverse(frozenS, (ss) => {
726+
const result = traverse(frozenS as JSONSchema, (ss) => {
727727
if (ss === true || ss === false) { return ss; }
728728
return { hello: "world", ...ss };
729729
}, { mutable: false, bfs: true }) as JSONSchemaObject;
@@ -754,7 +754,7 @@ describe("Mutability settings", () => {
754754

755755
const frozenS = Object.freeze(s);
756756

757-
const result = traverse(frozenS, (ss) => {
757+
const result = traverse(frozenS as JSONSchema, (ss) => {
758758
if (ss === true || ss === false) { return ss; }
759759
return { hello: "world", ...ss };
760760
}, { mutable: false, bfs: true, skipFirstMutation: true }) as JSONSchemaObject;
@@ -781,7 +781,7 @@ describe("Mutability settings", () => {
781781
s.properties.foo = s;
782782

783783

784-
const result = traverse(s, (ss) => ss, { mutable: true }) as JSONSchemaObject;
784+
const result = traverse(s as JSONSchema, (ss) => ss, { mutable: true }) as JSONSchemaObject;
785785

786786
expect(s).toBe(result);
787787
expect((result.properties as Properties).foo).toBe(result);
@@ -797,7 +797,7 @@ describe("Mutability settings", () => {
797797
}
798798
};
799799

800-
const result = traverse(s, (ss: any) => { ss.hello = "world"; return ss; }, { mutable: true, skipFirstMutation: true }) as JSONSchemaObject;
800+
const result = traverse(s as JSONSchema, (ss: any) => { ss.hello = "world"; return ss; }, { mutable: true, skipFirstMutation: true }) as JSONSchemaObject;
801801

802802
expect(s).toBe(result);
803803
expect((s as any).hello).not.toBeDefined();
@@ -812,14 +812,12 @@ describe("Mutability settings", () => {
812812
}
813813
};
814814

815-
const result = traverse(s, (ss: any) => { ss.hello = "world"; return ss; }, { mutable: true, bfs: true }) as JSONSchemaObject;
815+
const result = traverse(s as JSONSchema, (ss: any) => { ss.hello = "world"; return ss; }, { mutable: true, bfs: true }) as JSONSchemaObject;
816816

817817
expect(s).toBe(result);
818818
expect((s as any).hello).toBe("world");
819819
expect((s.properties.foo as any).hello).toBe("world")
820820
expect((result.properties as Properties).foo).toBe(s.properties.foo);
821821
});
822-
823822
});
824-
825823
});

0 commit comments

Comments
 (0)