mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-24 21:24:34 +00:00
REST API: Ensure that all properties of get_endpoint_args_for_item_schema are listed.
* Add new var $valid_schema_properties to match rest_validate_value_from_schema() * Unit test to ensure all valid properties exists, and non-valid properties are ignored Fixes: #50301. Props: pentatonicfunk, TimothyBlynJacobs. git-svn-id: https://develop.svn.wordpress.org/trunk@47911 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -39,11 +39,18 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
|
||||
'somestring' => array(
|
||||
'type' => 'string',
|
||||
'description' => 'A pretty string.',
|
||||
'minLength' => 3,
|
||||
'maxLength' => 3,
|
||||
'pattern' => '[a-zA-Z]+',
|
||||
'context' => array( 'view' ),
|
||||
),
|
||||
'someinteger' => array(
|
||||
'type' => 'integer',
|
||||
'context' => array( 'view' ),
|
||||
'type' => 'integer',
|
||||
'minimum' => 100,
|
||||
'maximum' => 200,
|
||||
'exclusiveMinimum' => true,
|
||||
'exclusiveMaximum' => true,
|
||||
'context' => array( 'view' ),
|
||||
),
|
||||
'someboolean' => array(
|
||||
'type' => 'boolean',
|
||||
@@ -93,6 +100,26 @@ class WP_REST_Test_Controller extends WP_REST_Controller {
|
||||
'context' => array( 'view' ),
|
||||
'default' => 'a',
|
||||
),
|
||||
'somearray' => array(
|
||||
'type' => 'array',
|
||||
'items' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'context' => array( 'view' ),
|
||||
),
|
||||
'someobject' => array(
|
||||
'type' => 'object',
|
||||
'additionalProperties' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'properties' => array(
|
||||
'object_id' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
'ignored_prop' => 'ignored_prop',
|
||||
'context' => array( 'view' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user