Skip to content

Commit 2dbd089

Browse files
clydinhansl
authored andcommitted
feat(@angular-devkit/core): add a schema for smart default keyword
1 parent d8a2ebc commit 2dbd089

File tree

1 file changed

+12
-9
lines changed
  • packages/angular_devkit/core/src/json/schema

1 file changed

+12
-9
lines changed

packages/angular_devkit/core/src/json/schema/registry.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,7 @@ export class CoreSchemaRegistry implements SchemaRegistry {
186186
// in synchronous (if available).
187187
let validator: Observable<ajv.ValidateFunction>;
188188
try {
189-
const maybeFnValidate = this._ajv.compile({
190-
$async: this._smartDefaultKeyword ? true : undefined,
191-
...schema,
192-
});
189+
const maybeFnValidate = this._ajv.compile(schema);
193190
validator = observableOf(maybeFnValidate);
194191
} catch (e) {
195192
// Propagate the error.
@@ -293,8 +290,8 @@ export class CoreSchemaRegistry implements SchemaRegistry {
293290
this._smartDefaultKeyword = true;
294291

295292
this._ajv.addKeyword('$default', {
296-
modifying: true,
297-
async: true,
293+
errors: false,
294+
valid: true,
298295
compile: (schema, _parentSchema, it) => {
299296
// We cheat, heavily.
300297
this._smartDefaultRecord.set(
@@ -303,9 +300,15 @@ export class CoreSchemaRegistry implements SchemaRegistry {
303300
schema,
304301
);
305302

306-
return function() {
307-
return Promise.resolve(true);
308-
};
303+
return () => true;
304+
},
305+
metaSchema: {
306+
type: 'object',
307+
properties: {
308+
'$source': { type: 'string' },
309+
},
310+
additionalProperties: true,
311+
required: [ '$source' ],
309312
},
310313
});
311314
}

0 commit comments

Comments
 (0)