Generally, I’m very supportive of adding more structured metadata around data in WordPress. I’m also not a huge fan of P2 discussion threads (because P2 kinda sucks), so keep that in mind if I forget to reply to a comment / don’t get an email notification about a comment.
I think we should follow JSON Schema unless we make a deliberate, and intentional, reason not to. Following JSON Schema gives us access to all of the validation libraries already written, clients that can interpret it, etc. etc. Not following JSON Schema invents even more work for us, makes WP incompatible with existing tools that use JSON Schema, means we have to create a translation layer between this and the WP REST API, etc. etc. The mock code provided appears to mostly follow JSON Schema with a few unintentional (?) departures.
More specifically,
type
should always be one of a fixed set of values. Thewp-image
type would be more correctly expressed astype=>integer,format=>wp-image
. Or, we could define our ownrelation
attribute.The
options
attribute has an equivalent in JSON Schema:enum
Lastly,
repeatable
appears to be functionally equivalent totype=>array,items=>...
. I suppose we could include it as a utility attribute, but doing so adds complexity.[…]
Also worth mentioning: the problem of defining an application’s data models is one I’m sure many other CMSes, frameworks, etc. have worked on. It would be really good to apply their learnings and (try to) avoid their mistakes.
From “A data schema for meta“, aka a very important conversation on WordPress architecture.