WordPress.org

Make WordPress Core

Changeset 48807


Ignore:
Timestamp:
08/17/2020 01:40:59 AM (9 months ago)
Author:
SergeyBiryukov
Message:

REST API: Add uniqueItems as a permitted endpoint argument JSON Schema keyword.

Support for the uniqueItems keyword was added in [48357], but wasn't included in the list of permitted keywords for WP_REST_Controller::get_endpoint_args_for_item_schema(). This prevented the keyword from being automatically supported if specified in a controller's item schema.

Props TimothyBlynJacobs.
Merges [48796] to the 5.5 branch.
Fixes #51021.

Location:
branches/5.5
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php

    r47923 r48807  
    646646            'minItems',
    647647            'maxItems',
     648            'uniqueItems',
    648649        );
    649650
  • branches/5.5/tests/phpunit/tests/rest-api/rest-controller.php

    r47923 r48807  
    266266        $this->assertArrayHasKey( 'items', $args['somearray'] );
    267267
    268         foreach ( array( 'minItems', 'maxItems' ) as $property ) {
     268        foreach ( array( 'minItems', 'maxItems', 'uniqueItems' ) as $property ) {
    269269            $this->assertArrayHasKey( $property, $args['somearray'] );
    270270        }
  • branches/5.5/tests/phpunit/tests/rest-api/rest-test-controller.php

    r47923 r48807  
    102102                ),
    103103                'somearray'      => array(
    104                     'type'     => 'array',
    105                     'items'    => array(
     104                    'type'        => 'array',
     105                    'items'       => array(
    106106                        'type' => 'string',
    107107                    ),
    108                     'minItems' => 1,
    109                     'maxItems' => 10,
    110                     'context'  => array( 'view' ),
     108                    'minItems'    => 1,
     109                    'maxItems'    => 10,
     110                    'uniqueItems' => true,
     111                    'context'     => array( 'view' ),
    111112                ),
    112113                'someobject'     => array(
Note: See TracChangeset for help on using the changeset viewer.