@@ -4,20 +4,23 @@ import * as PropertyKeyToCompletionOption from '../PropertyKeyToCompletionOption
4
4
import * as ResolveSchemaRef from '../ResolveSchemaRef/ResolveSchemaRef.ts'
5
5
import type { JsonSchema } from '../JsonSchema/JsonSchema.ts'
6
6
7
- const getSchemaProperties = ( schema : JsonSchema ) : JsonSchema [ 'properties' ] => {
7
+ const getSchemaProperties = (
8
+ rootSchema : JsonSchema ,
9
+ schema : JsonSchema ,
10
+ ) : JsonSchema [ 'properties' ] => {
8
11
if ( schema . properties ) {
9
12
return schema . properties
10
13
}
11
14
12
15
if ( schema . $ref ) {
13
- const resolved = ResolveSchemaRef . resolveSchemaRef ( schema , schema . $ref )
14
- return resolved . properties || { }
16
+ const resolved = ResolveSchemaRef . resolveSchemaRef ( rootSchema , schema . $ref )
17
+ return getSchemaProperties ( rootSchema , resolved )
15
18
}
16
19
17
20
if ( schema . allOf ) {
18
21
const properties : { [ key : string ] : JsonSchema } = { }
19
22
for ( const subSchema of schema . allOf ) {
20
- const subProperties = getSchemaProperties ( subSchema )
23
+ const subProperties = getSchemaProperties ( rootSchema , subSchema )
21
24
Object . assign ( properties , subProperties )
22
25
}
23
26
return properties
@@ -26,7 +29,7 @@ const getSchemaProperties = (schema: JsonSchema): JsonSchema['properties'] => {
26
29
if ( schema . anyOf ) {
27
30
const properties : { [ key : string ] : JsonSchema } = { }
28
31
for ( const subSchema of schema . anyOf ) {
29
- const subProperties = getSchemaProperties ( subSchema )
32
+ const subProperties = getSchemaProperties ( rootSchema , subSchema )
30
33
Object . assign ( properties , subProperties )
31
34
}
32
35
return properties
@@ -39,7 +42,7 @@ export const jsonCompletionProperty = (
39
42
schema : JsonSchema ,
40
43
node : AstNode ,
41
44
) : readonly CompletionItem [ ] => {
42
- const properties = getSchemaProperties ( schema )
45
+ const properties = getSchemaProperties ( schema , schema )
43
46
const keys = Object . keys ( properties || { } )
44
47
return keys . map ( PropertyKeyToCompletionOption . propertyKeyToCompletionOption )
45
48
}
0 commit comments