WordPress.org

Make WordPress Core

Ticket #39264: 39264.7.diff

File 39264.7.diff, 83.5 KB (added by adamsilverstein, 3 years ago)

slight cleanup for jshint

  • Gruntfile.js

    diff --git Gruntfile.js Gruntfile.js
    index 5a9317c..92aa12d 100644
    module.exports = function(grunt) { 
    439439                        'external-http': {
    440440                                cmd: 'phpunit',
    441441                                args: ['-c', 'phpunit.xml.dist', '--group', 'external-http']
     442                        },
     443                        'restapi-jsclient': {
     444                                cmd: 'phpunit',
     445                                args: ['-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient']
    442446                        }
    443447                },
    444448                uglify: {
    module.exports = function(grunt) { 
    672676                'jshint:media'
    673677        ] );
    674678
     679        grunt.registerTask( 'restapi-jsclient', [
     680                'phpunit:restapi-jsclient',
     681                'qunit'
     682        ] );
     683
    675684        grunt.renameTask( 'watch', '_watch' );
    676685
    677686        grunt.registerTask( 'watch', function() {
  • new file tests/phpunit/tests/rest-api/rest-schema-setup.php

    diff --git tests/phpunit/tests/rest-api/rest-schema-setup.php tests/phpunit/tests/rest-api/rest-schema-setup.php
    new file mode 100644
    index 0000000..ae2f3cd
    - +  
     1<?php
     2/**
     3 * Unit tests covering schema initialization.
     4 *
     5 * Also generates the fixture data used by the wp-api.js QUnit tests.
     6 *
     7 * @package WordPress
     8 * @subpackage REST API
     9 */
     10
     11/**
     12 * @group restapi
     13 * @group restapi-jsclient
     14 */
     15class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
     16
     17        public function setUp() {
     18                parent::setUp();
     19
     20                /** @var WP_REST_Server $wp_rest_server */
     21                global $wp_rest_server;
     22                $this->server = $wp_rest_server = new Spy_REST_Server;
     23                do_action( 'rest_api_init' );
     24        }
     25
     26        public function tearDown() {
     27                parent::tearDown();
     28                remove_filter( 'rest_url', array( $this, 'test_rest_url_for_leading_slash' ), 10, 2 );
     29                /** @var WP_REST_Server $wp_rest_server */
     30                global $wp_rest_server;
     31                $wp_rest_server = null;
     32        }
     33
     34        public function test_expected_routes_in_schema() {
     35                $routes = $this->server->get_routes();
     36
     37                $this->assertTrue( is_array( $routes ), '`get_routes` should return an array.' );
     38                $this->assertTrue( ! empty( $routes ), 'Routes should not be empty.' );
     39
     40                $expected_routes = array(
     41                        '/',
     42                        '/oembed/1.0',
     43                        '/oembed/1.0/embed',
     44                        '/wp/v2',
     45                        '/wp/v2/posts',
     46                        '/wp/v2/posts/(?P<id>[\\d]+)',
     47                        '/wp/v2/posts/(?P<parent>[\\d]+)/revisions',
     48                        '/wp/v2/posts/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)',
     49                        '/wp/v2/pages',
     50                        '/wp/v2/pages/(?P<id>[\\d]+)',
     51                        '/wp/v2/pages/(?P<parent>[\\d]+)/revisions',
     52                        '/wp/v2/pages/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)',
     53                        '/wp/v2/media',
     54                        '/wp/v2/media/(?P<id>[\\d]+)',
     55                        '/wp/v2/types',
     56                        '/wp/v2/types/(?P<type>[\\w-]+)',
     57                        '/wp/v2/statuses',
     58                        '/wp/v2/statuses/(?P<status>[\\w-]+)',
     59                        '/wp/v2/taxonomies',
     60                        '/wp/v2/taxonomies/(?P<taxonomy>[\\w-]+)',
     61                        '/wp/v2/categories',
     62                        '/wp/v2/categories/(?P<id>[\\d]+)',
     63                        '/wp/v2/tags',
     64                        '/wp/v2/tags/(?P<id>[\\d]+)',
     65                        '/wp/v2/users',
     66                        '/wp/v2/users/(?P<id>[\\d]+)',
     67                        '/wp/v2/users/me',
     68                        '/wp/v2/comments',
     69                        '/wp/v2/comments/(?P<id>[\\d]+)',
     70                        '/wp/v2/settings',
     71                );
     72
     73                $this->assertEquals( $expected_routes, array_keys( $routes ) );
     74        }
     75
     76        public function test_build_wp_api_client_fixtures() {
     77                // Set up for testing the individual endpoints.
     78                // Set a current admin user.
     79                $administrator = $this->factory->user->create( array(
     80                        'role' => 'administrator',
     81                ) );
     82                wp_set_current_user( $administrator );
     83
     84                // Set up data for endpoints.
     85                $post_id  = $this->factory->post->create();
     86                $page_id  = $this->factory->post->create( array( 'post_type' => 'page' ) );
     87                $tag_id   = $this->factory->tag->create( array( 'name' => 'test' ) );
     88                $media_id = $this->factory->attachment->create_object( '/tmp/canola.jpg', 0, array(
     89                        'post_mime_type' => 'image/jpeg',
     90                        'post_excerpt'   => 'A sample caption',
     91                ) );
     92                wp_update_post( array( 'post_content' => 'Updated content.', 'ID' => $post_id ) );
     93                wp_update_post( array( 'post_content' => 'Updated content.', 'ID' => $page_id ) );
     94                $comment_id = $this->factory->comment->create( array(
     95                        'comment_approved' => 1,
     96                        'comment_post_ID'  => $post_id,
     97                        'user_id'          => 0,
     98                ) );
     99
     100                // Generate route data for subsequent QUnit tests.
     101                $routes_to_generate_data = array(
     102                        array(
     103                                'route' => '/',
     104                                'name'  => 'Schema',
     105                        ),
     106                        array(
     107                                'route' => '/oembed/1.0',
     108                                'name'  => 'oembed',
     109                        ),
     110                        array(
     111                                'route' => '/oembed/1.0/embed',
     112                                'name'  => 'oembeds',
     113                        ),
     114                        array(
     115                                'route' => '/wp/v2/posts',
     116                                'name'  => 'PostsCollection',
     117                        ),
     118                        array(
     119                                'route' => '/wp/v2/posts/' . $post_id,
     120                                'name'  => 'PostModel',
     121                        ),
     122                        array(
     123                                'route' => '/wp/v2/posts/' . $post_id . '/revisions',
     124                                'name'  => 'postRevisions',
     125                        ),
     126                        array(
     127                                'route' => '/wp/v2/posts/' . $post_id . '/revisions/1',
     128                                'name'  => 'revision',
     129                        ),
     130                        array(
     131                                'route' => '/wp/v2/pages',
     132                                'name'  => 'PagesCollection',
     133                        ),
     134                        array(
     135                                'route' => '/wp/v2/pages/' . $page_id,
     136                                'name'  => 'PageModel',
     137                        ),
     138                        array(
     139                                'route' => '/wp/v2/pages/'. $page_id . '/revisions',
     140                                'name'  => 'pageRevisions',
     141                        ),
     142                        array(
     143                                'route' => '/wp/v2/pages/'. $page_id . '/revisions/1',
     144                                'name'  => 'pageRevision',
     145                        ),
     146                        array(
     147                                'route' => '/wp/v2/media',
     148                                'name'  => 'MediaCollection',
     149                        ),
     150                        array(
     151                                'route' => '/wp/v2/media/' . $media_id,
     152                                'name'  => 'MediaModel',
     153                        ),
     154                        array(
     155                                'route' => '/wp/v2/types',
     156                                'name'  => 'TypesCollection',
     157                        ),
     158                        array(
     159                                'route' => '/wp/v2/types/',
     160                                'name'  => 'TypeModel',
     161                        ),
     162                        array(
     163                                'route' => '/wp/v2/statuses',
     164                                'name'  => 'StatusesCollection',
     165                        ),
     166                        array(
     167                                'route' => '/wp/v2/statuses/publish',
     168                                'name'  => 'StatusModel',
     169                        ),
     170                        array(
     171                                'route' => '/wp/v2/taxonomies',
     172                                'name'  => 'TaxonomiesCollection',
     173                        ),
     174                        array(
     175                                'route' => '/wp/v2/taxonomies/category',
     176                                'name'  => 'TaxonomyModel',
     177                        ),
     178                        array(
     179                                'route' => '/wp/v2/categories',
     180                                'name'  => 'CategoriesCollection',
     181                        ),
     182                        array(
     183                                'route' => '/wp/v2/categories/1',
     184                                'name'  => 'CategoryModel',
     185                        ),
     186                        array(
     187                                'route' => '/wp/v2/tags',
     188                                'name'  => 'TagsCollection',
     189                        ),
     190                        array(
     191                                'route' => '/wp/v2/tags/' . $tag_id,
     192                                'name'  => 'TagModel',
     193                        ),
     194                        array(
     195                                'route' => '/wp/v2/users',
     196                                'name'  => 'UsersCollection',
     197                        ),
     198                        array(
     199                                'route' => '/wp/v2/users/1',
     200                                'name'  => 'UserModel',
     201                        ),
     202                        array(
     203                                'route' => '/wp/v2/users/me',
     204                                'name'  => 'me',
     205                        ),
     206                        array(
     207                                'route' => '/wp/v2/comments',
     208                                'name'  => 'CommentsCollection',
     209                        ),
     210                        array(
     211                                'route' => '/wp/v2/comments/1',
     212                                'name'  => 'CommentModel',
     213                        ),
     214                        array(
     215                                'route' => '/wp/v2/settings',
     216                                'name'  => 'settings',
     217                        ),
     218                );
     219
     220                // Set up the mocked response and tell jshint to ignore the single quote json objects
     221                $mocked_responses = "/*jshint -W109 */\n\nvar mockedApiResponse = {};\n\n";
     222                $mocked_responses .= "/**\n";
     223                $mocked_responses .= " * DO NOT EDIT\n";
     224                $mocked_responses .= " * Auto-generated by test_build_wp_api_client_fixtures\n";
     225                $mocked_responses .= " */\n";
     226
     227                foreach ( $routes_to_generate_data as $route ) {
     228                        $request = new WP_REST_Request( 'GET', $route['route'] );
     229                        $response = $this->server->dispatch( $request );
     230                        $data = $response->get_data();
     231
     232                        $this->assertTrue( ! empty( $data ), $route['name'] . ' route should return data.' );
     233
     234                        $mocked_responses .= 'mockedApiResponse.' . $route['name'] . ' = ' . wp_json_encode( $data ) . ";\n\n";
     235                }
     236
     237                // Save the route object for QUnit tests.
     238                $file = './tests/qunit/fixtures/wp-api-generated.js';
     239                file_put_contents( $file, $mocked_responses );
     240
     241                // Clean up our test data.
     242                wp_delete_post( $post_id, true );
     243                wp_delete_post( $page_id, true );
     244                wp_delete_term( $tag_id, 'tags' );
     245                wp_delete_attachment( $media_id );
     246                wp_delete_comment( $comment_id );
     247        }
     248}
  • new file tests/qunit/fixtures/wp-api-generated.js

    diff --git tests/qunit/fixtures/wp-api-generated.js tests/qunit/fixtures/wp-api-generated.js
    new file mode 100644
    index 0000000..f21b6b5
    - +  
     1/*jshint -W109 */
     2
     3var mockedApiResponse = {};
     4
     5/**
     6 * DO NOT EDIT
     7 * Auto-generated by test_build_wp_api_client_fixtures
     8 */
     9mockedApiResponse.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<id>[\\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<parent>[\\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<parent>[\\d]+)\/revisions\/(?P<id>[\\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<id>[\\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<parent>[\\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<parent>[\\d]+)\/revisions\/(?P<id>[\\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<id>[\\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<type>[\\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<status>[\\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<taxonomy>[\\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<id>[\\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<id>[\\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<id>[\\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<id>[\\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"}}}};
     10
     11mockedApiResponse.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"}}}};
     12
     13mockedApiResponse.oembeds = {"code":"rest_missing_callback_param","message":"Missing parameter(s): url","data":{"status":400,"params":["url"]}};
     14
     15mockedApiResponse.PostsCollection = [{"id":3,"date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","guid":{"rendered":"http:\/\/example.org\/?p=3"},"modified":"2017-02-14T02:33:53","modified_gmt":"2017-02-14T02:33:53","slug":"post-title-19","type":"post","link":"http:\/\/example.org\/?p=3","title":{"rendered":"Post title 19"},"content":{"rendered":"<p>Updated content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post excerpt 19<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts\/3"}],"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\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fcomments&post=3"}],"version-history":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts\/3\/revisions"}],"wp:attachment":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fcategories&post=3"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Ftags&post=3"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}];
     16
     17mockedApiResponse.PostModel = {"id":3,"date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","guid":{"rendered":"http:\/\/example.org\/?p=3"},"modified":"2017-02-14T02:33:53","modified_gmt":"2017-02-14T02:33:53","slug":"post-title-19","type":"post","link":"http:\/\/example.org\/?p=3","title":{"rendered":"Post title 19"},"content":{"rendered":"<p>Updated content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post excerpt 19<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[]};
     18
     19mockedApiResponse.postRevisions = [{"author":"2","date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","id":6,"modified":"2017-02-14T02:33:53","modified_gmt":"2017-02-14T02:33:53","parent":3,"slug":"3-revision-v1","guid":{"rendered":"http:\/\/example.org\/?p=6"},"title":{"rendered":"Post title 19"},"content":{"rendered":"<p>Updated content.<\/p>\n"},"excerpt":{"rendered":"<p>Post excerpt 19<\/p>\n"},"_links":{"parent":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/posts\/3"}]}}];
     20
     21mockedApiResponse.revision = {"code":"rest_post_invalid_id","message":"Invalid revision ID.","data":{"status":404}};
     22
     23mockedApiResponse.PagesCollection = [{"id":4,"date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","guid":{"rendered":"http:\/\/example.org\/?page_id=4"},"modified":"2017-02-14T02:33:53","modified_gmt":"2017-02-14T02:33:53","slug":"post-title-20","type":"page","link":"http:\/\/example.org\/?page_id=4","title":{"rendered":"Post title 20"},"content":{"rendered":"<p>Updated content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post excerpt 20<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages\/4"}],"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\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fcomments&post=4"}],"version-history":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages\/4\/revisions"}],"wp:attachment":[{"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}];
     24
     25mockedApiResponse.PageModel = {"id":4,"date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","guid":{"rendered":"http:\/\/example.org\/?page_id=4"},"modified":"2017-02-14T02:33:53","modified_gmt":"2017-02-14T02:33:53","slug":"post-title-20","type":"page","link":"http:\/\/example.org\/?page_id=4","title":{"rendered":"Post title 20"},"content":{"rendered":"<p>Updated content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post excerpt 20<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[]};
     26
     27mockedApiResponse.pageRevisions = [{"author":"2","date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","id":7,"modified":"2017-02-14T02:33:53","modified_gmt":"2017-02-14T02:33:53","parent":4,"slug":"4-revision-v1","guid":{"rendered":"http:\/\/example.org\/?p=7"},"title":{"rendered":"Post title 20"},"content":{"rendered":"<p>Updated content.<\/p>\n"},"excerpt":{"rendered":"<p>Post excerpt 20<\/p>\n"},"_links":{"parent":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/pages\/4"}]}}];
     28
     29mockedApiResponse.pageRevision = {"code":"rest_post_invalid_id","message":"Invalid revision ID.","data":{"status":404}};
     30
     31mockedApiResponse.MediaCollection = [{"id":5,"date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","guid":{"rendered":"http:\/\/example.org\/?attachment_id=5"},"modified":"2017-02-14T02:33:53","modified_gmt":"2017-02-14T02:33:53","slug":"5","type":"attachment","link":"http:\/\/example.org\/?attachment_id=5","title":{"rendered":""},"author":2,"comment_status":"open","ping_status":"closed","template":"","meta":[],"description":{"rendered":"<p class=\"attachment\"><a href='http:\/\/example.org\/wp-content\/uploads\/\/tmp\/canola.jpg'><img width=\"1\" height=\"1\" src=\"http:\/\/example.org\/wp-content\/uploads\/\/tmp\/canola.jpg\" class=\"attachment-medium size-medium\" alt=\"\" \/><\/a><\/p>\n"},"caption":{"rendered":"<p>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\/5"}],"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\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/example.org\/?rest_route=%2Fwp%2Fv2%2Fcomments&post=5"}]}}];
     32
     33mockedApiResponse.MediaModel = {"id":5,"date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","guid":{"rendered":"http:\/\/example.org\/?attachment_id=5"},"modified":"2017-02-14T02:33:53","modified_gmt":"2017-02-14T02:33:53","slug":"5","type":"attachment","link":"http:\/\/example.org\/?attachment_id=5","title":{"rendered":""},"author":2,"comment_status":"open","ping_status":"closed","template":"","meta":[],"description":{"rendered":"<p class=\"attachment\"><a href='http:\/\/example.org\/wp-content\/uploads\/\/tmp\/canola.jpg'><img width=\"1\" height=\"1\" src=\"http:\/\/example.org\/wp-content\/uploads\/\/tmp\/canola.jpg\" class=\"attachment-medium size-medium\" alt=\"\" \/><\/a><\/p>\n"},"caption":{"rendered":"<p>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"};
     34
     35mockedApiResponse.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}]}}};
     36
     37mockedApiResponse.TypeModel = {"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}};
     38
     39mockedApiResponse.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"}]}}};
     40
     41mockedApiResponse.StatusModel = {"name":"Published","public":true,"queryable":true,"slug":"publish"};
     42
     43mockedApiResponse.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}]}}};
     44
     45mockedApiResponse.TaxonomyModel = {"name":"Categories","slug":"category","description":"","types":["post"],"hierarchical":true,"rest_base":"categories"};
     46
     47mockedApiResponse.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}]}}];
     48
     49mockedApiResponse.CategoryModel = {"id":1,"count":1,"description":"","link":"http:\/\/example.org\/?cat=1","name":"Uncategorized","slug":"uncategorized","taxonomy":"category","parent":0,"meta":[]};
     50
     51mockedApiResponse.TagsCollection = [{"id":2,"count":0,"description":"Term description 21","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\/2"}],"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=2"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}];
     52
     53mockedApiResponse.TagModel = {"id":2,"count":0,"description":"Term description 21","link":"http:\/\/example.org\/?tag=test","name":"test","slug":"test","taxonomy":"post_tag","meta":[]};
     54
     55mockedApiResponse.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":2,"name":"User 18","url":"","description":"","link":"http:\/\/example.org\/?author=2","slug":"user-18","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/cd631944deab1f0589fedb77b3735377?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/cd631944deab1f0589fedb77b3735377?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/cd631944deab1f0589fedb77b3735377?s=96&d=mm&r=g"},"meta":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users\/2"}],"collection":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/users"}]}}];
     56
     57mockedApiResponse.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":[]};
     58
     59mockedApiResponse.me = {"id":2,"name":"User 18","url":"","description":"","link":"http:\/\/example.org\/?author=2","slug":"user-18","avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/cd631944deab1f0589fedb77b3735377?s=24&d=mm&r=g","48":"http:\/\/0.gravatar.com\/avatar\/cd631944deab1f0589fedb77b3735377?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/cd631944deab1f0589fedb77b3735377?s=96&d=mm&r=g"},"meta":[]};
     60
     61mockedApiResponse.CommentsCollection = [{"id":2,"post":3,"parent":0,"author":0,"author_name":"Commenter 22","author_url":"http:\/\/example.com\/22\/","date":"2017-02-14T02:33:53","date_gmt":"2017-02-14T02:33:53","content":{"rendered":"<p>This is a comment<\/p>\n"},"link":"http:\/\/example.org\/?p=3#comment-2","status":"approved","type":"comment","author_avatar_urls":{"24":"http:\/\/0.gravatar.com\/avatar\/?s=24&d=mm&r=g","48":"http:\/\/1.gravatar.com\/avatar\/?s=48&d=mm&r=g","96":"http:\/\/0.gravatar.com\/avatar\/?s=96&d=mm&r=g"},"meta":[],"_links":{"self":[{"href":"http:\/\/example.org\/?rest_route=\/wp\/v2\/comments\/2"}],"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\/3"}]}}];
     62
     63mockedApiResponse.CommentModel = {"code":"rest_comment_invalid_id","message":"Invalid comment ID.","data":{"status":404}};
     64
     65mockedApiResponse.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"};
     66
  • new file tests/qunit/fixtures/wp-api.js

    diff --git tests/qunit/fixtures/wp-api.js tests/qunit/fixtures/wp-api.js
    new file mode 100644
    index 0000000..cbbc484
    - +  
     1/* global mockedApiResponse, Backbone */
     2/**
     3 * @var mockedApiResponse defined in wp-api-generated.js
     4 */
     5
     6var pathToData = {
     7        'wp-json/wp/v2/': mockedApiResponse.Schema,
     8        'wp-json/wp/v2/categories': mockedApiResponse.CategoriesCollection,
     9        'wp-json/wp/v2/comments': mockedApiResponse.CommentsCollection,
     10        'wp-json/wp/v2/media': mockedApiResponse.MediaCollection,
     11        'wp-json/wp/v2/pages': mockedApiResponse.PagesCollection,
     12        'wp-json/wp/v2/posts': mockedApiResponse.PostsCollection,
     13        'wp-json/wp/v2/statuses': mockedApiResponse.StatusesCollection,
     14        'wp-json/wp/v2/tags': mockedApiResponse.TagsCollection,
     15        'wp-json/wp/v2/taxonomies': mockedApiResponse.TaxonomiesCollection,
     16        'wp-json/wp/v2/types': mockedApiResponse.TypesCollection,
     17        'wp-json/wp/v2/users': mockedApiResponse.UsersCollection,
     18        'wp-json/wp/v2/category': mockedApiResponse.CategoryModel,
     19        'wp-json/wp/v2/media1': mockedApiResponse.MediaModel,
     20        'wp-json/wp/v2/page': mockedApiResponse.PageModel,
     21        'wp-json/wp/v2/post': mockedApiResponse.PostModel,
     22        'wp-json/wp/v2/tag': mockedApiResponse.TagModel,
     23        'wp-json/wp/v2/user': mockedApiResponse.UserModel,
     24        'wp-json/wp/v2/taxonomy': mockedApiResponse.TaxonomyModel,
     25        'wp-json/wp/v2/status': mockedApiResponse.StatusModel,
     26        'wp-json/wp/v2/type': mockedApiResponse.TypeModel
     27};
     28
     29/**
     30 * Mock the ajax callbacks for our tests.
     31 *
     32 * @param  {object} param The parameters sent to the ajax request.
     33 *
     34 * @return {Object}       A jQuery defered object that resolves with the mapped data.
     35 */
     36Backbone.ajax = function ( param ) {
     37
     38        var data,
     39                request = param.url.replace( 'http://localhost/', '' );
     40
     41        if ( pathToData[ request ] ) {
     42                data = pathToData[ request ];
     43        }
     44
     45        // Call success handler.
     46        param.success( data );
     47        var deferred = jQuery.Deferred();
     48
     49        // Resolve the deferred with the mocked data
     50        deferred.resolve( data );
     51
     52        // Return the deferred promise that will resolve with the expected data.
     53        return deferred.promise();
     54
     55};
  • tests/qunit/index.html

    diff --git tests/qunit/index.html tests/qunit/index.html
    index 58591e4..0b6930f 100644
     
    1717                                }
    1818                        };
    1919                </script>
     20                <script>
     21                        var wpApiSettings = {
     22                                'root': 'http://localhost/wp-json/'
     23                        };
     24                </script>
    2025                <script src="../../src/wp-includes/js/wp-util.js"></script>
    2126                <script src="../../src/wp-includes/js/wp-a11y.js"></script>
    2227
     
    3439                        <script src="fixtures/customize-settings.js"></script>
    3540                        <script src="fixtures/customize-menus.js"></script>
    3641                        <script src="fixtures/customize-widgets.js"></script>
     42                        <script src="fixtures/wp-api-generated.js"></script>
     43                        <script src="fixtures/wp-api.js"></script>
    3744                </div>
    3845                <p><a href="editor">TinyMCE tests</a></p>
    3946
     
    4350                <script src="../../src/wp-includes/js/customize-models.js"></script>
    4451                <script src="../../src/wp-includes/js/shortcode.js"></script>
    4552                <script src="../../src/wp-admin/js/customize-controls.js"></script>
     53                <script src="../../src/wp-includes/js/wp-api.js"></script>
    4654
    4755                <script type='text/javascript' src='../../src/wp-includes/js/jquery/ui/core.js'></script>
    4856                <script type='text/javascript' src='../../src/wp-includes/js/jquery/ui/widget.js'></script>
     
    6169                <script src="wp-admin/js/customize-base.js"></script>
    6270                <script src="wp-admin/js/customize-header.js"></script>
    6371                <script src="wp-includes/js/shortcode.js"></script>
     72                <script src="wp-includes/js/wp-api.js"></script>
    6473                <script src="wp-admin/js/customize-controls.js"></script>
    6574                <script src="wp-admin/js/customize-controls-utils.js"></script>
    6675                <script src="wp-admin/js/customize-nav-menus.js"></script>
  • new file tests/qunit/wp-includes/js/wp-api.js

    diff --git tests/qunit/wp-includes/js/wp-api.js tests/qunit/wp-includes/js/wp-api.js
    new file mode 100644
    index 0000000..5225d9e
    - +  
     1/* global wp */
     2( function( QUnit ) {
     3        module( 'wpapi' );
     4
     5        QUnit.test( 'API Loaded correctly', function( assert ) {
     6                var done = assert.async();
     7                assert.expect( 2 );
     8
     9                assert.ok( wp.api.loadPromise );
     10
     11                wp.api.loadPromise.done( function() {
     12                        assert.ok( wp.api.models );
     13                        done();
     14                } );
     15
     16        } );
     17
     18        // The list of collections we should check.
     19        var collectionClassNames = [
     20                'Categories',
     21                'Comments',
     22                'Media',
     23                'Pages',
     24                'Posts',
     25                'Statuses',
     26                'Tags',
     27                'Taxonomies',
     28                'Types',
     29                'Users'
     30        ];
     31
     32        // Collections that should get helpers tested.
     33        var collectionHelperTests = [
     34                {
     35                        'collectionType':   'Posts',
     36                        'returnsModelType': 'post',
     37                        'supportsMethods':  {
     38                                'getDate':          'getDate',
     39                                'getRevisions':     'getRevisions',
     40                                'getTags':          'getTags',
     41                                'getCategories':    'getCategories',
     42                                'getAuthorUser':    'getAuthorUser',
     43                                'getFeaturedMedia': 'getFeaturedMedia'
     44                                /*'getMeta':        'getMeta', currently not supported */
     45                        }
     46                },
     47                {
     48                        'collectionType':   'Pages',
     49                        'returnsModelType': 'page',
     50                        'supportsMethods':  {
     51                                'getDate':          'getDate',
     52                                'getRevisions':     'getRevisions',
     53                                'getAuthorUser':    'getAuthorUser',
     54                                'getFeaturedMedia': 'getFeaturedMedia'
     55                        }
     56                }
     57        ];
     58
     59        _.each( collectionClassNames, function( className ) {
     60                QUnit.test( 'Testing ' + className + ' collection.', function( assert ) {
     61                        var done = assert.async();
     62
     63                        wp.api.loadPromise.done( function() {
     64                                var theCollection = new wp.api.collections[ className ]();
     65                                assert.ok(
     66                                        theCollection,
     67                                        'We can instantiate wp.api.collections.' + className
     68                                );
     69                                theCollection.fetch().done( function() {
     70                                        assert.equal(
     71                                                1,
     72                                                theCollection.state.currentPage,
     73                                                'We should be on page 1 of the collection in ' + className
     74                                        );
     75
     76                                                // Should this collection have helper methods?
     77                                                var collectionHelperTest = _.findWhere( collectionHelperTests, { 'collectionType': className } );
     78
     79                                                // If we found a match, run the tests against it.
     80                                                if ( ! _.isUndefined( collectionHelperTest ) ) {
     81
     82                                                        // Test the first returned model.
     83                                                        var firstModel = theCollection.at( 0 );
     84
     85                                                        // Is the model the right type?
     86                                                        assert.equal(
     87                                                                collectionHelperTest.returnsModelType,
     88                                                                firstModel.get( 'type' ),
     89                                                                'The wp.api.collections.' + className + ' is of type ' + collectionHelperTest.returnsModelType
     90                                                        );
     91
     92                                                        // Does the model have all of the expected supported methods?
     93                                                        _.each( collectionHelperTest.supportsMethods, function( method ) {
     94                                                                assert.equal(
     95                                                                        'function',
     96                                                                        typeof firstModel[ method ],
     97                                                                        className + '.' + method + ' is a function.'
     98                                                                );
     99                                                        } );
     100                                                }
     101
     102                                        // Trigger Qunit async completion.
     103                                        done();
     104                                } );
     105
     106                        } );
     107
     108                } );
     109        } );
     110
     111        // The list of models we should check.
     112        var modelsWithIdsClassNames = [
     113                'Category',
     114                'Media',
     115                'Page',
     116                'Post',
     117                'Tag',
     118                'User'
     119        ];
     120
     121        _.each( modelsWithIdsClassNames, function( className ) {
     122
     123                QUnit.test( 'Checking ' + className + ' model.' , function( assert ) {
     124                        var done = assert.async();
     125
     126                        assert.expect( 2 );
     127
     128                        wp.api.loadPromise.done( function() {
     129                                var theModel = new wp.api.models[ className ]();
     130                                assert.ok( theModel, 'We can instantiate wp.api.models.' + className );
     131                                theModel.fetch().done( function(  ) {
     132                                        var theModel2 = new wp.api.models[ className ]();
     133                                        theModel2.set( 'id', theModel.attributes[0].id );
     134                                        theModel2.fetch().done( function() {
     135
     136                                                // We were able to retrieve the model.
     137                                                assert.equal(
     138                                                        theModel.attributes[0].id,
     139                                                        theModel2.get( 'id' ) ,
     140                                                        'We should be able to get a ' + className
     141                                                );
     142
     143                                                // Trigger Qunit async completion.
     144                                                done();
     145                                        } );
     146                                } );
     147
     148                        } );
     149
     150                } );
     151        } );
     152
     153        var modelsWithIndexes = [
     154                'Taxonomy',
     155                'Status',
     156                'Type'
     157        ];
     158
     159        _.each( modelsWithIndexes, function( className ) {
     160
     161                QUnit.test( 'Testing ' + className + ' model.' , function( assert ) {
     162                        var done = assert.async();
     163
     164                        assert.expect( 2 );
     165
     166                        wp.api.loadPromise.done( function(  ) {
     167
     168                                var theModel = new wp.api.models[ className ]();
     169                                assert.ok( theModel, 'We can instantiate wp.api.models.' + className );
     170                                theModel.fetch().done( function(  ) {
     171                                        var theModel2 = new wp.api.models[ className ]();
     172
     173                                        if ( ! _.isUndefined( theModel.attributes[0] ) ) {
     174                                                theModel2.set( 'id', theModel.attributes[0].id );
     175                                        }
     176
     177                                        theModel2.fetch().done( function() {
     178                                                // We were able to retrieve the model.
     179                                                assert.notEqual(
     180                                                        0,
     181                                                        _.keys( theModel2.attributes ).length ,
     182                                                        'We should be able to get a ' + className
     183                                                );
     184
     185                                                // Trigger Qunit async completion.
     186                                                done();
     187                                        } );
     188                                } );
     189
     190                        } );
     191
     192                } );
     193        } );
     194
     195} )( window.QUnit );