From d76017c51ed2c7526c502e407a9f370da21586f8 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Tue, 15 Nov 2016 18:15:30 +0000 Subject: [PATCH] REST API: Clean up argument and property types. There's a couple of places where we were missing type notes for arguments, which mainly affects documentation. Props jnylen0. Fixes #38792. git-svn-id: https://develop.svn.wordpress.org/trunk@39250 602fd350-edb4-49c9-b593-d223f7449a82 --- .../endpoints/class-wp-rest-comments-controller.php | 1 + .../class-wp-rest-post-types-controller.php | 5 +---- .../endpoints/class-wp-rest-posts-controller.php | 4 ++++ .../class-wp-rest-taxonomies-controller.php | 2 +- .../endpoints/class-wp-rest-users-controller.php | 12 +++++++++--- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index efd25ad53f..19a83f30f7 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -1158,6 +1158,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { 'description' => __( 'HTML content for the object, transformed for display.' ), 'type' => 'string', 'context' => array( 'view', 'edit', 'embed' ), + 'readonly' => true, ), ), ), diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php index 5394d16fdb..4c6cdd3626 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php @@ -205,10 +205,7 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller { 'properties' => array( 'capabilities' => array( 'description' => __( 'All capabilities used by the resource.' ), - 'type' => 'array', - 'items' => array( - 'type' => 'string', - ), + 'type' => 'object', 'context' => array( 'edit' ), 'readonly' => true, ), diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 0b4ca2ec9a..d1b43a313a 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -86,6 +86,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 'password' => array( 'description' => __( 'The password for the post if it is password protected.' ), + 'type' => 'string', ), ), ), @@ -2069,6 +2070,9 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $params['slug'] = array( 'description' => __( 'Limit result set to posts with one or more specific slugs.' ), 'type' => 'array', + 'items' => array( + 'type' => 'string', + ), 'sanitize_callback' => 'wp_parse_slug_list', ); diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php index 11c306c988..b63d66cef0 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php @@ -236,7 +236,7 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller { 'properties' => array( 'capabilities' => array( 'description' => __( 'All capabilities used by the resource.' ), - 'type' => 'array', + 'type' => 'object', 'context' => array( 'edit' ), 'readonly' => true, ), diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php index 177b8151fd..324c127356 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php @@ -89,7 +89,10 @@ class WP_REST_Users_Controller extends WP_REST_Controller { 'default' => false, 'description' => __( 'Required to be true, as resource does not support trashing.' ), ), - 'reassign' => array(), + 'reassign' => array( + 'type' => 'integer', + 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ), + ), ), ), 'schema' => array( $this, 'get_public_item_schema' ), @@ -100,7 +103,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller { 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_current_item' ), 'args' => array( - 'context' => array(), + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), ), array( @@ -119,7 +122,10 @@ class WP_REST_Users_Controller extends WP_REST_Controller { 'default' => false, 'description' => __( 'Required to be true, as resource does not support trashing.' ), ), - 'reassign' => array(), + 'reassign' => array( + 'type' => 'integer', + 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ), + ), ), ), 'schema' => array( $this, 'get_public_item_schema' ),