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. Fixes #51021. git-svn-id: https://develop.svn.wordpress.org/trunk@48796 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
dd071ee278
commit
dddddc47f4
@ -645,6 +645,7 @@ abstract class WP_REST_Controller {
|
|||||||
'pattern',
|
'pattern',
|
||||||
'minItems',
|
'minItems',
|
||||||
'maxItems',
|
'maxItems',
|
||||||
|
'uniqueItems',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( $schema_properties as $field_id => $params ) {
|
foreach ( $schema_properties as $field_id => $params ) {
|
||||||
|
@ -265,7 +265,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
|||||||
|
|
||||||
$this->assertArrayHasKey( 'items', $args['somearray'] );
|
$this->assertArrayHasKey( 'items', $args['somearray'] );
|
||||||
|
|
||||||
foreach ( array( 'minItems', 'maxItems' ) as $property ) {
|
foreach ( array( 'minItems', 'maxItems', 'uniqueItems' ) as $property ) {
|
||||||
$this->assertArrayHasKey( $property, $args['somearray'] );
|
$this->assertArrayHasKey( $property, $args['somearray'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,13 +101,14 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
|
|||||||
'default' => 'a',
|
'default' => 'a',
|
||||||
),
|
),
|
||||||
'somearray' => array(
|
'somearray' => array(
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'items' => array(
|
'items' => array(
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
),
|
),
|
||||||
'minItems' => 1,
|
'minItems' => 1,
|
||||||
'maxItems' => 10,
|
'maxItems' => 10,
|
||||||
'context' => array( 'view' ),
|
'uniqueItems' => true,
|
||||||
|
'context' => array( 'view' ),
|
||||||
),
|
),
|
||||||
'someobject' => array(
|
'someobject' => array(
|
||||||
'type' => 'object',
|
'type' => 'object',
|
||||||
|
Loading…
Reference in New Issue
Block a user