@@ -109,17 +109,16 @@ export class YAMLSchemaService extends JSONSchemaService {
109
109
this . customSchemaProvider = customSchemaProvider ;
110
110
}
111
111
112
- public resolveSchemaContent (
112
+ async resolveSchemaContent (
113
113
schemaToResolve : UnresolvedSchema ,
114
114
schemaURL : string ,
115
115
dependencies : SchemaDependencies
116
116
) : Promise < ResolvedSchema > {
117
117
const resolveErrors : string [ ] = schemaToResolve . errors . slice ( 0 ) ;
118
- const schema = schemaToResolve . schema ;
118
+ let schema = schemaToResolve . schema ;
119
119
const contextService = this . contextService ;
120
120
121
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
122
- const findSection = ( schema : JSONSchema , path : string ) : any => {
121
+ const findSection = ( schema : JSONSchema , path : string ) : JSONSchema => {
123
122
if ( ! path ) {
124
123
return schema ;
125
124
}
@@ -176,15 +175,15 @@ export class YAMLSchemaService extends JSONSchemaService {
176
175
} ) ;
177
176
} ;
178
177
179
- const resolveRefs = (
178
+ const resolveRefs = async (
180
179
node : JSONSchema ,
181
180
parentSchema : JSONSchema ,
182
181
parentSchemaURL : string ,
183
182
parentSchemaDependencies : SchemaDependencies
184
183
// eslint-disable-next-line @typescript-eslint/no-explicit-any
185
184
) : Promise < any > => {
186
185
if ( ! node || typeof node !== 'object' ) {
187
- return Promise . resolve ( null ) ;
186
+ return null ;
188
187
}
189
188
190
189
const toWalk : JSONSchema [ ] = [ node ] ;
@@ -260,7 +259,17 @@ export class YAMLSchemaService extends JSONSchemaService {
260
259
if ( parentSchemaURL . indexOf ( '#' ) > 0 ) {
261
260
const segments = parentSchemaURL . split ( '#' , 2 ) ;
262
261
if ( segments [ 0 ] . length > 0 && segments [ 1 ] . length > 0 ) {
263
- openPromises . push ( resolveExternalLink ( node , segments [ 0 ] , segments [ 1 ] , parentSchemaURL , parentSchemaDependencies ) ) ;
262
+ const newSchema = { } ;
263
+ await resolveExternalLink ( newSchema , segments [ 0 ] , segments [ 1 ] , parentSchemaURL , parentSchemaDependencies ) ;
264
+ for ( const key in schema ) {
265
+ if ( key === 'required' ) {
266
+ continue ;
267
+ }
268
+ if ( Object . prototype . hasOwnProperty . call ( schema , key ) && ! Object . prototype . hasOwnProperty . call ( newSchema , key ) ) {
269
+ newSchema [ key ] = schema [ key ] ;
270
+ }
271
+ }
272
+ schema = newSchema ;
264
273
}
265
274
}
266
275
@@ -275,9 +284,8 @@ export class YAMLSchemaService extends JSONSchemaService {
275
284
return Promise . all ( openPromises ) ;
276
285
} ;
277
286
278
- return resolveRefs ( schema , schema , schemaURL , dependencies ) . then ( ( ) => {
279
- return new ResolvedSchema ( schema , resolveErrors ) ;
280
- } ) ;
287
+ await resolveRefs ( schema , schema , schemaURL , dependencies ) ;
288
+ return new ResolvedSchema ( schema , resolveErrors ) ;
281
289
}
282
290
283
291
public getSchemaForResource ( resource : string , doc : JSONDocument ) : Promise < ResolvedSchema > {
0 commit comments