Skip to content

[json] Schema changes not reflected if schema file has jsonc extension. #184904

Open
@samunro

Description

Type: Bug

  1. Create a JSON Schema file (schema file) with the json extension and the following contents.
{
    "$schema": "http://json-schema.org/draft-07/schema",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "$schema": {
          "type": "string"
        },
        "test": {"type": "boolean"}
    }
}
  1. Create a second file (instance file) in the same folder with the json extension and the following contents.
{
    "$schema": "http://json-schema.org/draft-07/schema",
    "type": "object",
    "additionalProperties": false,
    "properties": {
        "$schema": {
          "type": "string"
        },
        "test": {"type": "boolean"}
    }
}
  1. Note that there are no problems in the instance file.
  2. Change the name of the property in the schema file from test to test1 and save.
  3. Note that there is now a problem in the instance file without having to reload Visual Studio Code.

"Property test is not allowed."

  1. Change the extension of the schema file and the reference to it in the instance file to json (instead of jsonc).
  2. Change the name of the property in the schema file from test1 back to test.
  3. Note that the problem in the instance file remains.

"Property test1 is not allowed."

  1. Restart Visual Studio Code.
  2. Note that there are no longer any problems in the instance file.

Visual Studio Code does appear to support JSON Schemas with the jsonc extension just like it does those with a json extension. Unlike schema files with the json extension though, those with the jsonc extension require a restart of Visual Studio Code to have changes relected in the validation of instance documents.

Note that this workaround also resulted in the schema changes being reflected.

https://stackoverflow.com/a/70175188/81595

VS Code version: Code 1.79.0 (b380da4, 2023-06-07T14:26:35.552Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 x 3592)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.95GB (11.72GB free)
Process Argv --crash-reporter-id 38b672a9-64ca-40e9-8060-3a52ff823ee1
Screen Reader no
VM 0%
Extensions (20)
Extension Author (truncated) Version
ng-template Ang 16.0.0
argutec-azure-repos arg 1.2007.15
vscode-eslint dba 2.4.0
githistory don 0.6.20
xml Dot 2.5.1
prettier-vscode esb 9.13.0
vscode-tfs gen 2.0.0
gitpod-desktop git 0.0.123
json-escaper jos 1.1.2
rainbow-csv mec 3.7.0
vscode-docker ms- 1.25.1
csharp ms- 1.25.9
remote-containers ms- 0.295.0
remote-ssh ms- 0.102.0
remote-ssh-edit ms- 0.86.0
remote-wsl ms- 0.79.4
powershell ms- 2023.6.0
remote-explorer ms- 0.4.0
copy-json-path nid 0.3.0
LiveServer rit 5.7.9
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes516:30244333
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
vscccc:30610679
282f8724:30602487
pyind779:30671433
89544117:30613380
pythonsymbol12:30671437
showlangstatbar:30737416
vsctsb:30748421
pythonms35:30701012
03d35959:30757346
pythonfmttext:30731395
pythoncmvfstrcf:30756944
fixhidewlkth:30730051
showsbindicator:30760979
pythongtdpathcf:30739705
dh2dc718:30763024

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugjsonJSON support issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions