@tsofist/schema-forge 2.5.1 → 2.6.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/lib/generator.spec.js +11 -15
- package/package.json +6 -6
package/lib/generator.spec.js
CHANGED
|
@@ -95,7 +95,7 @@ describe('validator for a7', () => {
|
|
|
95
95
|
expect(initial).toStrictEqual(2);
|
|
96
96
|
validator.warmupCacheSync();
|
|
97
97
|
const warmed = validator.compilationArtifactCount;
|
|
98
|
-
expect(warmed).toStrictEqual(
|
|
98
|
+
expect(warmed).toStrictEqual(9);
|
|
99
99
|
validator.clear();
|
|
100
100
|
const cleared = validator.compilationArtifactCount;
|
|
101
101
|
expect(cleared).toStrictEqual(1);
|
|
@@ -471,7 +471,8 @@ describe('generator for a1', () => {
|
|
|
471
471
|
expect(forgeSchemaResult.refs.length).toStrictEqual(10);
|
|
472
472
|
});
|
|
473
473
|
it('getSchema', () => {
|
|
474
|
-
expect(validator.getValidator('test#/definitions/
|
|
474
|
+
expect(validator.getValidator('test#/definitions/PositiveInt').schema).toStrictEqual({
|
|
475
|
+
minimum: 1,
|
|
475
476
|
type: 'integer',
|
|
476
477
|
});
|
|
477
478
|
expect(validator.getValidator('#/definitions/NotExists')).toStrictEqual(undefined);
|
|
@@ -486,14 +487,16 @@ describe('generator for a1', () => {
|
|
|
486
487
|
});
|
|
487
488
|
});
|
|
488
489
|
it('hasSchema', () => {
|
|
489
|
-
expect(validator.hasValidator('test#/definitions/
|
|
490
|
+
expect(validator.hasValidator('test#/definitions/SomeType1')).toStrictEqual(true);
|
|
491
|
+
expect(validator.hasValidator('test#/definitions/PositiveInt')).toStrictEqual(true);
|
|
492
|
+
expect(validator.hasValidator('test#/definitions/Int')).toStrictEqual(false);
|
|
490
493
|
expect(validator.hasValidator('test#/definitions/!Int')).toStrictEqual(false);
|
|
491
494
|
});
|
|
492
495
|
it('checkBySchema', () => {
|
|
493
496
|
expect(() => validator.checkBySchema('test#/definitions/ExportedInterfaceB_InterfaceDeclaration', {})).toThrow(types_1.SchemaForgeValidationErrorCode);
|
|
494
|
-
expect(validator.checkBySchema('test#/definitions/
|
|
495
|
-
expect(() => validator.checkBySchema('test#/definitions/
|
|
496
|
-
expect(() => validator.checkBySchema('!test#/definitions/
|
|
497
|
+
expect(validator.checkBySchema('test#/definitions/PositiveInt', 1)).toStrictEqual(true);
|
|
498
|
+
expect(() => validator.checkBySchema('test#/definitions/PositiveInt', 1.1)).toThrow(types_1.SchemaForgeValidationErrorCode);
|
|
499
|
+
expect(() => validator.checkBySchema('!test#/definitions/PositiveInt', 1)).toThrow(types_1.SchemaNotFoundErrorCode);
|
|
497
500
|
{
|
|
498
501
|
const schema = '!test#/definitions/Int';
|
|
499
502
|
try {
|
|
@@ -510,7 +513,7 @@ describe('generator for a1', () => {
|
|
|
510
513
|
}
|
|
511
514
|
}
|
|
512
515
|
{
|
|
513
|
-
const schema = 'test#/definitions/
|
|
516
|
+
const schema = 'test#/definitions/PositiveInt';
|
|
514
517
|
const message = 'ERROR!';
|
|
515
518
|
try {
|
|
516
519
|
validator.checkBySchema(schema, 1.1, { errorMessage: message });
|
|
@@ -568,13 +571,6 @@ describe('generator for a1', () => {
|
|
|
568
571
|
interface: 'ExportedInterfaceB',
|
|
569
572
|
method: 'methodB',
|
|
570
573
|
},
|
|
571
|
-
{
|
|
572
|
-
ref: 'test#/definitions/Int',
|
|
573
|
-
kind: 0,
|
|
574
|
-
name: 'Int',
|
|
575
|
-
schemaId: 'test',
|
|
576
|
-
type: 'Int',
|
|
577
|
-
},
|
|
578
574
|
{
|
|
579
575
|
ref: 'test#/definitions/NonExportedInterfaceD_InterfaceDeclaration',
|
|
580
576
|
kind: 1,
|
|
@@ -625,7 +621,7 @@ describe('generator for a1', () => {
|
|
|
625
621
|
defsByName[def.name] = def;
|
|
626
622
|
}
|
|
627
623
|
expect(validator.listDefinitions()).toStrictEqual(defs);
|
|
628
|
-
expect(validator.listDefinitions((info) => info.kind === types_1.SchemaDefinitionKind.Type && !info.name.startsWith('Some'))).toStrictEqual([defsByName['
|
|
624
|
+
expect(validator.listDefinitions((info) => info.kind === types_1.SchemaDefinitionKind.Type && !info.name.startsWith('Some'))).toStrictEqual([defsByName['PositiveInt']]);
|
|
629
625
|
expect(validator.listDefinitions((info) => info.kind === types_1.SchemaDefinitionKind.API)).toStrictEqual([
|
|
630
626
|
defsByName['ExportedInterfaceB_InterfaceDeclaration'],
|
|
631
627
|
defsByName['NonExportedInterfaceD_InterfaceDeclaration'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsofist/schema-forge",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Generate JSON schema from TypeScript types",
|
|
5
5
|
"author": "Andrew Berdnikov <tsofistgudmen@gmail.com>",
|
|
6
6
|
"license": "LGPL-3.0",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@faker-js/faker": "^9.6.0",
|
|
24
|
-
"@tsofist/stem": "^
|
|
24
|
+
"@tsofist/stem": "^3.0.2",
|
|
25
25
|
"ajv": "^8.17.1",
|
|
26
26
|
"ajv-formats": "^3.0.1",
|
|
27
|
-
"json-schema-faker": "^0.5.
|
|
27
|
+
"json-schema-faker": "^0.5.9",
|
|
28
28
|
"jsonpath-plus": "^10.3.0",
|
|
29
29
|
"ts-json-schema-generator": "~2.3.0",
|
|
30
30
|
"tslib": "^2.8.1"
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@tsofist/web-buddy": "^1.21.0",
|
|
34
34
|
"@types/jest": "^29.5.14",
|
|
35
|
-
"@types/node": "^20.17.
|
|
35
|
+
"@types/node": "^20.17.30",
|
|
36
36
|
"@types/supertest": "^6.0.3",
|
|
37
37
|
"jest": "^29.7.0",
|
|
38
38
|
"rimraf": "^6.0.1",
|
|
39
39
|
"supertest": "^7.1.0",
|
|
40
|
-
"ts-jest": "^29.3.
|
|
41
|
-
"typescript": "~5.8.
|
|
40
|
+
"ts-jest": "^29.3.1",
|
|
41
|
+
"typescript": "~5.8.3"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"registry": "https://registry.npmjs.org/",
|