[wp-trac] [WordPress Trac] #53828: Nullable registered meta with format does not display in JSON schema

WordPress Trac noreply at wordpress.org
Thu Jul 29 16:06:34 UTC 2021


#53828: Nullable registered meta with format does not display in JSON schema
----------------------------+-----------------------------
 Reporter:  chrisvanpatten  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  REST API        |    Version:
 Severity:  normal          |   Keywords:
  Focuses:  rest-api        |
----------------------------+-----------------------------
 When registering a piece of meta as a nullable type in the REST schema, it
 does not display in the JSON schema for the particular object.

 For example, the following will not correctly register a meta key in REST:

 {{{#!php
 <?php
 register_meta(
         'post',
         'backgroundColor',
         [
                 'single'       => true,
                 'type'         => 'string',
                 'show_in_rest' => [
                         'schema' => [
                                 'title'  => __( 'Background Color' ),
                                 'type'   => [ 'string', 'null' ],
                                 'format' => 'hex-color',
                         ],
                 ],
         ],
 );
 }}}

 The key will not be visible in the JSON schema, and the key/value pair
 will also not be available in the meta object in the post response from
 the API.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53828>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list