Skip to content

Commit dfe1cc7

Browse files
feat: examples completion for propertyNames
1 parent 8a95a7a commit dfe1cc7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/services/jsonCompletion.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ export class JSONCompletion {
289289
propertyNameCompletionItem(schemaPropertyNames.enum[i], enumDescription, enumDetails, enumSortText);
290290
}
291291
}
292+
if (schemaPropertyNames.examples) {
293+
for (let i = 0; i < schemaPropertyNames.examples.length; i++) {
294+
propertyNameCompletionItem(schemaPropertyNames.examples[i], undefined, undefined, undefined);
295+
}
296+
}
292297
if (schemaPropertyNames.const) {
293298
propertyNameCompletionItem(schemaPropertyNames.const, undefined, schemaPropertyNames.completionDetail, schemaPropertyNames.suggestSortText);
294299
}

src/test/completion.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,12 @@ suite('JSON Completion', () => {
333333
enum: ['a', 'b'],
334334
enumSortTexts: ['2', '1'],
335335
},
336+
},
337+
examples: {
338+
type: 'object',
339+
propertyNames: {
340+
examples: ['a', 'b'],
341+
},
336342
}
337343
}
338344
};
@@ -381,6 +387,12 @@ suite('JSON Completion', () => {
381387
{ label: 'b', sortText: "1" },
382388
]
383389
});
390+
await testCompletionsFor('{"examples":{|}}', schema, {
391+
items: [
392+
{ label: 'a' },
393+
{ label: 'b' },
394+
]
395+
});
384396
});
385397

386398
test('Complete value with schema', async function () {

0 commit comments

Comments
 (0)