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.
typeshould always be one of a fixed set of values. The
wp-imagetype would be more correctly expressed as
type=>integer,format=>wp-image. Or, we could define our own
optionsattribute has an equivalent in JSON Schema:
repeatableappears to be functionally equivalent to
type=>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.