diff --git a/src/services/configuration.ts b/src/services/configuration.ts index 59489e87..8656b613 100644 --- a/src/services/configuration.ts +++ b/src/services/configuration.ts @@ -10,10 +10,6 @@ import * as l10n from '@vscode/l10n'; export const schemaContributions: ISchemaContributions = { schemaAssociations: [], schemas: { - // refer to the latest schema - 'http://json-schema.org/schema#': { - $ref: 'http://json-schema.org/draft-07/schema#' - }, // bundle the schema-schema to include (localized) descriptions 'http://json-schema.org/draft-04/schema#': { '$schema': 'http://json-schema.org/draft-04/schema#', diff --git a/src/services/jsonCompletion.ts b/src/services/jsonCompletion.ts index fc592779..90d4c9fc 100644 --- a/src/services/jsonCompletion.ts +++ b/src/services/jsonCompletion.ts @@ -733,13 +733,18 @@ export class JSONCompletion { private addDollarSchemaCompletions(separatorAfter: string, collector: CompletionsCollector): void { const schemaIds = this.schemaService.getRegisteredSchemaIds(schema => schema === 'http' || schema === 'https'); - schemaIds.forEach(schemaId => collector.add({ - kind: CompletionItemKind.Module, - label: this.getLabelForValue(schemaId), - filterText: this.getFilterTextForValue(schemaId), - insertText: this.getInsertTextForValue(schemaId, separatorAfter), - insertTextFormat: InsertTextFormat.Snippet, documentation: '' - })); + schemaIds.forEach(schemaId => { + if (schemaId.startsWith('http://json-schema.org/draft-')) { + schemaId = schemaId + '#'; + } + collector.add({ + kind: CompletionItemKind.Module, + label: this.getLabelForValue(schemaId), + filterText: this.getFilterTextForValue(schemaId), + insertText: this.getInsertTextForValue(schemaId, separatorAfter), + insertTextFormat: InsertTextFormat.Snippet, documentation: '' + }); + }); } private getLabelForValue(value: any): string { diff --git a/src/test/completion.test.ts b/src/test/completion.test.ts index a88f1736..dc9a825e 100644 --- a/src/test/completion.test.ts +++ b/src/test/completion.test.ts @@ -1078,7 +1078,9 @@ suite('JSON Completion', () => { }); await testCompletionsFor('{ "$schema": | }', schema, { items: [ - { label: '"http://myschemastore/test1"', resultText: '{ "$schema": "http://myschemastore/test1" }' } + { label: '"http://myschemastore/test1"', resultText: '{ "$schema": "http://myschemastore/test1" }' }, + { label: '"http://json-schema.org/draft-04/schema#"', resultText: '{ "$schema": "http://json-schema.org/draft-04/schema#" }' }, + { label: '"http://json-schema.org/draft-07/schema#"', resultText: '{ "$schema": "http://json-schema.org/draft-07/schema#" }' } ] }); await testCompletionsFor('{ "$schema": "|', schema, {