Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additionalProperties do not work #28

Open
mkaut opened this issue Apr 24, 2019 · 3 comments
Open

additionalProperties do not work #28

mkaut opened this issue Apr 24, 2019 · 3 comments

Comments

@mkaut
Copy link

mkaut commented Apr 24, 2019

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...

@RicoSuter
Copy link
Owner

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 :-)

@mkaut
Copy link
Author

mkaut commented May 10, 2019

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?

@RicoSuter
Copy link
Owner

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

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

No branches or pull requests

2 participants