@fincity/kirun-js 2.2.1 → 2.2.2
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/__tests__/engine/json/schema/validator/ArraySchemaAdapterTypeTest.ts +26 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/engine/json/schema/Schema.ts +6 -4
- package/src/engine/json/schema/type/TypeUtil.ts +17 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KIRunSchemaRepository, SchemaValidator } from '../../../../../src';
|
|
1
|
+
import { KIRunSchemaRepository, SchemaType, SchemaValidator } from '../../../../../src';
|
|
2
2
|
import { Schema } from '../../../../../src/engine/json/schema/Schema';
|
|
3
3
|
|
|
4
4
|
const repo = new KIRunSchemaRepository();
|
|
@@ -139,3 +139,28 @@ test('schemaArray With out Tuple Test ', async () => {
|
|
|
139
139
|
];
|
|
140
140
|
expect(await SchemaValidator.validate([], schema, repo, obj)).toBe(obj);
|
|
141
141
|
});
|
|
142
|
+
|
|
143
|
+
test('Regular JSON', async () => {
|
|
144
|
+
let schema = Schema.from({
|
|
145
|
+
type: 'object',
|
|
146
|
+
properties: {
|
|
147
|
+
productId: {
|
|
148
|
+
description: 'The unique identifier for a product',
|
|
149
|
+
type: 'integer',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
expect(schema?.getType()?.contains(SchemaType.OBJECT)).toBe(true);
|
|
155
|
+
expect(schema?.getType()?.contains(SchemaType.INTEGER)).toBe(false);
|
|
156
|
+
expect(schema?.getProperties()?.get('productId')?.getType()?.contains(SchemaType.INTEGER)).toBe(
|
|
157
|
+
true,
|
|
158
|
+
);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('Only Ref test', async () => {
|
|
162
|
+
let schema = Schema.from({ ref: 'System.any' });
|
|
163
|
+
|
|
164
|
+
expect(schema?.getType()).toBeUndefined();
|
|
165
|
+
expect(schema?.getRef()).toBe('System.any');
|
|
166
|
+
});
|