Ticket #40510: 40510.4.diff
File 40510.4.diff, 28.3 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
156 156 * @return true|WP_Error True if the request has read access, WP_Error object otherwise. 157 157 */ 158 158 public function get_items_permissions_check( $request ) { 159 return true; 159 160 $parent = $this->get_parent( $request['parent'] ); 160 161 if ( is_wp_error( $parent ) ) { 161 162 return $parent; … … 205 206 return $parent; 206 207 } 207 208 208 $revisions = wp_get_post_revisions( $request['parent'] ); 209 // Ensure a search string is set in case the orderby is set to 'relevance'. 210 if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) ) { 211 return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) ); 212 } 213 214 // Ensure an include parameter is set in case the orderby is set to 'include'. 215 if ( ! empty( $request['orderby'] ) && 'include' === $request['orderby'] && empty( $request['include'] ) ) { 216 return new WP_Error( 'rest_orderby_include_missing_include', __( 'You need to define an include parameter to order by include.' ), array( 'status' => 400 ) ); 217 } 218 219 if ( wp_revisions_enabled( $parent ) ) { 220 $registered = $this->get_collection_params(); 221 $args = array( 222 'post_parent' => $parent->ID, 223 'post_type' => 'revision', 224 'post_status' => 'inherit', 225 'posts_per_page' => -1, 226 'suppress_filters' => true, 227 ); 228 229 $parameter_mappings = array( 230 'exclude' => 'post__not_in', 231 'include' => 'post__in', 232 'offset' => 'offset', 233 'order' => 'order', 234 'orderby' => 'orderby', 235 'page' => 'paged', 236 'per_page' => 'posts_per_page', 237 'search' => 's', 238 ); 239 240 foreach ( $parameter_mappings as $api_param => $wp_param ) { 241 if ( isset( $registered[ $api_param ], $request[ $api_param ] ) ) { 242 $args[ $wp_param ] = $request[ $api_param ]; 243 } 244 } 245 246 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */ 247 $args = apply_filters( 'rest_revision_query', $args, $request ); 248 $query_args = $this->prepare_items_query( $args, $request ); 249 250 $revisions_query = new WP_Query(); 251 $revisions = $revisions_query->query( $query_args ); 252 $offset = isset( $query_args['offset'] ) ? (int) $query_args['offset'] : 0; 253 $page = (int) $query_args['paged']; 254 $total_revisions = $revisions_query->found_posts; 255 256 if ( $total_revisions < 1 ) { 257 // Out-of-bounds, run the query again without LIMIT for total count. 258 unset( $query_args['paged'], $query_args['offset'] ); 259 260 $count_query = new WP_Query(); 261 $count_query->query( $query_args ); 262 263 $total_revisions = $count_query->found_posts; 264 } 265 266 if ( $revisions_query->query_vars['posts_per_page'] > 0 ) { 267 $max_pages = ceil( $total_revisions / (int) $revisions_query->query_vars['posts_per_page'] ); 268 } else { 269 $max_pages = $total_revisions > 0 ? 1 : 0; 270 } 271 272 if ( $total_revisions > 0 ) { 273 if ( $offset >= $total_revisions ) { 274 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 ) ); 275 } elseif ( ! $offset && $page > $max_pages ) { 276 return new WP_Error( 'rest_revision_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) ); 277 } 278 } 279 } else { 280 $revisions = array(); 281 $total_revisions = 0; 282 $max_pages = 0; 283 $page = (int) $request['page']; 284 } 209 285 210 286 $response = array(); 211 287 foreach ( $revisions as $revision ) { 212 288 $data = $this->prepare_item_for_response( $revision, $request ); 213 289 $response[] = $this->prepare_response_for_collection( $data ); 214 290 } 215 return rest_ensure_response( $response ); 291 292 $response = rest_ensure_response( $response ); 293 294 $response->header( 'X-WP-Total', (int) $total_revisions ); 295 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 296 297 $request_params = $request->get_query_params(); 298 $base = add_query_arg( $request_params, rest_url( sprintf( '%s/%s/%d/%s', $this->namespace, $this->parent_base, $request['parent'], $this->rest_base ) ) ); 299 300 if ( $page > 1 ) { 301 $prev_page = $page - 1; 302 303 if ( $prev_page > $max_pages ) { 304 $prev_page = $max_pages; 305 } 306 307 $prev_link = add_query_arg( 'page', $prev_page, $base ); 308 $response->link_header( 'prev', $prev_link ); 309 } 310 if ( $max_pages > $page ) { 311 $next_page = $page + 1; 312 $next_link = add_query_arg( 'page', $next_page, $base ); 313 314 $response->link_header( 'next', $next_link ); 315 } 316 317 return $response; 216 318 } 217 319 218 320 /** … … 331 433 } 332 434 333 435 /** 436 * Determines the allowed query_vars for a get_items() response and prepares 437 * them for WP_Query. 438 * 439 * @since 5.0.0 440 * 441 * @param array $prepared_args Optional. Prepared WP_Query arguments. Default empty array. 442 * @param WP_REST_Request $request Optional. Full details about the request. 443 * @return array Items query arguments. 444 */ 445 protected function prepare_items_query( $prepared_args = array(), $request = null ) { 446 $query_args = array(); 447 448 foreach ( $prepared_args as $key => $value ) { 449 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */ 450 $query_args[ $key ] = apply_filters( "rest_query_var-{$key}", $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 451 } 452 453 // Map to proper WP_Query orderby param. 454 if ( isset( $query_args['orderby'] ) && isset( $request['orderby'] ) ) { 455 $orderby_mappings = array( 456 'id' => 'ID', 457 'include' => 'post__in', 458 'slug' => 'post_name', 459 'include_slugs' => 'post_name__in', 460 ); 461 462 if ( isset( $orderby_mappings[ $request['orderby'] ] ) ) { 463 $query_args['orderby'] = $orderby_mappings[ $request['orderby'] ]; 464 } 465 } 466 467 return $query_args; 468 } 469 470 /** 334 471 * Prepares the revision for the REST response. 335 472 * 336 473 * @since 4.7.0 … … 550 687 * @return array Collection parameters. 551 688 */ 552 689 public function get_collection_params() { 553 return array( 554 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 690 $query_params = parent::get_collection_params(); 691 692 $query_params['context']['default'] = 'view'; 693 694 unset( $query_params['per_page']['default'] ); 695 696 $query_params['exclude'] = array( 697 'description' => __( 'Ensure result set excludes specific IDs.' ), 698 'type' => 'array', 699 'items' => array( 700 'type' => 'integer', 701 ), 702 'default' => array(), 555 703 ); 704 705 $query_params['include'] = array( 706 'description' => __( 'Limit result set to specific IDs.' ), 707 'type' => 'array', 708 'items' => array( 709 'type' => 'integer', 710 ), 711 'default' => array(), 712 ); 713 714 $query_params['offset'] = array( 715 'description' => __( 'Offset the result set by a specific number of items.' ), 716 'type' => 'integer', 717 ); 718 719 $query_params['order'] = array( 720 'description' => __( 'Order sort attribute ascending or descending.' ), 721 'type' => 'string', 722 'default' => 'desc', 723 'enum' => array( 'asc', 'desc' ), 724 ); 725 726 $query_params['orderby'] = array( 727 'description' => __( 'Sort collection by object attribute.' ), 728 'type' => 'string', 729 'default' => 'date', 730 'enum' => array( 731 'date', 732 'id', 733 'include', 734 'relevance', 735 'slug', 736 'include_slugs', 737 'title', 738 ), 739 ); 740 741 return $query_params; 556 742 } 557 743 558 744 /** -
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 }