VisualJsonEditor icon indicating copy to clipboard operation
VisualJsonEditor copied to clipboard

additionalProperties do not work

Open mkaut opened this issue 7 years ago • 3 comments

The following example (taken from https://cswr.github.io/JsonSchema/spec/objects/) does not work:

{
	"type": "object",
	"properties": {
		"first_name": {"type": "string"},
		"last_name": {"type": "string"}
	},
	"additionalProperties": {
		"type": "integer"
	}
}
{
	"first_name": "Gary",
	"last_name": "Medel",
	"age": 25
}

The file is correctly validated, but the "age" property is not shown in the editor, and neither is it possible to add new properties (allowed by the schema). Also, if I change "age" to "25" (a string), the JSON is still validated, even if it is invalid. It even validates with additionalProperties: false... In other words, it looks like the additionalProperties keyword is ignored in the schema. I have also tested patternProperties and it does not work either,

I could understand if you did not want to have additional properties in the editor (since without additionalProperties: false, one can add anything anywhere), but it would be nice if the validating worked correctly and also if the already present (and valid) keys we shown in the editor...

mkaut avatar Apr 24 '19 08:04 mkaut

I think validation should work as expected as this is not part of VJE, but the UI does not yet support all JSON Schema features... but I accept PRs :-)

RicoSuter avatar Apr 24 '19 08:04 RicoSuter

I am not sure what you mean by "should work", but the validation clearly does not work, since it validates files that break the additionalProperties or patternProperties requirements. If the validation is not part of VJE, can you file a bug upstream?

mkaut avatar May 10 '19 13:05 mkaut

since it validates files that break the additionalProperties or patternProperties requirements

That’s probably because they are loaded into the ui model and then the data gets lost when converting the ui model back for validation...

See also: http://njsonschema.org

RicoSuter avatar May 10 '19 16:05 RicoSuter