Ticket #40510: 40510.5.diff
File 40510.5.diff, 29.4 KB (added by , 7 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
876 876 * 877 877 * @param string $value The query_var value. 878 878 */ 879 $query_args[ $key ] = apply_filters( "rest_query_var-{$key}", $value ); 879 $query_args[ $key ] = apply_filters( "rest_query_var-{$key}", $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 880 880 } 881 881 882 882 if ( 'post' !== $this->post_type || ! isset( $query_args['ignore_sticky_posts'] ) ) { -
src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
205 205 return $parent; 206 206 } 207 207 208 $revisions = wp_get_post_revisions( $request['parent'] ); 208 // Ensure a search string is set in case the orderby is set to 'relevance'. 209 if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) ) { 210 return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) ); 211 } 212 213 // Ensure an include parameter is set in case the orderby is set to 'include'. 214 if ( ! empty( $request['orderby'] ) && 'include' === $request['orderby'] && empty( $request['include'] ) ) { 215 return new WP_Error( 'rest_orderby_include_missing_include', __( 'You need to define an include parameter to order by include.' ), array( 'status' => 400 ) ); 216 } 217 218 if ( wp_revisions_enabled( $parent ) ) { 219 $registered = $this->get_collection_params(); 220 $args = array( 221 'post_parent' => $parent->ID, 222 'post_type' => 'revision', 223 'post_status' => 'inherit', 224 'posts_per_page' => -1, 225 'orderby' => 'date ID', 226 'order' => 'DESC', 227 'suppress_filters' => true, 228 ); 229 230 $parameter_mappings = array( 231 'exclude' => 'post__not_in', 232 'include' => 'post__in', 233 'offset' => 'offset', 234 'order' => 'order', 235 'orderby' => 'orderby', 236 'page' => 'paged', 237 'per_page' => 'posts_per_page', 238 'search' => 's', 239 ); 240 241 // For backward-compatibility, 'date' needs to resolve to 'date ID'. 242 if ( isset( $request['orderby'] ) && 'date' === $request['orderby'] ) { 243 $request['orderby'] = 'date ID'; 244 } 245 246 foreach ( $parameter_mappings as $api_param => $wp_param ) { 247 if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) { 248 $args[ $wp_param ] = $request[ $api_param ]; 249 } 250 } 251 252 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */ 253 $args = apply_filters( 'rest_revision_query', $args, $request ); 254 $query_args = $this->prepare_items_query( $args, $request ); 255 256 $revisions_query = new WP_Query(); 257 $revisions = $revisions_query->query( $query_args ); 258 $offset = isset( $query_args['offset'] ) ? (int) $query_args['offset'] : 0; 259 $page = (int) $query_args['paged']; 260 $total_revisions = $revisions_query->found_posts; 261 262 if ( $total_revisions < 1 ) { 263 // Out-of-bounds, run the query again without LIMIT for total count. 264 unset( $query_args['paged'], $query_args['offset'] ); 265 266 $count_query = new WP_Query(); 267 $count_query->query( $query_args ); 268 269 $total_revisions = $count_query->found_posts; 270 } 271 272 if ( $revisions_query->query_vars['posts_per_page'] > 0 ) { 273 $max_pages = ceil( $total_revisions / (int) $revisions_query->query_vars['posts_per_page'] ); 274 } else { 275 $max_pages = $total_revisions > 0 ? 1 : 0; 276 } 277 278 if ( $total_revisions > 0 ) { 279 if ( $offset >= $total_revisions ) { 280 return new WP_Error( 'rest_revision_invalid_offset_number', __( 'The offset number requested is larger than or equal to the number of available revisions.' ), array( 'status' => 400 ) ); 281 } elseif ( ! $offset && $page > $max_pages ) { 282 return new WP_Error( 'rest_revision_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) ); 283 } 284 } 285 } else { 286 $revisions = array(); 287 $total_revisions = 0; 288 $max_pages = 0; 289 $page = (int) $request['page']; 290 } 209 291 210 292 $response = array(); 211 293 foreach ( $revisions as $revision ) { 212 294 $data = $this->prepare_item_for_response( $revision, $request ); 213 295 $response[] = $this->prepare_response_for_collection( $data ); 214 296 } 215 return rest_ensure_response( $response ); 297 298 $response = rest_ensure_response( $response ); 299 300 $response->header( 'X-WP-Total', (int) $total_revisions ); 301 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 302 303 $request_params = $request->get_query_params(); 304 $base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s/%d/%s', $this->namespace, $this->parent_base, $request['parent'], $this->rest_base ) ) ); 305 306 if ( $page > 1 ) { 307 $prev_page = $page - 1; 308 309 if ( $prev_page > $max_pages ) { 310 $prev_page = $max_pages; 311 } 312 313 $prev_link = add_query_arg( 'page', $prev_page, $base ); 314 $response->link_header( 'prev', $prev_link ); 315 } 316 if ( $max_pages > $page ) { 317 $next_page = $page + 1; 318 $next_link = add_query_arg( 'page', $next_page, $base ); 319 320 $response->link_header( 'next', $next_link ); 321 } 322 323 return $response; 216 324 } 217 325 218 326 /** … … 331 439 } 332 440 333 441 /** 442 * Determines the allowed query_vars for a get_items() response and prepares 443 * them for WP_Query. 444 * 445 * @since 5.0.0 446 * 447 * @param array $prepared_args Optional. Prepared WP_Query arguments. Default empty array. 448 * @param WP_REST_Request $request Optional. Full details about the request. 449 * @return array Items query arguments. 450 */ 451 protected function prepare_items_query( $prepared_args = array(), $request = null ) { 452 $query_args = array(); 453 454 foreach ( $prepared_args as $key => $value ) { 455 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */ 456 $query_args[ $key ] = apply_filters( "rest_query_var-{$key}", $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 457 } 458 459 // Map to proper WP_Query orderby param. 460 if ( isset( $query_args['orderby'] ) && isset( $request['orderby'] ) ) { 461 $orderby_mappings = array( 462 'id' => 'ID', 463 'include' => 'post__in', 464 'slug' => 'post_name', 465 'include_slugs' => 'post_name__in', 466 ); 467 468 if ( isset( $orderby_mappings[ $request['orderby'] ] ) ) { 469 $query_args['orderby'] = $orderby_mappings[ $request['orderby'] ]; 470 } 471 } 472 473 return $query_args; 474 } 475 476 /** 334 477 * Prepares the revision for the REST response. 335 478 * 336 479 * @since 4.7.0 … … 550 693 * @return array Collection parameters. 551 694 */ 552 695 public function get_collection_params() { 553 return array( 554 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 696 $query_params = parent::get_collection_params(); 697 698 $query_params['context']['default'] = 'view'; 699 700 unset( $query_params['per_page']['default'] ); 701 702 $query_params['exclude'] = array( 703 'description' => __( 'Ensure result set excludes specific IDs.' ), 704 'type' => 'array', 705 'items' => array( 706 'type' => 'integer', 707 ), 708 'default' => array(), 555 709 ); 710 711 $query_params['include'] = array( 712 'description' => __( 'Limit result set to specific IDs.' ), 713 'type' => 'array', 714 'items' => array( 715 'type' => 'integer', 716 ), 717 'default' => array(), 718 ); 719 720 $query_params['offset'] = array( 721 'description' => __( 'Offset the result set by a specific number of items.' ), 722 'type' => 'integer', 723 ); 724 725 $query_params['order'] = array( 726 'description' => __( 'Order sort attribute ascending or descending.' ), 727 'type' => 'string', 728 'default' => 'desc', 729 'enum' => array( 'asc', 'desc' ), 730 ); 731 732 $query_params['orderby'] = array( 733 'description' => __( 'Sort collection by object attribute.' ), 734 'type' => 'string', 735 'default' => 'date', 736 'enum' => array( 737 'date', 738 'id', 739 'include', 740 'relevance', 741 'slug', 742 'include_slugs', 743 'title', 744 ), 745 ); 746 747 return $query_params; 556 748 } 557 749 558 750 /** -
tests/phpunit/tests/rest-api/rest-revisions-controller.php
44 44 'ID' => self::$post_id, 45 45 ) 46 46 ); 47 wp_update_post( 48 array( 49 'post_content' => 'This content is fantastic.', 50 'ID' => self::$post_id, 51 ) 52 ); 47 53 wp_set_current_user( 0 ); 48 54 } 49 55 … … 59 65 public function setUp() { 60 66 parent::setUp(); 61 67 62 $revisions = wp_get_post_revisions( self::$post_id ); 63 $this->revision_1 = array_pop( $revisions ); 64 $this->revision_id1 = $this->revision_1->ID; 65 $this->revision_2 = array_pop( $revisions ); 66 $this->revision_id2 = $this->revision_2->ID; 68 $revisions = wp_get_post_revisions( self::$post_id ); 69 $this->total_revisions = count( $revisions ); 70 $this->revisions = $revisions; 71 $this->revision_1 = array_pop( $revisions ); 72 $this->revision_id1 = $this->revision_1->ID; 73 $this->revision_2 = array_pop( $revisions ); 74 $this->revision_id2 = $this->revision_2->ID; 75 $this->revision_3 = array_pop( $revisions ); 76 $this->revision_id3 = $this->revision_3->ID; 67 77 } 68 78 69 79 public function test_register_routes() { … … 95 105 $response = rest_get_server()->dispatch( $request ); 96 106 $data = $response->get_data(); 97 107 $this->assertEquals( 200, $response->get_status() ); 98 $this->assertCount( 2, $data );108 $this->assertCount( $this->total_revisions, $data ); 99 109 100 110 // Reverse chron 101 $this->assertEquals( $this->revision_id2, $data[0]['id'] ); 102 $this->check_get_revision_response( $data[0], $this->revision_2 ); 111 $this->assertEquals( $this->revision_id3, $data[2]['id'] ); 112 $this->check_get_revision_response( $data[2], $this->revision_3 ); 113 114 $this->assertEquals( $this->revision_id2, $data[1]['id'] ); 115 $this->check_get_revision_response( $data[1], $this->revision_2 ); 103 116 104 $this->assertEquals( $this->revision_id1, $data[ 1]['id'] );105 $this->check_get_revision_response( $data[ 1], $this->revision_1 );117 $this->assertEquals( $this->revision_id1, $data[0]['id'] ); 118 $this->check_get_revision_response( $data[0], $this->revision_1 ); 106 119 } 107 120 108 121 public function test_get_items_no_permission() { … … 382 395 $this->assertEquals( $parent_post_id, self::$post_id ); 383 396 } 384 397 398 /** 399 * Test the pagination header of the first page. 400 * 401 * @ticket 40510 402 */ 403 public function test_get_items_pagination_header_of_the_first_page() { 404 wp_set_current_user( self::$editor_id ); 405 406 $rest_route = '/wp/v2/posts/' . self::$post_id . '/revisions'; 407 $per_page = 2; 408 $total_pages = (int) ceil( $this->total_revisions / $per_page ); 409 $page = 1; // First page. 410 411 $request = new WP_REST_Request( 'GET', $rest_route ); 412 $request->set_query_params( array( 413 'per_page' => $per_page, 414 'page' => $page, 415 )); 416 $response = rest_get_server()->dispatch( $request ); 417 $headers = $response->get_headers(); 418 $this->assertSame( $this->total_revisions, $headers['X-WP-Total'] ); 419 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 420 $next_link = add_query_arg( 421 array( 422 'per_page' => $per_page, 423 'page' => $page + 1, 424 ), rest_url( $rest_route ) 425 ); 426 $this->assertFalse( stripos( $headers['Link'], 'rel="prev"' ) ); 427 $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] ); 428 } 429 430 /** 431 * Test the pagination header of the last page. 432 * 433 * @ticket 40510 434 */ 435 public function test_get_items_pagination_header_of_the_last_page() { 436 wp_set_current_user( self::$editor_id ); 437 438 $rest_route = '/wp/v2/posts/' . self::$post_id . '/revisions'; 439 $per_page = 2; 440 $total_pages = (int) ceil( $this->total_revisions / $per_page ); 441 $page = 2; // Last page. 442 443 $request = new WP_REST_Request( 'GET', $rest_route ); 444 $request->set_query_params( array( 445 'per_page' => $per_page, 446 'page' => $page, 447 )); 448 $response = rest_get_server()->dispatch( $request ); 449 $headers = $response->get_headers(); 450 $this->assertSame( $this->total_revisions, $headers['X-WP-Total'] ); 451 $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); 452 $prev_link = add_query_arg( 453 array( 454 'per_page' => $per_page, 455 'page' => $page - 1, 456 ), rest_url( $rest_route ) 457 ); 458 $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] ); 459 } 460 461 /** 462 * Test that invalid 'per_page' query should error. 463 * 464 * @ticket 40510 465 */ 466 public function test_get_items_invalid_per_page_should_error() { 467 wp_set_current_user( self::$editor_id ); 468 469 $per_page = -1; // Invalid number. 470 $expected_error = 'rest_invalid_param'; 471 $expected_status = 400; 472 473 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 474 $request->set_param( 'per_page', $per_page ); 475 $response = rest_get_server()->dispatch( $request ); 476 $this->assertErrorResponse( $expected_error, $response, $expected_status ); 477 } 478 479 /** 480 * Test that out of bounds 'page' query should error. 481 * 482 * @ticket 40510 483 */ 484 public function test_get_items_out_of_bounds_page_should_error() { 485 wp_set_current_user( self::$editor_id ); 486 487 $per_page = 2; 488 $total_pages = (int) ceil( $this->total_revisions / $per_page ); 489 $page = $total_pages + 1; // Out of bound page. 490 $expected_error = 'rest_revision_invalid_page_number'; 491 $expected_status = 400; 492 493 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 494 $request->set_query_params( array( 495 'per_page' => $per_page, 496 'page' => $page, 497 )); 498 $response = rest_get_server()->dispatch( $request ); 499 $this->assertErrorResponse( $expected_error, $response, $expected_status ); 500 } 501 502 /** 503 * Test that impossibly high 'page' query should error. 504 * 505 * @ticket 40510 506 */ 507 public function test_get_items_invalid_max_pages_should_error() { 508 wp_set_current_user( self::$editor_id ); 509 510 $per_page = 2; 511 $page = REST_TESTS_IMPOSSIBLY_HIGH_NUMBER; // Invalid number. 512 $expected_error = 'rest_revision_invalid_page_number'; 513 $expected_status = 400; 514 515 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 516 $request->set_query_params( array( 517 'per_page' => $per_page, 518 'page' => $page, 519 )); 520 $response = rest_get_server()->dispatch( $request ); 521 $this->assertErrorResponse( $expected_error, $response, $expected_status ); 522 } 523 524 /** 525 * Test the search query. 526 * 527 * @ticket 40510 528 */ 529 public function test_get_items_search_query() { 530 wp_set_current_user( self::$editor_id ); 531 532 $search_string = 'better'; 533 $expected_count = 1; 534 $expected_content = 'This content is better.'; 535 536 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 537 $request->set_param( 'search', $search_string ); 538 $response = rest_get_server()->dispatch( $request ); 539 $data = $response->get_data(); 540 $this->assertCount( $expected_count, $data ); 541 $this->assertContains( $expected_content, $data[0]['content']['rendered'] ); 542 } 543 544 /** 545 * Test that the default query should fetch all revisions. 546 * 547 * @ticket 40510 548 */ 549 public function test_get_items_default_query_should_fetch_all_revisons() { 550 wp_set_current_user( self::$editor_id ); 551 552 $expected_count = $this->total_revisions; 553 554 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 555 $response = rest_get_server()->dispatch( $request ); 556 $this->assertCount( $expected_count, $response->get_data() ); 557 } 558 559 /** 560 * Test that 'offset' query shouldn't work without 'per_page' (fallback -1). 561 * 562 * @ticket 40510 563 */ 564 public function test_get_items_offset_should_not_work_without_per_page() { 565 wp_set_current_user( self::$editor_id ); 566 567 $offset = 1; 568 $expected_count = $this->total_revisions; 569 570 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 571 $request->set_param( 'offset', $offset ); 572 $response = rest_get_server()->dispatch( $request ); 573 $this->assertCount( $expected_count, $response->get_data() ); 574 } 575 576 /** 577 * Test that 'offset' query should work with 'per_page'. 578 * 579 * @ticket 40510 580 */ 581 public function test_get_items_offset_should_work_with_per_page() { 582 wp_set_current_user( self::$editor_id ); 583 584 $per_page = 2; 585 $offset = 1; 586 $expected_count = 2; 587 588 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 589 $request->set_query_params( array( 590 'offset' => $offset, 591 'per_page' => $per_page, 592 )); 593 $response = rest_get_server()->dispatch( $request ); 594 $this->assertCount( $expected_count, $response->get_data() ); 595 } 596 597 /** 598 * Test that 'offset' query should take priority over 'page'. 599 * 600 * @ticket 40510 601 */ 602 public function test_get_items_offset_should_take_priority_over_page() { 603 wp_set_current_user( self::$editor_id ); 604 605 $per_page = 2; 606 $offset = 1; 607 $page = 1; 608 $expected_count = 2; 609 610 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 611 $request->set_query_params( array( 612 'offset' => $offset, 613 'per_page' => $per_page, 614 'page' => $page, 615 )); 616 $response = rest_get_server()->dispatch( $request ); 617 $this->assertCount( $expected_count, $response->get_data() ); 618 } 619 620 /** 621 * Test that 'offset' query, as the total revisions count, should return empty data. 622 * 623 * @ticket 40510 624 */ 625 public function test_get_items_total_revisions_offset_should_return_empty_data() { 626 wp_set_current_user( self::$editor_id ); 627 628 $per_page = 2; 629 $offset = $this->total_revisions; 630 $expected_error = 'rest_revision_invalid_offset_number'; 631 $expected_status = 400; 632 633 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 634 $request->set_query_params( array( 635 'offset' => $offset, 636 'per_page' => $per_page, 637 )); 638 $response = rest_get_server()->dispatch( $request ); 639 $this->assertErrorResponse( $expected_error, $response, $expected_status ); 640 } 641 642 /** 643 * Test that out of bound 'offset' query should error. 644 * 645 * @ticket 40510 646 */ 647 public function test_get_items_out_of_bound_offset_should_error() { 648 wp_set_current_user( self::$editor_id ); 649 650 $per_page = 2; 651 $offset = $this->total_revisions + 1; 652 $expected_error = 'rest_revision_invalid_offset_number'; 653 $expected_status = 400; 654 655 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 656 $request->set_query_params( array( 657 'offset' => $offset, 658 'per_page' => $per_page, 659 )); 660 $response = rest_get_server()->dispatch( $request ); 661 $this->assertErrorResponse( $expected_error, $response, $expected_status ); 662 } 663 664 /** 665 * Test that impossible high number for 'offset' query should error. 666 * 667 * @ticket 40510 668 */ 669 public function test_get_items_impossible_high_number_offset_should_error() { 670 wp_set_current_user( self::$editor_id ); 671 672 $per_page = 2; 673 $offset = REST_TESTS_IMPOSSIBLY_HIGH_NUMBER; 674 $expected_error = 'rest_revision_invalid_offset_number'; 675 $expected_status = 400; 676 677 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 678 $request->set_query_params( array( 679 'offset' => $offset, 680 'per_page' => $per_page, 681 )); 682 $response = rest_get_server()->dispatch( $request ); 683 $this->assertErrorResponse( $expected_error, $response, $expected_status ); 684 } 685 686 /** 687 * Test that invalid 'offset' query should error. 688 * 689 * @ticket 40510 690 */ 691 public function test_get_items_invalid_offset_should_error() { 692 wp_set_current_user( self::$editor_id ); 693 694 $per_page = 2; 695 $offset = 'moreplease'; 696 $expected_error = 'rest_invalid_param'; 697 $expected_status = 400; 698 699 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 700 $request->set_query_params( array( 701 'offset' => $offset, 702 'per_page' => $per_page, 703 )); 704 $response = rest_get_server()->dispatch( $request ); 705 $this->assertErrorResponse( $expected_error, $response, $expected_status ); 706 } 707 708 /** 709 * Test that out of bounds 'page' query should not error when offset is provided, 710 * because it takes precedence. 711 * 712 * @ticket 40510 713 */ 714 public function test_get_items_out_of_bounds_page_should_not_error_if_offset() { 715 wp_set_current_user( self::$editor_id ); 716 717 $per_page = 2; 718 $total_pages = (int) ceil( $this->total_revisions / $per_page ); 719 $page = $total_pages + 1; // Out of bound page. 720 $expected_count = 2; 721 722 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); 723 $request->set_query_params( array( 724 'offset' => 1, 725 'per_page' => $per_page, 726 'page' => $page, 727 )); 728 $response = rest_get_server()->dispatch( $request ); 729 $this->assertCount( $expected_count, $response->get_data() ); 730 } 385 731 } -
tests/qunit/fixtures/wp-api-generated.js
721 721 ], 722 722 "description": "Scope under which the request is made; determines fields present in response.", 723 723 "type": "string" 724 }, 725 "page": { 726 "required": false, 727 "default": 1, 728 "description": "Current page of the collection.", 729 "type": "integer" 730 }, 731 "per_page": { 732 "required": false, 733 "description": "Maximum number of items to be returned in result set.", 734 "type": "integer" 735 }, 736 "search": { 737 "required": false, 738 "description": "Limit results to those matching a string.", 739 "type": "string" 740 }, 741 "exclude": { 742 "required": false, 743 "default": [], 744 "description": "Ensure result set excludes specific IDs.", 745 "type": "array", 746 "items": { 747 "type": "integer" 748 } 749 }, 750 "include": { 751 "required": false, 752 "default": [], 753 "description": "Limit result set to specific IDs.", 754 "type": "array", 755 "items": { 756 "type": "integer" 757 } 758 }, 759 "offset": { 760 "required": false, 761 "description": "Offset the result set by a specific number of items.", 762 "type": "integer" 763 }, 764 "order": { 765 "required": false, 766 "default": "desc", 767 "enum": [ 768 "asc", 769 "desc" 770 ], 771 "description": "Order sort attribute ascending or descending.", 772 "type": "string" 773 }, 774 "orderby": { 775 "required": false, 776 "default": "date", 777 "enum": [ 778 "date", 779 "id", 780 "include", 781 "relevance", 782 "slug", 783 "include_slugs", 784 "title" 785 ], 786 "description": "Sort collection by object attribute.", 787 "type": "string" 724 788 } 725 789 } 726 790 } … … 1263 1327 ], 1264 1328 "description": "Scope under which the request is made; determines fields present in response.", 1265 1329 "type": "string" 1330 }, 1331 "page": { 1332 "required": false, 1333 "default": 1, 1334 "description": "Current page of the collection.", 1335 "type": "integer" 1336 }, 1337 "per_page": { 1338 "required": false, 1339 "description": "Maximum number of items to be returned in result set.", 1340 "type": "integer" 1341 }, 1342 "search": { 1343 "required": false, 1344 "description": "Limit results to those matching a string.", 1345 "type": "string" 1346 }, 1347 "exclude": { 1348 "required": false, 1349 "default": [], 1350 "description": "Ensure result set excludes specific IDs.", 1351 "type": "array", 1352 "items": { 1353 "type": "integer" 1354 } 1355 }, 1356 "include": { 1357 "required": false, 1358 "default": [], 1359 "description": "Limit result set to specific IDs.", 1360 "type": "array", 1361 "items": { 1362 "type": "integer" 1363 } 1364 }, 1365 "offset": { 1366 "required": false, 1367 "description": "Offset the result set by a specific number of items.", 1368 "type": "integer" 1369 }, 1370 "order": { 1371 "required": false, 1372 "default": "desc", 1373 "enum": [ 1374 "asc", 1375 "desc" 1376 ], 1377 "description": "Order sort attribute ascending or descending.", 1378 "type": "string" 1379 }, 1380 "orderby": { 1381 "required": false, 1382 "default": "date", 1383 "enum": [ 1384 "date", 1385 "id", 1386 "include", 1387 "relevance", 1388 "slug", 1389 "include_slugs", 1390 "title" 1391 ], 1392 "description": "Sort collection by object attribute.", 1393 "type": "string" 1266 1394 } 1267 1395 } 1268 1396 } … … 4286 4414 "taxonomy": "category", 4287 4415 "parent": 0, 4288 4416 "meta": { 4289 "meta_key": "" 4417 "test_single": "", 4418 "test_multi": [], 4419 "meta_key": "", 4420 "test_cat_single": "", 4421 "test_cat_multi": [] 4290 4422 }, 4291 4423 "_links": { 4292 4424 "self": [ … … 4330 4462 "taxonomy": "category", 4331 4463 "parent": 0, 4332 4464 "meta": { 4333 "meta_key": "" 4465 "test_single": "", 4466 "test_multi": [], 4467 "meta_key": "", 4468 "test_cat_single": "", 4469 "test_cat_multi": [] 4334 4470 } 4335 4471 }; 4336 4472 … … 4344 4480 "slug": "restapi-client-fixture-tag", 4345 4481 "taxonomy": "post_tag", 4346 4482 "meta": { 4347 "meta_key": "meta_value" 4483 "test_single": "", 4484 "test_multi": [], 4485 "meta_key": "meta_value", 4486 "test_tag_meta": "" 4348 4487 }, 4349 4488 "_links": { 4350 4489 "self": [ … … 4387 4526 "slug": "restapi-client-fixture-tag", 4388 4527 "taxonomy": "post_tag", 4389 4528 "meta": { 4390 "meta_key": "meta_value" 4529 "test_single": "", 4530 "test_multi": [], 4531 "meta_key": "meta_value", 4532 "test_tag_meta": "" 4391 4533 } 4392 4534 }; 4393 4535