coreDataToUpdate error when dynamically changing the JSON Schema

Hi,

I’m writing a JSON Schema editor component for my vue/vuetify app. My initial JSON Schema has an “$id” property. Whenever I change something in the schema, I get the following error in the console:

Error in callback for watcher "coreDataToUpdate":
Error: schema with key or id "https://...[redacted]..." already exists

If I remove the $id from my schema, the issue is solved. I guess that JsonForms recreates a random id when none is present? Anyway, removing $id from my schema doesn’t seems a bit hackerish. Are there cleaner solutions?

Thanks

Hi @kobbejager,

This issue occurs because of our usage of AJV. By default AJV is stateful and caches schemas according to their $id. So when another schema object with the same $id is encountered it throws an error. We already handle most of these cases within the JSON Forms code by removing the schema from the AJV cache before recompiling. We either missed a case or you are using a custom AJV which is already prefilled.

Removing the $id before handing the schema over to JSON Forms is certainly fine. An alternative could be to give the JSON Forms component a key to reinitialize it whenever your schema changes.