inkandswitch / cambria-project

Schema evolution with bi-directional lenses.
MIT License
592 stars 24 forks source link

JSON Schema - use of allOf, oneOf #8

Open JYone3A opened 3 years ago

JYone3A commented 3 years ago

I'm thinking about using Cambria in a tool that already uses JSON Schema (CRUD tool for JSONs). However, things like allOf and oneOf are not supported (and will not be supported as they make things too complicated, in the code but also from the perspective of the created data structures).

I was wondering why those two things are used in the Cambria JSON schema.

allOf

If I understand correctly, this is used to first import the $ref and then set a custom title/description? Couldn't the title/description then just be set on the original $refd definition? Or will this probably be used in other places as well?

Also - and again I'm not sure - can't $ref be used to import parts of another schema? So instead of re-defining the basic JSON schema types, could the $ref not point directly to http://json-schema.org/draft-07/schema/definitions/simpleTypes? Although allOf would then definitely have to be used to set the title/description ...

oneOf

Instead of the oneOf in lensOp, couldn't just one big object be created with all the ops as keys? It would allow to add multiple, but distinct OPs in one step - but is that a problem? (not sure if some of the JSON schema validation rules could be used to prevent that, we're also not making use of those)