[wp-trac] [WordPress Trac] #51020: minItems/maxItems not shown in argument schema

WordPress Trac noreply at wordpress.org
Sat Aug 15 12:52:47 UTC 2020


#51020: minItems/maxItems not shown in argument schema
--------------------------+--------------------------------------
 Reporter:  raubvogel     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  trunk
 Severity:  normal        |   Keywords:  dev-feedback needs-patch
  Focuses:  rest-api      |
--------------------------+--------------------------------------
 The {{{minItems}}} and {{{maxItems}}} documented at
 [https://developer.wordpress.org/rest-api/extending-the-rest-api/schema
 /#minitems-and-maxitems] are not shown in the argument schema.

 Add argument like (note {{{minItems}}} and {{{maxItems}}})
 {{{#!php
 <?php
 $args = ['f_marker_author_args'    => [
                                 'description' => __( 'Filter.',
 PVGW_TEXT_DOMAIN ),
                                 'required'    => false,
                                 'type'        => 'array',
                                 'minItems'    => 1,
                                 'maxItems'    => 2,
                                 'items'       => [ 'type' => 'integer' ],
                         ]]
 }}}

 to

 {{{#!php
 <?php
 register_rest_route( $this->namespace, '/' . $this->rest_base,
                         array(
                                 // register the readable endpoint for
 collections
                                 [
                                         'methods'             =>
 WP_REST_Server::READABLE,
                                         'callback'            => [ $this,
 'get_items' ],
                                         'permission_callback' => [ $this,
 'get_items_permissions_check' ],
                                         'args'                => $args,
                                 ],
                                 // register schema callback
                                 'schema' => [ $this,
 'get_public_item_schema' ],
                         )
                 );
 }}}

 If I do something like **OPTIONS** [http://localhost/wordpress-beta/wp-
 json/pvgw/v1/markers], in part I only get

 {{{
 "f_marker_author_args": {
                     "required": false,
                     "description": "Filter.",
                     "type": "array",
                     "items": {
                         "type": "integer"
                     }
                 },
 }}}

 The keys {{{minItems}}} and {{{maxItems}}} are missing.

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


More information about the wp-trac mailing list