@@ -27,23 +27,8 @@ import { SchemaVersions } from '../yamlTypes';
27
27
28
28
import { parse } from 'yaml' ;
29
29
import * as Json from 'jsonc-parser' ;
30
- import Ajv , { DefinedError } from 'ajv' ;
31
- import Ajv4 from 'ajv-draft-04' ;
32
30
import { getSchemaTitle } from '../utils/schemaUtils' ;
33
31
34
- const ajv = new Ajv ( ) ;
35
- const ajv4 = new Ajv4 ( ) ;
36
-
37
- // load JSON Schema 07 def to validate loaded schemas
38
- // eslint-disable-next-line @typescript-eslint/no-var-requires
39
- const jsonSchema07 = require ( 'ajv/dist/refs/json-schema-draft-07.json' ) ;
40
- const schema07Validator = ajv . compile ( jsonSchema07 ) ;
41
-
42
- // eslint-disable-next-line @typescript-eslint/no-var-requires
43
- const jsonSchema04 = require ( 'ajv-draft-04/dist/refs/json-schema-draft-04.json' ) ;
44
- const schema04Validator = ajv4 . compile ( jsonSchema04 ) ;
45
- const SCHEMA_04_URI_WITH_HTTPS = ajv4 . defaultMeta ( ) . replace ( 'http://' , 'https://' ) ;
46
-
47
32
export declare type CustomSchemaProvider = ( uri : string ) => Promise < string | string [ ] > ;
48
33
49
34
export enum MODIFICATION_ACTIONS {
@@ -169,16 +154,12 @@ export class YAMLSchemaService extends JSONSchemaService {
169
154
let schema : JSONSchema = schemaToResolve . schema ;
170
155
const contextService = this . contextService ;
171
156
172
- const validator =
173
- this . normalizeId ( schema . $schema ) === ajv4 . defaultMeta ( ) || this . normalizeId ( schema . $schema ) === SCHEMA_04_URI_WITH_HTTPS
174
- ? schema04Validator
175
- : schema07Validator ;
176
- if ( ! validator ( schema ) ) {
177
- const errs : string [ ] = [ ] ;
178
- for ( const err of validator . errors as DefinedError [ ] ) {
179
- errs . push ( `${ err . instancePath } : ${ err . message } ` ) ;
180
- }
181
- resolveErrors . push ( `Schema '${ getSchemaTitle ( schemaToResolve . schema , schemaURL ) } ' is not valid:\n${ errs . join ( '\n' ) } ` ) ;
157
+ // Basic schema validation - check if schema is a valid object
158
+ if ( typeof schema !== 'object' || schema === null || Array . isArray ( schema ) ) {
159
+ const invalidSchemaType = Array . isArray ( schema ) ? 'array' : typeof schema ;
160
+ resolveErrors . push (
161
+ `Schema '${ getSchemaTitle ( schemaToResolve . schema , schemaURL ) } ' is not valid:\nWrong schema: "${ invalidSchemaType } ", it MUST be an Object or Boolean`
162
+ ) ;
182
163
}
183
164
184
165
const findSection = ( schema : JSONSchema , path : string ) : JSONSchema => {
0 commit comments