[wp-trac] [WordPress Trac] #51025: Add support for the anyOf and oneOf JSON Schema keywords.

WordPress Trac noreply at wordpress.org
Sat Aug 15 15:06:44 UTC 2020


#51025: Add support for the anyOf and oneOf JSON Schema keywords.
-------------------------------------------------+-------------------------
 Reporter:  TimothyBlynJacobs                    |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  5.6
Component:  REST API                             |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  needs-patch needs-unit-tests json-   |     Focuses:
  schema                                         |
-------------------------------------------------+-------------------------

Comment (by TimothyBlynJacobs):

 For schemas like the example that have a property in common that is used
 to disambiguate, we could solve this by introducing a keyword that would
 signify that property. But that would really only work for these `switch`
 type schemas.

 A more generic approach might be to do something like this:

 1. Discard schemas that don't match the type.
 2. For objects, find the schema that has the most properties in common.
 3. Find the schema that has the most keywords that validate.

 We can also mandate that each schema in the `oneOf` array has a `title`
 set. That way we can at least give an error message like "x is not a valid
 Rotation or Crop".

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51025#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list