rodikh/angular-json-editor

"additionalProperties": false does not prevent adding new properties

Closed this issue · 6 comments

Setting "additionalProperties": false in the schema does not prevent adding new properties in the web interface. However, it invalidates the form, so the data can't be submitted. I can't find any way to delete the added property, except refreshing page, which will loose the form data.

I think the option you're looking for is the no_additional_properties option in the configuration.
it will prevent the property gui from adding fields.
as far as I am aware, the additionalProperties option is for the validation, not for the gui.

You are probably right. I just assumed that additionalProperties in the schema would be taken into account when the GUI was generated, but I suppose it shouldn't be taken for granted.

Thanks for pointing out the config parameter. That will be useful!

Actually, it would make sense to be able to remove accidentally added properties, under all circumstances, so I thought I'd reopen this issue.

Hey @perqa, sorry it took me a while to get around to this issue,
but can you explain your case?

If you set both additionalProperties to false and no_additional_properties to true, you shouldn't be able to accidentally add properties in the first place, and you shouldn't allow your user to remove any form field, required or not.

perqa commented

I see what you mean, but is there any point to have two different parameters for this? If additionalProperties is false, then no_additional_properties should always be true, right? So it could just as well be set automatically, or am I missing something?

That makes sense, but perhaps this is an issue for the original plugin's repository, as the purpose of this one is to wrap the functionality of the original in an angular directive, as-is.