diff --git a/src/compile/compile-type/compile-path.ts b/src/compile/compile-type/compile-path.ts index c8ae744..7b6820e 100644 --- a/src/compile/compile-type/compile-path.ts +++ b/src/compile/compile-type/compile-path.ts @@ -6,7 +6,8 @@ import cel from '../cel'; export default function(schema: JSONSchema7, ref: string): string { const map = cel.calc(ref, 'is', 'map'); - const withPath = cel.calc(cel.ref(ref, 'path'), 'is', 'string'); + const hasOnly = cel.call(cel.ref(cel.call(cel.ref(ref, 'keys')), 'hasOnly'), cel.val(['path'])); + const withPath = cel.calc(cel.ref(ref, 'path'), 'is', 'path') - return cel.calc(map, '&&', withPath); + return cel.calc(map, '&&', cel.calc(hasOnly, '&&', withPath)); } diff --git a/test/compile-type.test.ts b/test/compile-type.test.ts index 0a3403f..62c62a7 100644 --- a/test/compile-type.test.ts +++ b/test/compile-type.test.ts @@ -46,7 +46,7 @@ describe('type compilers', () => { assert.equal(compilePath({ definitions: { Path: {}}, $ref: '#/definitions/Path' - }, 'ref'), '((ref is map)&&(ref.path is string))'); + }, 'ref'), `((ref is map)&&(ref.keys().hasOnly(["path"])&&(ref.path is path)))`); }); });