Closed justincy closed 7 years ago
I don't know how this would be possible without calculating the schema definition on the fly. Instead of exporting a static object we would export a method which calculates and returns the schema. It would have properties attached to it which expose the data types and the hierarchy in a pseudo json-schema.
An example of what I was thinking:
// Fetch the schema
gedxSchema();
// The psuedo-schema
gedxSchema.Subject = {
extends: 'Conclusion',
type: 'object',
properties: {...}
};
But that's actually not good enough. We would need to write the entire schema as a modified version with the extends
keyword that gets interpreted at runtime and transformed into valid schema.
Provide an easy way for GedcomX extensions to use this library as a base and add their schema.
The tricky part is being able to hook into the hierarchy. The schema definition is output as a static JSON object but it's calculated on load to allow for inheritance of properties: Subject copies the properties of Conclusion which copies the properties of ExtensibleData. Ideally extensions wouldn't have to modify all inheriting data types if they add properties to Conclusion.