mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
refactor: update all
This commit is contained in:
committed by
Rainer Killinger
parent
8cf40900bb
commit
0ca252b221
@@ -24,6 +24,7 @@ import {definitionsOf} from './easy-ast/ast-util';
|
||||
import {lightweightProjectFromPath} from './easy-ast/easy-ast';
|
||||
import {isSchemaWithDefinitions} from './util/guards';
|
||||
import path from 'path';
|
||||
import re2 from './types/re2';
|
||||
|
||||
/**
|
||||
* StAppsCore converter
|
||||
@@ -65,7 +66,7 @@ export class Converter {
|
||||
this.generator = new SchemaGenerator(program, createParser(program, config), createFormatter(config));
|
||||
|
||||
// create Ajv instance
|
||||
this.schemaValidator = new Ajv();
|
||||
this.schemaValidator = new Ajv({code: {regExp: re2}});
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires,unicorn/prefer-module
|
||||
this.schemaValidator.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));
|
||||
}
|
||||
|
||||
6
src/types/re2.ts
Normal file
6
src/types/re2.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import re2 from 're2';
|
||||
|
||||
type Re2 = typeof re2 & {code: string};
|
||||
(re2 as Re2).code = 'require("lib/types/re2").default';
|
||||
|
||||
export default re2 as Re2;
|
||||
@@ -23,6 +23,7 @@ import {globPromisified, readFilePromisified, writeFilePromisified} from './comm
|
||||
import {ExpectedValidationErrors, ValidationError, ValidationResult} from './types/validator';
|
||||
import {isThingWithType} from './util/guards';
|
||||
import path from 'path';
|
||||
import re2 from './types/re2';
|
||||
|
||||
/**
|
||||
* StAppsCore validator
|
||||
@@ -31,7 +32,11 @@ export class Validator {
|
||||
/**
|
||||
* JSON Schema Validator
|
||||
*/
|
||||
private readonly ajv = new Ajv({verbose: true});
|
||||
private readonly ajv = new Ajv({
|
||||
verbose: true,
|
||||
ignoreKeywordsWithRef: true,
|
||||
code: {regExp: re2},
|
||||
});
|
||||
|
||||
/**
|
||||
* Map of schema names to schemas
|
||||
@@ -133,7 +138,7 @@ function fromAjvResult(
|
||||
const betterErrorObject: betterAjvErrors.IOutputError[] | undefined = betterAjvErrors(
|
||||
schema,
|
||||
instance,
|
||||
ajvInstance.errors,
|
||||
ajvInstance.errors ?? [],
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
{format: 'js', indent: null},
|
||||
);
|
||||
@@ -145,10 +150,10 @@ function fromAjvResult(
|
||||
dataPath: ajvError.instancePath,
|
||||
instance: instance,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
||||
message: betterErrorObject?.[index].error!,
|
||||
message: betterErrorObject?.[index]?.error! ?? ajvError.message,
|
||||
name: ajvError.keyword,
|
||||
schemaPath: ajvError.schemaPath,
|
||||
suggestion: betterErrorObject?.[index].suggestion,
|
||||
suggestion: betterErrorObject?.[index]?.suggestion,
|
||||
};
|
||||
// (validationError as ValidationError).humanReadableError = betterErrorCLI?.[index] as unknown as string;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user