[wp-trac] [WordPress Trac] #51911: REST API: Make JSON Schema enum more robust for non-string types

WordPress Trac noreply at wordpress.org
Sun Jan 24 16:50:54 UTC 2021


#51911: REST API: Make JSON Schema enum more robust for non-string types
-------------------------------------------------+-------------------------
 Reporter:  TimothyBlynJacobs                    |       Owner:
                                                 |  TimothyBlynJacobs
     Type:  enhancement                          |      Status:  closed
 Priority:  normal                               |   Milestone:  5.7
Component:  REST API                             |     Version:  4.7
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  good-first-bug json-schema has-      |     Focuses:
  patch has-unit-tests                           |
-------------------------------------------------+-------------------------
Changes (by TimothyBlynJacobs):

 * owner:  (none) => TimothyBlynJacobs
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"50010" 50010]:
 {{{
 #!CommitTicketReference repository="" revision="50010"
 REST API: Support type coercion when validating the `enum` JSON Schema
 keyword.

 Previously, the `enum` keyword was validated by perform a strict equality
 check. For `string` types this is generally ok, but it prevented using
 alternative types like `number` when rich type support isn't available.

 Now the same level of type coercion/sanitization is applied when
 validating `enum` as all other validation checks. This means that a value
 of `"1"` will be accepted for an `enum` of `[ 0, 1 ]`. Additionally,
 `object` types now properly ignore key order when checking for equality.

 Props yakimun.
 Fixes #51911.
 }}}

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


More information about the wp-trac mailing list