monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

[Feature Request] Warn for properties marked `"deprecated": true` in JSON Schema

Open eggplants opened this issue 2 years ago • 5 comments

Context

  • [X] This issue is not a bug report. (please use a different template for reporting a bug)
  • [X] This issue is not a duplicate of an existing issue. (please use the search to find existing issues)

Description

Related?: #277

deprecated is introduced in json-schema Draft 2019-09. https://json-schema.org/draft/2019-09/release-notes.html#meta-data-vocabulary https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.3

I would like to warn deprecated properties marked "deprecated": true in JSON Schema like Property p1 is deprecated..

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.40.0#XQAAAAI3AwAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw3Ei00H9ZIu9-Fa32EzPTwY64-taCjCG3AffhHCYo3PV_ek3Ebg3AG4MZPGWACFnHSU7wDjf4MFRe32SXzHsq_-SzuU7of0BTs3KFauxbLfsiljHbMFtJ_atM7bbmCV5YlXRQSDOQuTdJXO9-pVc6PwBccNCSCXTi_9MTKiCqbBklhn5o22xcBujG6hAbkBvFrX0HNRHiW_rhOlSm-CdgNSSrP3jFVKFLJ6q2TtTCCqbvMsBma_1c3L8GRuSBKIKnmAF_W13B8NvHo0MimAFBYs6MzCpZBETT_xCvjNqTM1BaUDMsrcOBbV1-vZtPLaAdOSP1-k8qdQoBnx2j9Q1hcD8qjS6hixAyj92oJTIHXPBXyTSSPMHoqCFpG6Brb2U95v3qom6pCbZ5d0I0KIsEz9EnISh_1_ZUy-WCJ0iWhQnr3Ga4e9uVc1oXq60lLPsTMiTRk-w21DcXOJ4e44tqXv3eR68VzhMd7mKGCZO86Tu5yx94MYoFO15-QTQZBbEVLXH-T6OC2p_n_Pl3rXr3Vf0y4NGk_bN-WonPym52ANcBcmQqduDcMmrzpTa97jK5gogwIXIVeWi4SAgf_7pEVIA

Monaco Editor Playground Code

// Configures two JSON schemas, with references.

const jsonCode = ["{", '    "p1": "this-is-deprecated-property-value",', '    "p2": false', "}"].join("\n");
const modelUri = monaco.Uri.parse("a://b/foo.json");
const model = monaco.editor.createModel(jsonCode, "json", modelUri);

const schema = {
	$schema: "http://json-schema.org/draft/2020-12/schema#",
	type: "object",
	properties: {
		p1: {
			deprecated: true,
			type: [
				"string"
			]
		},
		p2: {
			type: [
				"boolean"
			]
		},
	},
}

monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
	validate: true,
	schemas: [
		{
			uri: "http://myserver/foo.schema.json",
			fileMatch: ["*"],
			schema,
		},
	],
});

monaco.editor.create(document.getElementById("container"), {
	model,
});

And I would like to warn:

{
    "p1": "this-is-deprecated-property-value",
    ^^^^
    "p2": false
}

eggplants avatar Aug 03 '23 16:08 eggplants

Hi. What is the state of this issue?

FacuLitterio avatar Sep 28 '23 22:09 FacuLitterio

This has been available in the json-languageservice for quite a while. @hediet We need to update the language service dependencies.

aeschli avatar Sep 29 '23 07:09 aeschli

@aeschli any chance of vscode-json-languageservice getting updated soon? Some of our end users are submitted schemas with draft 2020-22 and we cannot support them.

jrsquared avatar Nov 28 '23 22:11 jrsquared

@hediet would be great if you could update to the latest vscode-json-languageservice ...

aeschli avatar Nov 29 '23 09:11 aeschli

Same: https://github.com/microsoft/monaco-editor/issues/3625

aeschli avatar Nov 29 '23 09:11 aeschli