diff --git a/Gruntfile.js b/Gruntfile.js index 5a9317c12d..92aa12db4d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -439,6 +439,10 @@ module.exports = function(grunt) { 'external-http': { cmd: 'phpunit', args: ['-c', 'phpunit.xml.dist', '--group', 'external-http'] + }, + 'restapi-jsclient': { + cmd: 'phpunit', + args: ['-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient'] } }, uglify: { @@ -672,6 +676,11 @@ module.exports = function(grunt) { 'jshint:media' ] ); + grunt.registerTask( 'restapi-jsclient', [ + 'phpunit:restapi-jsclient', + 'qunit' + ] ); + grunt.renameTask( 'watch', '_watch' ); grunt.registerTask( 'watch', function() { diff --git a/tests/phpunit/tests/rest-api/rest-schema-setup.php b/tests/phpunit/tests/rest-api/rest-schema-setup.php new file mode 100644 index 0000000000..ae2f3cd31e --- /dev/null +++ b/tests/phpunit/tests/rest-api/rest-schema-setup.php @@ -0,0 +1,248 @@ +server = $wp_rest_server = new Spy_REST_Server; + do_action( 'rest_api_init' ); + } + + public function tearDown() { + parent::tearDown(); + remove_filter( 'rest_url', array( $this, 'test_rest_url_for_leading_slash' ), 10, 2 ); + /** @var WP_REST_Server $wp_rest_server */ + global $wp_rest_server; + $wp_rest_server = null; + } + + public function test_expected_routes_in_schema() { + $routes = $this->server->get_routes(); + + $this->assertTrue( is_array( $routes ), '`get_routes` should return an array.' ); + $this->assertTrue( ! empty( $routes ), 'Routes should not be empty.' ); + + $expected_routes = array( + '/', + '/oembed/1.0', + '/oembed/1.0/embed', + '/wp/v2', + '/wp/v2/posts', + '/wp/v2/posts/(?P[\\d]+)', + '/wp/v2/posts/(?P[\\d]+)/revisions', + '/wp/v2/posts/(?P[\\d]+)/revisions/(?P[\\d]+)', + '/wp/v2/pages', + '/wp/v2/pages/(?P[\\d]+)', + '/wp/v2/pages/(?P[\\d]+)/revisions', + '/wp/v2/pages/(?P[\\d]+)/revisions/(?P[\\d]+)', + '/wp/v2/media', + '/wp/v2/media/(?P[\\d]+)', + '/wp/v2/types', + '/wp/v2/types/(?P[\\w-]+)', + '/wp/v2/statuses', + '/wp/v2/statuses/(?P[\\w-]+)', + '/wp/v2/taxonomies', + '/wp/v2/taxonomies/(?P[\\w-]+)', + '/wp/v2/categories', + '/wp/v2/categories/(?P[\\d]+)', + '/wp/v2/tags', + '/wp/v2/tags/(?P[\\d]+)', + '/wp/v2/users', + '/wp/v2/users/(?P[\\d]+)', + '/wp/v2/users/me', + '/wp/v2/comments', + '/wp/v2/comments/(?P[\\d]+)', + '/wp/v2/settings', + ); + + $this->assertEquals( $expected_routes, array_keys( $routes ) ); + } + + public function test_build_wp_api_client_fixtures() { + // Set up for testing the individual endpoints. + // Set a current admin user. + $administrator = $this->factory->user->create( array( + 'role' => 'administrator', + ) ); + wp_set_current_user( $administrator ); + + // Set up data for endpoints. + $post_id = $this->factory->post->create(); + $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); + $tag_id = $this->factory->tag->create( array( 'name' => 'test' ) ); + $media_id = $this->factory->attachment->create_object( '/tmp/canola.jpg', 0, array( + 'post_mime_type' => 'image/jpeg', + 'post_excerpt' => 'A sample caption', + ) ); + wp_update_post( array( 'post_content' => 'Updated content.', 'ID' => $post_id ) ); + wp_update_post( array( 'post_content' => 'Updated content.', 'ID' => $page_id ) ); + $comment_id = $this->factory->comment->create( array( + 'comment_approved' => 1, + 'comment_post_ID' => $post_id, + 'user_id' => 0, + ) ); + + // Generate route data for subsequent QUnit tests. + $routes_to_generate_data = array( + array( + 'route' => '/', + 'name' => 'Schema', + ), + array( + 'route' => '/oembed/1.0', + 'name' => 'oembed', + ), + array( + 'route' => '/oembed/1.0/embed', + 'name' => 'oembeds', + ), + array( + 'route' => '/wp/v2/posts', + 'name' => 'PostsCollection', + ), + array( + 'route' => '/wp/v2/posts/' . $post_id, + 'name' => 'PostModel', + ), + array( + 'route' => '/wp/v2/posts/' . $post_id . '/revisions', + 'name' => 'postRevisions', + ), + array( + 'route' => '/wp/v2/posts/' . $post_id . '/revisions/1', + 'name' => 'revision', + ), + array( + 'route' => '/wp/v2/pages', + 'name' => 'PagesCollection', + ), + array( + 'route' => '/wp/v2/pages/' . $page_id, + 'name' => 'PageModel', + ), + array( + 'route' => '/wp/v2/pages/'. $page_id . '/revisions', + 'name' => 'pageRevisions', + ), + array( + 'route' => '/wp/v2/pages/'. $page_id . '/revisions/1', + 'name' => 'pageRevision', + ), + array( + 'route' => '/wp/v2/media', + 'name' => 'MediaCollection', + ), + array( + 'route' => '/wp/v2/media/' . $media_id, + 'name' => 'MediaModel', + ), + array( + 'route' => '/wp/v2/types', + 'name' => 'TypesCollection', + ), + array( + 'route' => '/wp/v2/types/', + 'name' => 'TypeModel', + ), + array( + 'route' => '/wp/v2/statuses', + 'name' => 'StatusesCollection', + ), + array( + 'route' => '/wp/v2/statuses/publish', + 'name' => 'StatusModel', + ), + array( + 'route' => '/wp/v2/taxonomies', + 'name' => 'TaxonomiesCollection', + ), + array( + 'route' => '/wp/v2/taxonomies/category', + 'name' => 'TaxonomyModel', + ), + array( + 'route' => '/wp/v2/categories', + 'name' => 'CategoriesCollection', + ), + array( + 'route' => '/wp/v2/categories/1', + 'name' => 'CategoryModel', + ), + array( + 'route' => '/wp/v2/tags', + 'name' => 'TagsCollection', + ), + array( + 'route' => '/wp/v2/tags/' . $tag_id, + 'name' => 'TagModel', + ), + array( + 'route' => '/wp/v2/users', + 'name' => 'UsersCollection', + ), + array( + 'route' => '/wp/v2/users/1', + 'name' => 'UserModel', + ), + array( + 'route' => '/wp/v2/users/me', + 'name' => 'me', + ), + array( + 'route' => '/wp/v2/comments', + 'name' => 'CommentsCollection', + ), + array( + 'route' => '/wp/v2/comments/1', + 'name' => 'CommentModel', + ), + array( + 'route' => '/wp/v2/settings', + 'name' => 'settings', + ), + ); + + // Set up the mocked response and tell jshint to ignore the single quote json objects + $mocked_responses = "/*jshint -W109 */\n\nvar mockedApiResponse = {};\n\n"; + $mocked_responses .= "/**\n"; + $mocked_responses .= " * DO NOT EDIT\n"; + $mocked_responses .= " * Auto-generated by test_build_wp_api_client_fixtures\n"; + $mocked_responses .= " */\n"; + + foreach ( $routes_to_generate_data as $route ) { + $request = new WP_REST_Request( 'GET', $route['route'] ); + $response = $this->server->dispatch( $request ); + $data = $response->get_data(); + + $this->assertTrue( ! empty( $data ), $route['name'] . ' route should return data.' ); + + $mocked_responses .= 'mockedApiResponse.' . $route['name'] . ' = ' . wp_json_encode( $data ) . ";\n\n"; + } + + // Save the route object for QUnit tests. + $file = './tests/qunit/fixtures/wp-api-generated.js'; + file_put_contents( $file, $mocked_responses ); + + // Clean up our test data. + wp_delete_post( $post_id, true ); + wp_delete_post( $page_id, true ); + wp_delete_term( $tag_id, 'tags' ); + wp_delete_attachment( $media_id ); + wp_delete_comment( $comment_id ); + } +} diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js new file mode 100644 index 0000000000..7d81297f4d --- /dev/null +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -0,0 +1,66 @@ +/*jshint -W109 */ + +var mockedApiResponse = {}; + +/** + * DO NOT EDIT + * Auto-generated by test_build_wp_api_client_fixtures + */ +mockedApiResponse.Schema = {"name":"Test Blog","description":"Just another WordPress site","url":"http:\/\/example.org","home":"http:\/\/example.org","namespaces":["oembed\/1.0","wp\/v2"],"authentication":[],"routes":{"\/":{"namespace":"","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/"}},"\/oembed\/1.0":{"namespace":"oembed\/1.0","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"namespace":{"required":false,"default":"oembed\/1.0"},"context":{"required":false,"default":"view"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/oembed\/1.0"}},"\/oembed\/1.0\/embed":{"namespace":"oembed\/1.0","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"url":{"required":true},"format":{"required":false,"default":"json"},"maxwidth":{"required":false,"default":600}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/oembed\/1.0\/embed"}},"\/wp\/v2":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"namespace":{"required":false,"default":"wp\/v2"},"context":{"required":false,"default":"view"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2"}},"\/wp\/v2\/posts":{"namespace":"wp\/v2","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"page":{"required":false,"default":1,"description":"Current page of the collection.","type":"integer"},"per_page":{"required":false,"default":10,"description":"Maximum number of items to be returned in result set.","type":"integer"},"search":{"required":false,"description":"Limit results to those matching a string.","type":"string"},"after":{"required":false,"description":"Limit response to posts published after a given ISO8601 compliant date.","type":"string"},"author":{"required":false,"default":[],"description":"Limit result set to posts assigned to specific authors.","type":"array","items":{"type":"integer"}},"author_exclude":{"required":false,"default":[],"description":"Ensure result set excludes posts assigned to specific authors.","type":"array","items":{"type":"integer"}},"before":{"required":false,"description":"Limit response to posts published before a given ISO8601 compliant date.","type":"string"},"exclude":{"required":false,"default":[],"description":"Ensure result set excludes specific IDs.","type":"array","items":{"type":"integer"}},"include":{"required":false,"default":[],"description":"Limit result set to specific IDs.","type":"array","items":{"type":"integer"}},"offset":{"required":false,"description":"Offset the result set by a specific number of items.","type":"integer"},"order":{"required":false,"default":"desc","enum":["asc","desc"],"description":"Order sort attribute ascending or descending.","type":"string"},"orderby":{"required":false,"default":"date","enum":["date","relevance","id","include","title","slug"],"description":"Sort collection by object attribute.","type":"string"},"slug":{"required":false,"description":"Limit result set to posts with one or more specific slugs.","type":"array","items":{"type":"string"}},"status":{"required":false,"default":"publish","description":"Limit result set to posts assigned one or more statuses.","type":"array","items":{"enum":["publish","future","draft","pending","private","trash","auto-draft","inherit","any"],"type":"string"}},"categories":{"required":false,"default":[],"description":"Limit result set to all items that have the specified term assigned in the categories taxonomy.","type":"array","items":{"type":"integer"}},"categories_exclude":{"required":false,"default":[],"description":"Limit result set to all items except those that have the specified term assigned in the categories taxonomy.","type":"array","items":{"type":"integer"}},"tags":{"required":false,"default":[],"description":"Limit result set to all items that have the specified term assigned in the tags taxonomy.","type":"array","items":{"type":"integer"}},"tags_exclude":{"required":false,"default":[],"description":"Limit result set to all items except those that have the specified term assigned in the tags taxonomy.","type":"array","items":{"type":"integer"}},"sticky":{"required":false,"description":"Limit result set to items that are sticky.","type":"boolean"}}},{"methods":["POST"],"args":{"date":{"required":false,"description":"The date the object was published, in the site's timezone.","type":"string"},"date_gmt":{"required":false,"description":"The date the object was published, as GMT.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the object unique to its type.","type":"string"},"status":{"required":false,"enum":["publish","future","draft","pending","private"],"description":"A named status for the object.","type":"string"},"password":{"required":false,"description":"A password to protect access to the content and excerpt.","type":"string"},"title":{"required":false,"description":"The title for the object.","type":"object"},"content":{"required":false,"description":"The content for the object.","type":"object"},"author":{"required":false,"description":"The ID for the author of the object.","type":"integer"},"excerpt":{"required":false,"description":"The excerpt for the object.","type":"object"},"featured_media":{"required":false,"description":"The ID of the featured media for the object.","type":"integer"},"comment_status":{"required":false,"enum":["open","closed"],"description":"Whether or not comments are open on the object.","type":"string"},"ping_status":{"required":false,"enum":["open","closed"],"description":"Whether or not the object can be pinged.","type":"string"},"format":{"required":false,"enum":["standard"],"description":"The format for the object.","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"},"sticky":{"required":false,"description":"Whether or not the object should be treated as sticky.","type":"boolean"},"template":{"required":false,"enum":[""],"description":"The theme file to use to display the object.","type":"string"},"categories":{"required":false,"description":"The terms assigned to the object in the category taxonomy.","type":"array","items":{"type":"integer"}},"tags":{"required":false,"description":"The terms assigned to the object in the post_tag taxonomy.","type":"array","items":{"type":"integer"}}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts"}},"\/wp\/v2\/posts\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"password":{"required":false,"description":"The password for the post if it is password protected.","type":"string"}}},{"methods":["POST","PUT","PATCH"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"date":{"required":false,"description":"The date the object was published, in the site's timezone.","type":"string"},"date_gmt":{"required":false,"description":"The date the object was published, as GMT.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the object unique to its type.","type":"string"},"status":{"required":false,"enum":["publish","future","draft","pending","private"],"description":"A named status for the object.","type":"string"},"password":{"required":false,"description":"A password to protect access to the content and excerpt.","type":"string"},"title":{"required":false,"description":"The title for the object.","type":"object"},"content":{"required":false,"description":"The content for the object.","type":"object"},"author":{"required":false,"description":"The ID for the author of the object.","type":"integer"},"excerpt":{"required":false,"description":"The excerpt for the object.","type":"object"},"featured_media":{"required":false,"description":"The ID of the featured media for the object.","type":"integer"},"comment_status":{"required":false,"enum":["open","closed"],"description":"Whether or not comments are open on the object.","type":"string"},"ping_status":{"required":false,"enum":["open","closed"],"description":"Whether or not the object can be pinged.","type":"string"},"format":{"required":false,"enum":["standard"],"description":"The format for the object.","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"},"sticky":{"required":false,"description":"Whether or not the object should be treated as sticky.","type":"boolean"},"template":{"required":false,"enum":[""],"description":"The theme file to use to display the object.","type":"string"},"categories":{"required":false,"description":"The terms assigned to the object in the category taxonomy.","type":"array","items":{"type":"integer"}},"tags":{"required":false,"description":"The terms assigned to the object in the post_tag taxonomy.","type":"array","items":{"type":"integer"}}}},{"methods":["DELETE"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"force":{"required":false,"default":false,"description":"Whether to bypass trash and force deletion.","type":"boolean"}}}]},"\/wp\/v2\/posts\/(?P[\\d]+)\/revisions":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}}]},"\/wp\/v2\/posts\/(?P[\\d]+)\/revisions\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","DELETE"],"endpoints":[{"methods":["GET"],"args":{"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}},{"methods":["DELETE"],"args":{"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"force":{"required":false,"default":false,"description":"Required to be true, as revisions do not support trashing.","type":"boolean"}}}]},"\/wp\/v2\/pages":{"namespace":"wp\/v2","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"page":{"required":false,"default":1,"description":"Current page of the collection.","type":"integer"},"per_page":{"required":false,"default":10,"description":"Maximum number of items to be returned in result set.","type":"integer"},"search":{"required":false,"description":"Limit results to those matching a string.","type":"string"},"after":{"required":false,"description":"Limit response to posts published after a given ISO8601 compliant date.","type":"string"},"author":{"required":false,"default":[],"description":"Limit result set to posts assigned to specific authors.","type":"array","items":{"type":"integer"}},"author_exclude":{"required":false,"default":[],"description":"Ensure result set excludes posts assigned to specific authors.","type":"array","items":{"type":"integer"}},"before":{"required":false,"description":"Limit response to posts published before a given ISO8601 compliant date.","type":"string"},"exclude":{"required":false,"default":[],"description":"Ensure result set excludes specific IDs.","type":"array","items":{"type":"integer"}},"include":{"required":false,"default":[],"description":"Limit result set to specific IDs.","type":"array","items":{"type":"integer"}},"menu_order":{"required":false,"description":"Limit result set to posts with a specific menu_order value.","type":"integer"},"offset":{"required":false,"description":"Offset the result set by a specific number of items.","type":"integer"},"order":{"required":false,"default":"desc","enum":["asc","desc"],"description":"Order sort attribute ascending or descending.","type":"string"},"orderby":{"required":false,"default":"date","enum":["date","relevance","id","include","title","slug","menu_order"],"description":"Sort collection by object attribute.","type":"string"},"parent":{"required":false,"default":[],"description":"Limit result set to those of particular parent IDs.","type":"array","items":{"type":"integer"}},"parent_exclude":{"required":false,"default":[],"description":"Limit result set to all items except those of a particular parent ID.","type":"array","items":{"type":"integer"}},"slug":{"required":false,"description":"Limit result set to posts with one or more specific slugs.","type":"array","items":{"type":"string"}},"status":{"required":false,"default":"publish","description":"Limit result set to posts assigned one or more statuses.","type":"array","items":{"enum":["publish","future","draft","pending","private","trash","auto-draft","inherit","any"],"type":"string"}}}},{"methods":["POST"],"args":{"date":{"required":false,"description":"The date the object was published, in the site's timezone.","type":"string"},"date_gmt":{"required":false,"description":"The date the object was published, as GMT.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the object unique to its type.","type":"string"},"status":{"required":false,"enum":["publish","future","draft","pending","private"],"description":"A named status for the object.","type":"string"},"password":{"required":false,"description":"A password to protect access to the content and excerpt.","type":"string"},"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"title":{"required":false,"description":"The title for the object.","type":"object"},"content":{"required":false,"description":"The content for the object.","type":"object"},"author":{"required":false,"description":"The ID for the author of the object.","type":"integer"},"excerpt":{"required":false,"description":"The excerpt for the object.","type":"object"},"featured_media":{"required":false,"description":"The ID of the featured media for the object.","type":"integer"},"comment_status":{"required":false,"enum":["open","closed"],"description":"Whether or not comments are open on the object.","type":"string"},"ping_status":{"required":false,"enum":["open","closed"],"description":"Whether or not the object can be pinged.","type":"string"},"menu_order":{"required":false,"description":"The order of the object in relation to other object of its type.","type":"integer"},"meta":{"required":false,"description":"Meta fields.","type":"object"},"template":{"required":false,"enum":[""],"description":"The theme file to use to display the object.","type":"string"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages"}},"\/wp\/v2\/pages\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"password":{"required":false,"description":"The password for the post if it is password protected.","type":"string"}}},{"methods":["POST","PUT","PATCH"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"date":{"required":false,"description":"The date the object was published, in the site's timezone.","type":"string"},"date_gmt":{"required":false,"description":"The date the object was published, as GMT.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the object unique to its type.","type":"string"},"status":{"required":false,"enum":["publish","future","draft","pending","private"],"description":"A named status for the object.","type":"string"},"password":{"required":false,"description":"A password to protect access to the content and excerpt.","type":"string"},"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"title":{"required":false,"description":"The title for the object.","type":"object"},"content":{"required":false,"description":"The content for the object.","type":"object"},"author":{"required":false,"description":"The ID for the author of the object.","type":"integer"},"excerpt":{"required":false,"description":"The excerpt for the object.","type":"object"},"featured_media":{"required":false,"description":"The ID of the featured media for the object.","type":"integer"},"comment_status":{"required":false,"enum":["open","closed"],"description":"Whether or not comments are open on the object.","type":"string"},"ping_status":{"required":false,"enum":["open","closed"],"description":"Whether or not the object can be pinged.","type":"string"},"menu_order":{"required":false,"description":"The order of the object in relation to other object of its type.","type":"integer"},"meta":{"required":false,"description":"Meta fields.","type":"object"},"template":{"required":false,"enum":[""],"description":"The theme file to use to display the object.","type":"string"}}},{"methods":["DELETE"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"force":{"required":false,"default":false,"description":"Whether to bypass trash and force deletion.","type":"boolean"}}}]},"\/wp\/v2\/pages\/(?P[\\d]+)\/revisions":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}}]},"\/wp\/v2\/pages\/(?P[\\d]+)\/revisions\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","DELETE"],"endpoints":[{"methods":["GET"],"args":{"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}},{"methods":["DELETE"],"args":{"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"force":{"required":false,"default":false,"description":"Required to be true, as revisions do not support trashing.","type":"boolean"}}}]},"\/wp\/v2\/media":{"namespace":"wp\/v2","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"page":{"required":false,"default":1,"description":"Current page of the collection.","type":"integer"},"per_page":{"required":false,"default":10,"description":"Maximum number of items to be returned in result set.","type":"integer"},"search":{"required":false,"description":"Limit results to those matching a string.","type":"string"},"after":{"required":false,"description":"Limit response to posts published after a given ISO8601 compliant date.","type":"string"},"author":{"required":false,"default":[],"description":"Limit result set to posts assigned to specific authors.","type":"array","items":{"type":"integer"}},"author_exclude":{"required":false,"default":[],"description":"Ensure result set excludes posts assigned to specific authors.","type":"array","items":{"type":"integer"}},"before":{"required":false,"description":"Limit response to posts published before a given ISO8601 compliant date.","type":"string"},"exclude":{"required":false,"default":[],"description":"Ensure result set excludes specific IDs.","type":"array","items":{"type":"integer"}},"include":{"required":false,"default":[],"description":"Limit result set to specific IDs.","type":"array","items":{"type":"integer"}},"offset":{"required":false,"description":"Offset the result set by a specific number of items.","type":"integer"},"order":{"required":false,"default":"desc","enum":["asc","desc"],"description":"Order sort attribute ascending or descending.","type":"string"},"orderby":{"required":false,"default":"date","enum":["date","relevance","id","include","title","slug"],"description":"Sort collection by object attribute.","type":"string"},"parent":{"required":false,"default":[],"description":"Limit result set to those of particular parent IDs.","type":"array","items":{"type":"integer"}},"parent_exclude":{"required":false,"default":[],"description":"Limit result set to all items except those of a particular parent ID.","type":"array","items":{"type":"integer"}},"slug":{"required":false,"description":"Limit result set to posts with one or more specific slugs.","type":"array","items":{"type":"string"}},"status":{"required":false,"default":"inherit","description":"Limit result set to posts assigned one or more statuses.","type":"array","items":{"enum":["inherit","private","trash"],"type":"string"}},"media_type":{"required":false,"enum":["image","video","text","application","audio"],"description":"Limit result set to attachments of a particular media type.","type":"string"},"mime_type":{"required":false,"description":"Limit result set to attachments of a particular MIME type.","type":"string"}}},{"methods":["POST"],"args":{"date":{"required":false,"description":"The date the object was published, in the site's timezone.","type":"string"},"date_gmt":{"required":false,"description":"The date the object was published, as GMT.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the object unique to its type.","type":"string"},"status":{"required":false,"enum":["publish","future","draft","pending","private"],"description":"A named status for the object.","type":"string"},"title":{"required":false,"description":"The title for the object.","type":"object"},"author":{"required":false,"description":"The ID for the author of the object.","type":"integer"},"comment_status":{"required":false,"enum":["open","closed"],"description":"Whether or not comments are open on the object.","type":"string"},"ping_status":{"required":false,"enum":["open","closed"],"description":"Whether or not the object can be pinged.","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"},"template":{"required":false,"enum":[""],"description":"The theme file to use to display the object.","type":"string"},"alt_text":{"required":false,"description":"Alternative text to display when attachment is not displayed.","type":"string"},"caption":{"required":false,"description":"The attachment caption.","type":"object"},"description":{"required":false,"description":"The attachment description.","type":"object"},"post":{"required":false,"description":"The ID for the associated post of the attachment.","type":"integer"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/media"}},"\/wp\/v2\/media\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}},{"methods":["POST","PUT","PATCH"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"date":{"required":false,"description":"The date the object was published, in the site's timezone.","type":"string"},"date_gmt":{"required":false,"description":"The date the object was published, as GMT.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the object unique to its type.","type":"string"},"status":{"required":false,"enum":["publish","future","draft","pending","private"],"description":"A named status for the object.","type":"string"},"title":{"required":false,"description":"The title for the object.","type":"object"},"author":{"required":false,"description":"The ID for the author of the object.","type":"integer"},"comment_status":{"required":false,"enum":["open","closed"],"description":"Whether or not comments are open on the object.","type":"string"},"ping_status":{"required":false,"enum":["open","closed"],"description":"Whether or not the object can be pinged.","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"},"template":{"required":false,"enum":[""],"description":"The theme file to use to display the object.","type":"string"},"alt_text":{"required":false,"description":"Alternative text to display when attachment is not displayed.","type":"string"},"caption":{"required":false,"description":"The attachment caption.","type":"object"},"description":{"required":false,"description":"The attachment description.","type":"object"},"post":{"required":false,"description":"The ID for the associated post of the attachment.","type":"integer"}}},{"methods":["DELETE"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"force":{"required":false,"default":false,"description":"Whether to bypass trash and force deletion.","type":"boolean"}}}]},"\/wp\/v2\/types":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/types"}},"\/wp\/v2\/types\/(?P[\\w-]+)":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"type":{"required":false,"description":"An alphanumeric identifier for the post type.","type":"string"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}}]},"\/wp\/v2\/statuses":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/statuses"}},"\/wp\/v2\/statuses\/(?P[\\w-]+)":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"status":{"required":false,"description":"An alphanumeric identifier for the status.","type":"string"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}}]},"\/wp\/v2\/taxonomies":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"type":{"required":false,"description":"Limit results to taxonomies associated with a specific post type.","type":"string"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/taxonomies"}},"\/wp\/v2\/taxonomies\/(?P[\\w-]+)":{"namespace":"wp\/v2","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"taxonomy":{"required":false,"description":"An alphanumeric identifier for the taxonomy.","type":"string"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}}]},"\/wp\/v2\/categories":{"namespace":"wp\/v2","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"page":{"required":false,"default":1,"description":"Current page of the collection.","type":"integer"},"per_page":{"required":false,"default":10,"description":"Maximum number of items to be returned in result set.","type":"integer"},"search":{"required":false,"description":"Limit results to those matching a string.","type":"string"},"exclude":{"required":false,"default":[],"description":"Ensure result set excludes specific IDs.","type":"array","items":{"type":"integer"}},"include":{"required":false,"default":[],"description":"Limit result set to specific IDs.","type":"array","items":{"type":"integer"}},"order":{"required":false,"default":"asc","enum":["asc","desc"],"description":"Order sort attribute ascending or descending.","type":"string"},"orderby":{"required":false,"default":"name","enum":["id","include","name","slug","term_group","description","count"],"description":"Sort collection by term attribute.","type":"string"},"hide_empty":{"required":false,"default":false,"description":"Whether to hide terms not assigned to any posts.","type":"boolean"},"parent":{"required":false,"description":"Limit result set to terms assigned to a specific parent.","type":"integer"},"post":{"required":false,"description":"Limit result set to terms assigned to a specific post.","type":"integer"},"slug":{"required":false,"description":"Limit result set to terms with a specific slug.","type":"string"}}},{"methods":["POST"],"args":{"description":{"required":false,"description":"HTML description of the term.","type":"string"},"name":{"required":true,"description":"HTML title for the term.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the term unique to its type.","type":"string"},"parent":{"required":false,"description":"The parent term ID.","type":"integer"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/categories"}},"\/wp\/v2\/categories\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":{"id":{"required":false,"description":"Unique identifier for the term.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}},{"methods":["POST","PUT","PATCH"],"args":{"id":{"required":false,"description":"Unique identifier for the term.","type":"integer"},"description":{"required":false,"description":"HTML description of the term.","type":"string"},"name":{"required":false,"description":"HTML title for the term.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the term unique to its type.","type":"string"},"parent":{"required":false,"description":"The parent term ID.","type":"integer"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}},{"methods":["DELETE"],"args":{"id":{"required":false,"description":"Unique identifier for the term.","type":"integer"},"force":{"required":false,"default":false,"description":"Required to be true, as terms do not support trashing.","type":"boolean"}}}]},"\/wp\/v2\/tags":{"namespace":"wp\/v2","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"page":{"required":false,"default":1,"description":"Current page of the collection.","type":"integer"},"per_page":{"required":false,"default":10,"description":"Maximum number of items to be returned in result set.","type":"integer"},"search":{"required":false,"description":"Limit results to those matching a string.","type":"string"},"exclude":{"required":false,"default":[],"description":"Ensure result set excludes specific IDs.","type":"array","items":{"type":"integer"}},"include":{"required":false,"default":[],"description":"Limit result set to specific IDs.","type":"array","items":{"type":"integer"}},"offset":{"required":false,"description":"Offset the result set by a specific number of items.","type":"integer"},"order":{"required":false,"default":"asc","enum":["asc","desc"],"description":"Order sort attribute ascending or descending.","type":"string"},"orderby":{"required":false,"default":"name","enum":["id","include","name","slug","term_group","description","count"],"description":"Sort collection by term attribute.","type":"string"},"hide_empty":{"required":false,"default":false,"description":"Whether to hide terms not assigned to any posts.","type":"boolean"},"post":{"required":false,"description":"Limit result set to terms assigned to a specific post.","type":"integer"},"slug":{"required":false,"description":"Limit result set to terms with a specific slug.","type":"string"}}},{"methods":["POST"],"args":{"description":{"required":false,"description":"HTML description of the term.","type":"string"},"name":{"required":true,"description":"HTML title for the term.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the term unique to its type.","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/tags"}},"\/wp\/v2\/tags\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":{"id":{"required":false,"description":"Unique identifier for the term.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}},{"methods":["POST","PUT","PATCH"],"args":{"id":{"required":false,"description":"Unique identifier for the term.","type":"integer"},"description":{"required":false,"description":"HTML description of the term.","type":"string"},"name":{"required":false,"description":"HTML title for the term.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the term unique to its type.","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}},{"methods":["DELETE"],"args":{"id":{"required":false,"description":"Unique identifier for the term.","type":"integer"},"force":{"required":false,"default":false,"description":"Required to be true, as terms do not support trashing.","type":"boolean"}}}]},"\/wp\/v2\/users":{"namespace":"wp\/v2","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"page":{"required":false,"default":1,"description":"Current page of the collection.","type":"integer"},"per_page":{"required":false,"default":10,"description":"Maximum number of items to be returned in result set.","type":"integer"},"search":{"required":false,"description":"Limit results to those matching a string.","type":"string"},"exclude":{"required":false,"default":[],"description":"Ensure result set excludes specific IDs.","type":"array","items":{"type":"integer"}},"include":{"required":false,"default":[],"description":"Limit result set to specific IDs.","type":"array","items":{"type":"integer"}},"offset":{"required":false,"description":"Offset the result set by a specific number of items.","type":"integer"},"order":{"required":false,"default":"asc","enum":["asc","desc"],"description":"Order sort attribute ascending or descending.","type":"string"},"orderby":{"required":false,"default":"name","enum":["id","include","name","registered_date","slug","email","url"],"description":"Sort collection by object attribute.","type":"string"},"slug":{"required":false,"description":"Limit result set to users with a specific slug.","type":"string"},"roles":{"required":false,"description":"Limit result set to users matching at least one specific role provided. Accepts csv list or single role.","type":"array","items":{"type":"string"}}}},{"methods":["POST"],"args":{"username":{"required":true,"description":"Login name for the user.","type":"string"},"name":{"required":false,"description":"Display name for the user.","type":"string"},"first_name":{"required":false,"description":"First name for the user.","type":"string"},"last_name":{"required":false,"description":"Last name for the user.","type":"string"},"email":{"required":true,"description":"The email address for the user.","type":"string"},"url":{"required":false,"description":"URL of the user.","type":"string"},"description":{"required":false,"description":"Description of the user.","type":"string"},"locale":{"required":false,"enum":["","en_US","de_DE","en_GB","es_ES"],"description":"Locale for the user.","type":"string"},"nickname":{"required":false,"description":"The nickname for the user.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the user.","type":"string"},"roles":{"required":false,"description":"Roles assigned to the user.","type":"array","items":{"type":"string"}},"password":{"required":true,"description":"Password for the user (never included).","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users"}},"\/wp\/v2\/users\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":{"id":{"required":false,"description":"Unique identifier for the user.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}},{"methods":["POST","PUT","PATCH"],"args":{"id":{"required":false,"description":"Unique identifier for the user.","type":"integer"},"username":{"required":false,"description":"Login name for the user.","type":"string"},"name":{"required":false,"description":"Display name for the user.","type":"string"},"first_name":{"required":false,"description":"First name for the user.","type":"string"},"last_name":{"required":false,"description":"Last name for the user.","type":"string"},"email":{"required":false,"description":"The email address for the user.","type":"string"},"url":{"required":false,"description":"URL of the user.","type":"string"},"description":{"required":false,"description":"Description of the user.","type":"string"},"locale":{"required":false,"enum":["","en_US","de_DE","en_GB","es_ES"],"description":"Locale for the user.","type":"string"},"nickname":{"required":false,"description":"The nickname for the user.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the user.","type":"string"},"roles":{"required":false,"description":"Roles assigned to the user.","type":"array","items":{"type":"string"}},"password":{"required":false,"description":"Password for the user (never included).","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}},{"methods":["DELETE"],"args":{"id":{"required":false,"description":"Unique identifier for the user.","type":"integer"},"force":{"required":false,"default":false,"description":"Required to be true, as users do not support trashing.","type":"boolean"},"reassign":{"required":true,"description":"Reassign the deleted user's posts and links to this user ID.","type":"integer"}}}]},"\/wp\/v2\/users\/me":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"}}},{"methods":["POST","PUT","PATCH"],"args":{"username":{"required":false,"description":"Login name for the user.","type":"string"},"name":{"required":false,"description":"Display name for the user.","type":"string"},"first_name":{"required":false,"description":"First name for the user.","type":"string"},"last_name":{"required":false,"description":"Last name for the user.","type":"string"},"email":{"required":false,"description":"The email address for the user.","type":"string"},"url":{"required":false,"description":"URL of the user.","type":"string"},"description":{"required":false,"description":"Description of the user.","type":"string"},"locale":{"required":false,"enum":["","en_US","de_DE","en_GB","es_ES"],"description":"Locale for the user.","type":"string"},"nickname":{"required":false,"description":"The nickname for the user.","type":"string"},"slug":{"required":false,"description":"An alphanumeric identifier for the user.","type":"string"},"roles":{"required":false,"description":"Roles assigned to the user.","type":"array","items":{"type":"string"}},"password":{"required":false,"description":"Password for the user (never included).","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}},{"methods":["DELETE"],"args":{"force":{"required":false,"default":false,"description":"Required to be true, as users do not support trashing.","type":"boolean"},"reassign":{"required":true,"description":"Reassign the deleted user's posts and links to this user ID.","type":"integer"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users\/me"}},"\/wp\/v2\/comments":{"namespace":"wp\/v2","methods":["GET","POST"],"endpoints":[{"methods":["GET"],"args":{"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"page":{"required":false,"default":1,"description":"Current page of the collection.","type":"integer"},"per_page":{"required":false,"default":10,"description":"Maximum number of items to be returned in result set.","type":"integer"},"search":{"required":false,"description":"Limit results to those matching a string.","type":"string"},"after":{"required":false,"description":"Limit response to comments published after a given ISO8601 compliant date.","type":"string"},"author":{"required":false,"description":"Limit result set to comments assigned to specific user IDs. Requires authorization.","type":"array","items":{"type":"integer"}},"author_exclude":{"required":false,"description":"Ensure result set excludes comments assigned to specific user IDs. Requires authorization.","type":"array","items":{"type":"integer"}},"author_email":{"required":false,"description":"Limit result set to that from a specific author email. Requires authorization.","type":"string"},"before":{"required":false,"description":"Limit response to comments published before a given ISO8601 compliant date.","type":"string"},"exclude":{"required":false,"default":[],"description":"Ensure result set excludes specific IDs.","type":"array","items":{"type":"integer"}},"include":{"required":false,"default":[],"description":"Limit result set to specific IDs.","type":"array","items":{"type":"integer"}},"offset":{"required":false,"description":"Offset the result set by a specific number of items.","type":"integer"},"order":{"required":false,"default":"desc","enum":["asc","desc"],"description":"Order sort attribute ascending or descending.","type":"string"},"orderby":{"required":false,"default":"date_gmt","enum":["date","date_gmt","id","include","post","parent","type"],"description":"Sort collection by object attribute.","type":"string"},"parent":{"required":false,"default":[],"description":"Limit result set to comments of specific parent IDs.","type":"array","items":{"type":"integer"}},"parent_exclude":{"required":false,"default":[],"description":"Ensure result set excludes specific parent IDs.","type":"array","items":{"type":"integer"}},"post":{"required":false,"default":[],"description":"Limit result set to comments assigned to specific post IDs.","type":"array","items":{"type":"integer"}},"status":{"required":false,"default":"approve","description":"Limit result set to comments assigned a specific status. Requires authorization.","type":"string"},"type":{"required":false,"default":"comment","description":"Limit result set to comments assigned a specific type. Requires authorization.","type":"string"},"password":{"required":false,"description":"The password for the post if it is password protected.","type":"string"}}},{"methods":["POST"],"args":{"author":{"required":false,"description":"The ID of the user object, if author was a user.","type":"integer"},"author_email":{"required":false,"description":"Email address for the object author.","type":"string"},"author_ip":{"required":false,"description":"IP address for the object author.","type":"string"},"author_name":{"required":false,"description":"Display name for the object author.","type":"string"},"author_url":{"required":false,"description":"URL for the object author.","type":"string"},"author_user_agent":{"required":false,"description":"User agent for the object author.","type":"string"},"content":{"required":false,"description":"The content for the object.","type":"object"},"date":{"required":false,"description":"The date the object was published, in the site's timezone.","type":"string"},"date_gmt":{"required":false,"description":"The date the object was published, as GMT.","type":"string"},"parent":{"required":false,"default":0,"description":"The ID for the parent of the object.","type":"integer"},"post":{"required":false,"default":0,"description":"The ID of the associated post object.","type":"integer"},"status":{"required":false,"description":"State of the object.","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/comments"}},"\/wp\/v2\/comments\/(?P[\\d]+)":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH","DELETE"],"endpoints":[{"methods":["GET"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"context":{"required":false,"default":"view","enum":["view","embed","edit"],"description":"Scope under which the request is made; determines fields present in response.","type":"string"},"password":{"required":false,"description":"The password for the post if it is password protected.","type":"string"}}},{"methods":["POST","PUT","PATCH"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"author":{"required":false,"description":"The ID of the user object, if author was a user.","type":"integer"},"author_email":{"required":false,"description":"Email address for the object author.","type":"string"},"author_ip":{"required":false,"description":"IP address for the object author.","type":"string"},"author_name":{"required":false,"description":"Display name for the object author.","type":"string"},"author_url":{"required":false,"description":"URL for the object author.","type":"string"},"author_user_agent":{"required":false,"description":"User agent for the object author.","type":"string"},"content":{"required":false,"description":"The content for the object.","type":"object"},"date":{"required":false,"description":"The date the object was published, in the site's timezone.","type":"string"},"date_gmt":{"required":false,"description":"The date the object was published, as GMT.","type":"string"},"parent":{"required":false,"description":"The ID for the parent of the object.","type":"integer"},"post":{"required":false,"description":"The ID of the associated post object.","type":"integer"},"status":{"required":false,"description":"State of the object.","type":"string"},"meta":{"required":false,"description":"Meta fields.","type":"object"}}},{"methods":["DELETE"],"args":{"id":{"required":false,"description":"Unique identifier for the object.","type":"integer"},"force":{"required":false,"default":false,"description":"Whether to bypass trash and force deletion.","type":"boolean"},"password":{"required":false,"description":"The password for the post if it is password protected.","type":"string"}}}]},"\/wp\/v2\/settings":{"namespace":"wp\/v2","methods":["GET","POST","PUT","PATCH"],"endpoints":[{"methods":["GET"],"args":[]},{"methods":["POST","PUT","PATCH"],"args":{"title":{"required":false,"description":"Site title.","type":"string"},"description":{"required":false,"description":"Site tagline.","type":"string"},"url":{"required":false,"description":"Site URL.","type":"string"},"email":{"required":false,"description":"This address is used for admin purposes, like new user notification.","type":"string"},"timezone":{"required":false,"description":"A city in the same timezone as you.","type":"string"},"date_format":{"required":false,"description":"A date format for all date strings.","type":"string"},"time_format":{"required":false,"description":"A time format for all time strings.","type":"string"},"start_of_week":{"required":false,"description":"A day number of the week that the week should start on.","type":"integer"},"language":{"required":false,"description":"WordPress locale code.","type":"string"},"use_smilies":{"required":false,"description":"Convert emoticons like :-) and :-P to graphics on display.","type":"boolean"},"default_category":{"required":false,"description":"Default post category.","type":"integer"},"default_post_format":{"required":false,"description":"Default post format.","type":"string"},"posts_per_page":{"required":false,"description":"Blog pages show at most.","type":"integer"},"default_ping_status":{"required":false,"enum":["open","closed"],"description":"Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.","type":"string"},"default_comment_status":{"required":false,"enum":["open","closed"],"description":"Allow people to post comments on new articles.","type":"string"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/wp\/v2\/settings"}}}}; + +mockedApiResponse.oembed = {"namespace":"oembed\/1.0","routes":{"\/oembed\/1.0":{"namespace":"oembed\/1.0","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"namespace":{"required":false,"default":"oembed\/1.0"},"context":{"required":false,"default":"view"}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/oembed\/1.0"}},"\/oembed\/1.0\/embed":{"namespace":"oembed\/1.0","methods":["GET"],"endpoints":[{"methods":["GET"],"args":{"url":{"required":true},"format":{"required":false,"default":"json"},"maxwidth":{"required":false,"default":600}}}],"_links":{"self":"http:\/\/example.org\/?rest_route=\/oembed\/1.0\/embed"}}}}; + +mockedApiResponse.oembeds = {"code":"rest_missing_callback_param","message":"Missing parameter(s): url","data":{"status":400,"params":["url"]}}; + +mockedApiResponse.PostsCollection = [{"id":1368,"date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","guid":{"rendered":"http:\/\/example.org\/?p=1368"},"modified":"2017-02-14T04:05:35","modified_gmt":"2017-02-14T04:05:35","slug":"post-title-6208","type":"post","link":"http:\/\/example.org\/?p=1368","title":{"rendered":"Post title 6208"},"content":{"rendered":"

Updated content.<\/p>\n","protected":false},"excerpt":{"rendered":"

Post excerpt 6208<\/p>\n","protected":false},"author":354,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"test_single":"","test_multi":[],"test_bad_auth":"","test_bad_auth_multi":[],"test_custom_schema":0,"test_custom_schema_multi":[],"new_name":"","new_name_multi":[],"test_string":"","test_number":0,"test_bool":false,"my_meta_key":[]},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts\/1368"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users\/354"}],"replies":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fcomments&post=1368"}],"version-history":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts\/1368\/revisions"}],"wp:attachment":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fcategories&post=1368"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Ftags&post=1368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]; + +mockedApiResponse.PostModel = {"id":1368,"date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","guid":{"rendered":"http:\/\/example.org\/?p=1368"},"modified":"2017-02-14T04:05:35","modified_gmt":"2017-02-14T04:05:35","slug":"post-title-6208","type":"post","link":"http:\/\/example.org\/?p=1368","title":{"rendered":"Post title 6208"},"content":{"rendered":"

Updated content.<\/p>\n","protected":false},"excerpt":{"rendered":"

Post excerpt 6208<\/p>\n","protected":false},"author":354,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"test_single":"","test_multi":[],"test_bad_auth":"","test_bad_auth_multi":[],"test_custom_schema":0,"test_custom_schema_multi":[],"new_name":"","new_name_multi":[],"test_string":"","test_number":0,"test_bool":false,"my_meta_key":[]},"categories":[1],"tags":[]}; + +mockedApiResponse.postRevisions = [{"author":"354","date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","id":1371,"modified":"2017-02-14T04:05:35","modified_gmt":"2017-02-14T04:05:35","parent":1368,"slug":"1368-revision-v1","guid":{"rendered":"http:\/\/example.org\/?p=1371"},"title":{"rendered":"Post title 6208"},"content":{"rendered":"

Updated content.<\/p>\n"},"excerpt":{"rendered":"

Post excerpt 6208<\/p>\n"},"_links":{"parent":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts\/1368"}]}}]; + +mockedApiResponse.revision = {"code":"rest_post_invalid_id","message":"Invalid revision ID.","data":{"status":404}}; + +mockedApiResponse.PagesCollection = [{"id":1369,"date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","guid":{"rendered":"http:\/\/example.org\/?page_id=1369"},"modified":"2017-02-14T04:05:35","modified_gmt":"2017-02-14T04:05:35","slug":"post-title-6209","type":"page","link":"http:\/\/example.org\/?page_id=1369","title":{"rendered":"Post title 6209"},"content":{"rendered":"

Updated content.<\/p>\n","protected":false},"excerpt":{"rendered":"

Post excerpt 6209<\/p>\n","protected":false},"author":354,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"test_single":"","test_multi":[],"test_bad_auth":"","test_bad_auth_multi":[],"test_custom_schema":0,"test_custom_schema_multi":[],"new_name":"","new_name_multi":[],"test_string":"","test_number":0,"test_bool":false,"my_meta_key":[]},"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages\/1369"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users\/354"}],"replies":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fcomments&post=1369"}],"version-history":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages\/1369\/revisions"}],"wp:attachment":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]; + +mockedApiResponse.PageModel = {"id":1369,"date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","guid":{"rendered":"http:\/\/example.org\/?page_id=1369"},"modified":"2017-02-14T04:05:35","modified_gmt":"2017-02-14T04:05:35","slug":"post-title-6209","type":"page","link":"http:\/\/example.org\/?page_id=1369","title":{"rendered":"Post title 6209"},"content":{"rendered":"

Updated content.<\/p>\n","protected":false},"excerpt":{"rendered":"

Post excerpt 6209<\/p>\n","protected":false},"author":354,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"test_single":"","test_multi":[],"test_bad_auth":"","test_bad_auth_multi":[],"test_custom_schema":0,"test_custom_schema_multi":[],"new_name":"","new_name_multi":[],"test_string":"","test_number":0,"test_bool":false,"my_meta_key":[]}}; + +mockedApiResponse.pageRevisions = [{"author":"354","date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","id":1372,"modified":"2017-02-14T04:05:35","modified_gmt":"2017-02-14T04:05:35","parent":1369,"slug":"1369-revision-v1","guid":{"rendered":"http:\/\/example.org\/?p=1372"},"title":{"rendered":"Post title 6209"},"content":{"rendered":"

Updated content.<\/p>\n"},"excerpt":{"rendered":"

Post excerpt 6209<\/p>\n"},"_links":{"parent":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages\/1369"}]}}]; + +mockedApiResponse.pageRevision = {"code":"rest_post_invalid_id","message":"Invalid revision ID.","data":{"status":404}}; + +mockedApiResponse.MediaCollection = [{"id":1370,"date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","guid":{"rendered":"http:\/\/example.org\/?attachment_id=1370"},"modified":"2017-02-14T04:05:35","modified_gmt":"2017-02-14T04:05:35","slug":"1370","type":"attachment","link":"http:\/\/example.org\/?attachment_id=1370","title":{"rendered":""},"author":354,"comment_status":"open","ping_status":"closed","template":"","meta":{"test_single":"","test_multi":[],"test_bad_auth":"","test_bad_auth_multi":[],"test_custom_schema":0,"test_custom_schema_multi":[],"new_name":"","new_name_multi":[],"test_string":"","test_number":0,"test_bool":false,"my_meta_key":[]},"description":{"rendered":"

\"\"<\/a><\/p>\n"},"caption":{"rendered":"

A sample caption<\/p>\n"},"alt_text":"","media_type":"image","mime_type":"image\/jpeg","media_details":{},"post":null,"source_url":"http:\/\/example.org\/wp-content\/uploads\/\/tmp\/canola.jpg","_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/media\/1370"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/media"}],"about":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/types\/attachment"}],"author":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users\/354"}],"replies":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fcomments&post=1370"}]}}]; + +mockedApiResponse.MediaModel = {"id":1370,"date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","guid":{"rendered":"http:\/\/example.org\/?attachment_id=1370"},"modified":"2017-02-14T04:05:35","modified_gmt":"2017-02-14T04:05:35","slug":"1370","type":"attachment","link":"http:\/\/example.org\/?attachment_id=1370","title":{"rendered":""},"author":354,"comment_status":"open","ping_status":"closed","template":"","meta":{"test_single":"","test_multi":[],"test_bad_auth":"","test_bad_auth_multi":[],"test_custom_schema":0,"test_custom_schema_multi":[],"new_name":"","new_name_multi":[],"test_string":"","test_number":0,"test_bool":false,"my_meta_key":[]},"description":{"rendered":"

\"\"<\/a><\/p>\n"},"caption":{"rendered":"

A sample caption<\/p>\n"},"alt_text":"","media_type":"image","mime_type":"image\/jpeg","media_details":{},"post":null,"source_url":"http:\/\/example.org\/wp-content\/uploads\/\/tmp\/canola.jpg"}; + +mockedApiResponse.TypesCollection = {"post":{"description":"","hierarchical":false,"name":"Posts","slug":"post","taxonomies":["category","post_tag"],"rest_base":"posts","_links":{"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/types"}],"wp:items":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},"page":{"description":"","hierarchical":true,"name":"Pages","slug":"page","taxonomies":[],"rest_base":"pages","_links":{"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/types"}],"wp:items":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},"attachment":{"description":"","hierarchical":false,"name":"Media","slug":"attachment","taxonomies":[],"rest_base":"media","_links":{"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/types"}],"wp:items":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/media"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}}; + +mockedApiResponse.TypeModel = {"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}; + +mockedApiResponse.StatusesCollection = {"publish":{"name":"Published","public":true,"queryable":true,"slug":"publish","_links":{"archives":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts"}]}},"future":{"name":"Scheduled","public":false,"queryable":false,"slug":"future","_links":{"archives":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fposts&status=future"}]}},"draft":{"name":"Draft","public":false,"queryable":false,"slug":"draft","_links":{"archives":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fposts&status=draft"}]}},"pending":{"name":"Pending","public":false,"queryable":false,"slug":"pending","_links":{"archives":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fposts&status=pending"}]}},"private":{"name":"Private","public":false,"queryable":false,"slug":"private","_links":{"archives":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fposts&status=private"}]}},"trash":{"name":"Trash","public":false,"queryable":false,"slug":"trash","_links":{"archives":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fposts&status=trash"}]}}}; + +mockedApiResponse.StatusModel = {"name":"Published","public":true,"queryable":true,"slug":"publish"}; + +mockedApiResponse.TaxonomiesCollection = {"category":{"name":"Categories","slug":"category","description":"","types":["post"],"hierarchical":true,"rest_base":"categories","_links":{"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/taxonomies"}],"wp:items":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/categories"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}},"post_tag":{"name":"Tags","slug":"post_tag","description":"","types":["post"],"hierarchical":false,"rest_base":"tags","_links":{"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/taxonomies"}],"wp:items":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/tags"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}}; + +mockedApiResponse.TaxonomyModel = {"name":"Categories","slug":"category","description":"","types":["post"],"hierarchical":true,"rest_base":"categories"}; + +mockedApiResponse.CategoriesCollection = [{"id":1,"count":1,"description":"","link":"http:\/\/example.org\/?cat=1","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","parent":0,"meta":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/categories\/1"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/categories"}],"about":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/taxonomies\/category"}],"wp:post_type":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fposts&categories=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]; + +mockedApiResponse.CategoryModel = {"id":1,"count":1,"description":"","link":"http:\/\/example.org\/?cat=1","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","parent":0,"meta":[]}; + +mockedApiResponse.TagsCollection = [{"id":685,"count":0,"description":"Term description 6210","link":"http:\/\/example.org\/?tag=test","name":"test","slug":"test","taxonomy":"post_tag","meta":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/tags\/685"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/tags"}],"about":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/taxonomies\/post_tag"}],"wp:post_type":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fposts&tags=685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}]; + +mockedApiResponse.TagModel = {"id":685,"count":0,"description":"Term description 6210","link":"http:\/\/example.org\/?tag=test","name":"test","slug":"test","taxonomy":"post_tag","meta":[]}; + +mockedApiResponse.UsersCollection = [{"id":1,"name":"admin","url":"","description":"","link":"http:\/\/example.org\/?author=1","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/96614ec98aa0c0d2ee75796dced6df54?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/96614ec98aa0c0d2ee75796dced6df54?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/96614ec98aa0c0d2ee75796dced6df54?s=96&d=mm&r=g"},"meta":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users\/1"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users"}]}},{"id":354,"name":"User 6207","url":"","description":"","link":"http:\/\/example.org\/?author=354","slug":"user-6207","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/3d42d2573c72bce413cf299f434ccf19?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/3d42d2573c72bce413cf299f434ccf19?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/3d42d2573c72bce413cf299f434ccf19?s=96&d=mm&r=g"},"meta":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users\/354"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users"}]}}]; + +mockedApiResponse.UserModel = {"id":1,"name":"admin","url":"","description":"","link":"http:\/\/example.org\/?author=1","slug":"admin","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/96614ec98aa0c0d2ee75796dced6df54?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/96614ec98aa0c0d2ee75796dced6df54?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/96614ec98aa0c0d2ee75796dced6df54?s=96&d=mm&r=g"},"meta":[]}; + +mockedApiResponse.me = {"id":354,"name":"User 6207","url":"","description":"","link":"http:\/\/example.org\/?author=354","slug":"user-6207","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/3d42d2573c72bce413cf299f434ccf19?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/3d42d2573c72bce413cf299f434ccf19?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/3d42d2573c72bce413cf299f434ccf19?s=96&d=mm&r=g"},"meta":[]}; + +mockedApiResponse.CommentsCollection = [{"id":1103,"post":1368,"parent":0,"author":0,"author_name":"Commenter 6211","author_url":"http:\/\/example.com\/6211\/","date":"2017-02-14T04:05:35","date_gmt":"2017-02-14T04:05:35","content":{"rendered":"

This is a comment<\/p>\n"},"link":"http:\/\/example.org\/?p=1368#comment-1103","status":"approved","type":"comment","author_avatar_urls":{"24":"http:\/\/1.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/1.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"meta":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/comments\/1103"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/comments"}],"up":[{"embeddable":true,"post_type":"post","href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts\/1368"}]}}]; + +mockedApiResponse.CommentModel = {"code":"rest_comment_invalid_id","message":"Invalid comment ID.","data":{"status":404}}; + +mockedApiResponse.settings = {"title":"Test Blog","description":"Just another WordPress site","url":"http:\/\/example.org","email":"admin@example.org","timezone":"","date_format":"F j, Y","time_format":"g:i a","start_of_week":1,"language":"en_US","use_smilies":true,"default_category":1,"default_post_format":"0","posts_per_page":10,"default_ping_status":"open","default_comment_status":"open"}; + diff --git a/tests/qunit/fixtures/wp-api.js b/tests/qunit/fixtures/wp-api.js new file mode 100644 index 0000000000..cbbc484174 --- /dev/null +++ b/tests/qunit/fixtures/wp-api.js @@ -0,0 +1,55 @@ +/* global mockedApiResponse, Backbone */ +/** + * @var mockedApiResponse defined in wp-api-generated.js + */ + +var pathToData = { + 'wp-json/wp/v2/': mockedApiResponse.Schema, + 'wp-json/wp/v2/categories': mockedApiResponse.CategoriesCollection, + 'wp-json/wp/v2/comments': mockedApiResponse.CommentsCollection, + 'wp-json/wp/v2/media': mockedApiResponse.MediaCollection, + 'wp-json/wp/v2/pages': mockedApiResponse.PagesCollection, + 'wp-json/wp/v2/posts': mockedApiResponse.PostsCollection, + 'wp-json/wp/v2/statuses': mockedApiResponse.StatusesCollection, + 'wp-json/wp/v2/tags': mockedApiResponse.TagsCollection, + 'wp-json/wp/v2/taxonomies': mockedApiResponse.TaxonomiesCollection, + 'wp-json/wp/v2/types': mockedApiResponse.TypesCollection, + 'wp-json/wp/v2/users': mockedApiResponse.UsersCollection, + 'wp-json/wp/v2/category': mockedApiResponse.CategoryModel, + 'wp-json/wp/v2/media1': mockedApiResponse.MediaModel, + 'wp-json/wp/v2/page': mockedApiResponse.PageModel, + 'wp-json/wp/v2/post': mockedApiResponse.PostModel, + 'wp-json/wp/v2/tag': mockedApiResponse.TagModel, + 'wp-json/wp/v2/user': mockedApiResponse.UserModel, + 'wp-json/wp/v2/taxonomy': mockedApiResponse.TaxonomyModel, + 'wp-json/wp/v2/status': mockedApiResponse.StatusModel, + 'wp-json/wp/v2/type': mockedApiResponse.TypeModel +}; + +/** + * Mock the ajax callbacks for our tests. + * + * @param {object} param The parameters sent to the ajax request. + * + * @return {Object} A jQuery defered object that resolves with the mapped data. + */ +Backbone.ajax = function ( param ) { + + var data, + request = param.url.replace( 'http://localhost/', '' ); + + if ( pathToData[ request ] ) { + data = pathToData[ request ]; + } + + // Call success handler. + param.success( data ); + var deferred = jQuery.Deferred(); + + // Resolve the deferred with the mocked data + deferred.resolve( data ); + + // Return the deferred promise that will resolve with the expected data. + return deferred.promise(); + +}; diff --git a/tests/qunit/index.html b/tests/qunit/index.html index 58591e4860..0b6930fe1c 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -17,6 +17,11 @@ } }; + @@ -34,6 +39,8 @@ + +

TinyMCE tests

@@ -43,6 +50,7 @@ + @@ -61,6 +69,7 @@ + diff --git a/tests/qunit/wp-includes/js/wp-api.js b/tests/qunit/wp-includes/js/wp-api.js new file mode 100644 index 0000000000..5225d9e254 --- /dev/null +++ b/tests/qunit/wp-includes/js/wp-api.js @@ -0,0 +1,195 @@ +/* global wp */ +( function( QUnit ) { + module( 'wpapi' ); + + QUnit.test( 'API Loaded correctly', function( assert ) { + var done = assert.async(); + assert.expect( 2 ); + + assert.ok( wp.api.loadPromise ); + + wp.api.loadPromise.done( function() { + assert.ok( wp.api.models ); + done(); + } ); + + } ); + + // The list of collections we should check. + var collectionClassNames = [ + 'Categories', + 'Comments', + 'Media', + 'Pages', + 'Posts', + 'Statuses', + 'Tags', + 'Taxonomies', + 'Types', + 'Users' + ]; + + // Collections that should get helpers tested. + var collectionHelperTests = [ + { + 'collectionType': 'Posts', + 'returnsModelType': 'post', + 'supportsMethods': { + 'getDate': 'getDate', + 'getRevisions': 'getRevisions', + 'getTags': 'getTags', + 'getCategories': 'getCategories', + 'getAuthorUser': 'getAuthorUser', + 'getFeaturedMedia': 'getFeaturedMedia' + /*'getMeta': 'getMeta', currently not supported */ + } + }, + { + 'collectionType': 'Pages', + 'returnsModelType': 'page', + 'supportsMethods': { + 'getDate': 'getDate', + 'getRevisions': 'getRevisions', + 'getAuthorUser': 'getAuthorUser', + 'getFeaturedMedia': 'getFeaturedMedia' + } + } + ]; + + _.each( collectionClassNames, function( className ) { + QUnit.test( 'Testing ' + className + ' collection.', function( assert ) { + var done = assert.async(); + + wp.api.loadPromise.done( function() { + var theCollection = new wp.api.collections[ className ](); + assert.ok( + theCollection, + 'We can instantiate wp.api.collections.' + className + ); + theCollection.fetch().done( function() { + assert.equal( + 1, + theCollection.state.currentPage, + 'We should be on page 1 of the collection in ' + className + ); + + // Should this collection have helper methods? + var collectionHelperTest = _.findWhere( collectionHelperTests, { 'collectionType': className } ); + + // If we found a match, run the tests against it. + if ( ! _.isUndefined( collectionHelperTest ) ) { + + // Test the first returned model. + var firstModel = theCollection.at( 0 ); + + // Is the model the right type? + assert.equal( + collectionHelperTest.returnsModelType, + firstModel.get( 'type' ), + 'The wp.api.collections.' + className + ' is of type ' + collectionHelperTest.returnsModelType + ); + + // Does the model have all of the expected supported methods? + _.each( collectionHelperTest.supportsMethods, function( method ) { + assert.equal( + 'function', + typeof firstModel[ method ], + className + '.' + method + ' is a function.' + ); + } ); + } + + // Trigger Qunit async completion. + done(); + } ); + + } ); + + } ); + } ); + + // The list of models we should check. + var modelsWithIdsClassNames = [ + 'Category', + 'Media', + 'Page', + 'Post', + 'Tag', + 'User' + ]; + + _.each( modelsWithIdsClassNames, function( className ) { + + QUnit.test( 'Checking ' + className + ' model.' , function( assert ) { + var done = assert.async(); + + assert.expect( 2 ); + + wp.api.loadPromise.done( function() { + var theModel = new wp.api.models[ className ](); + assert.ok( theModel, 'We can instantiate wp.api.models.' + className ); + theModel.fetch().done( function( ) { + var theModel2 = new wp.api.models[ className ](); + theModel2.set( 'id', theModel.attributes[0].id ); + theModel2.fetch().done( function() { + + // We were able to retrieve the model. + assert.equal( + theModel.attributes[0].id, + theModel2.get( 'id' ) , + 'We should be able to get a ' + className + ); + + // Trigger Qunit async completion. + done(); + } ); + } ); + + } ); + + } ); + } ); + + var modelsWithIndexes = [ + 'Taxonomy', + 'Status', + 'Type' + ]; + + _.each( modelsWithIndexes, function( className ) { + + QUnit.test( 'Testing ' + className + ' model.' , function( assert ) { + var done = assert.async(); + + assert.expect( 2 ); + + wp.api.loadPromise.done( function( ) { + + var theModel = new wp.api.models[ className ](); + assert.ok( theModel, 'We can instantiate wp.api.models.' + className ); + theModel.fetch().done( function( ) { + var theModel2 = new wp.api.models[ className ](); + + if ( ! _.isUndefined( theModel.attributes[0] ) ) { + theModel2.set( 'id', theModel.attributes[0].id ); + } + + theModel2.fetch().done( function() { + // We were able to retrieve the model. + assert.notEqual( + 0, + _.keys( theModel2.attributes ).length , + 'We should be able to get a ' + className + ); + + // Trigger Qunit async completion. + done(); + } ); + } ); + + } ); + + } ); + } ); + +} )( window.QUnit );