<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[40117] branches/4.7: REST API: JavaScript client - improve route discovery for custom namespaces.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/40117">40117</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/40117","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-02-24 22:47:47 +0000 (Fri, 24 Feb 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>REST API: JavaScript client - improve route discovery for custom namespaces.

Fix parsing of custom namespace routes. Transform class names, removing dashes and capitalizing each word/route part so a route path of `widgets/recent-posts` becomes a collection with the name `WidgetsRecentPosts`. Correct parent route part when routes are longer than expected, reversing parse direction.

Props westonruter, jazbek, adamsilverstein, jnylen0.
Merges <a href="https://core.trac.wordpress.org/changeset/40074">[40074]</a> and <a href="https://core.trac.wordpress.org/changeset/40109">[40109]</a> to the 4.7 branch.
Fixes <a href="https://core.trac.wordpress.org/ticket/39561">#39561</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches47srcwpincludesjswpapijs">branches/4.7/src/wp-includes/js/wp-api.js</a></li>
<li><a href="#branches47testsqunitfixtureswpapijs">branches/4.7/tests/qunit/fixtures/wp-api.js</a></li>
<li><a href="#branches47testsqunitindexhtml">branches/4.7/tests/qunit/index.html</a></li>
<li><a href="#branches47testsqunitwpincludesjswpapijs">branches/4.7/tests/qunit/wp-includes/js/wp-api.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branches47testsqunitfixturesjswidgetsendpointjs">branches/4.7/tests/qunit/fixtures/js-widgets-endpoint.js</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#branches47">branches/4.7/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx" style="display: block; padding: 0 10px">Index: branches/4.7
</span><span class="cx" style="display: block; padding: 0 10px">===================================================================
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">--- branches/4.7 2017-02-24 22:33:05 UTC (rev 40116)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+++ branches/4.7  2017-02-24 22:47:47 UTC (rev 40117)
</ins><a id="branches47"></a>
<div class="propset"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Property changes: branches/4.7</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: svn:mergeinfo</h4></div>
<span class="cx" style="display: block; padding: 0 10px"> /branches/3.1:18031
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/3.3:20543
</span><span class="cx" style="display: block; padding: 0 10px"> /branches/3.4:21757
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/trunk:18512,39365,39367,39369,39371,39373,39375-39376,39378,39380,39382,39384,39386,39388,39390,39392-39393,39396-39397,39400,39402,39404,39406,39409,39411,39413,39415,39417-39420,39424,39426,39428,39430,39432-39434,39436,39438,39440,39442-39444,39447,39449-39451,39453,39455-39457,39460,39462,39464,39466,39468,39470-39471,39475,39477-39478,39482-39483,39487-39488,39490,39495-39496,39499,39502,39504,39506,39508,39510,39512,39514,39517,39520,39522,39545-39547,39557-39563,39565,39578,39580-39581,39584,39586,39594-39595,39597-39599,39601,39603,39612-39613,39616-39617,39619-39623,39626,39635,39640,39645,39649,39657,39659,39663,39677-39678,39680-39681,39684-39686,39688-39689,39692,39720,39742,39744,39759-39760,39772,39795,39807-39808,39831,39843,39848,39850,39912,39914,39923-39924,39949,39951-39952,39954,39956,39968,39992,39994,40030,40036,40039-40041,40045,40049,40055,40058,40061,40063-40066
 ,40068,40070,40077,40080,40082,40086,40089,40101,40104-40106,40108,40110
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/trunk:18512,39365,39367,39369,39371,39373,39375-39376,39378,39380,39382,39384,39386,39388,39390,39392-39393,39396-39397,39400,39402,39404,39406,39409,39411,39413,39415,39417-39420,39424,39426,39428,39430,39432-39434,39436,39438,39440,39442-39444,39447,39449-39451,39453,39455-39457,39460,39462,39464,39466,39468,39470-39471,39475,39477-39478,39482-39483,39487-39488,39490,39495-39496,39499,39502,39504,39506,39508,39510,39512,39514,39517,39520,39522,39545-39547,39557-39563,39565,39578,39580-39581,39584,39586,39594-39595,39597-39599,39601,39603,39612-39613,39616-39617,39619-39623,39626,39635,39640,39645,39649,39657,39659,39663,39677-39678,39680-39681,39684-39686,39688-39689,39692,39720,39742,39744,39759-39760,39772,39795,39807-39808,39831,39843,39848,39850,39912,39914,39923-39924,39949,39951-39952,39954,39956,39968,39992,39994,40030,40036,40039-40041,40045,40049,40055,40058,40061,40063-40066,
 40068,40070,40074,40077,40080,40082,40086,40089,40101,40104-40106,40108-40110
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="branches47srcwpincludesjswpapijs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/src/wp-includes/js/wp-api.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/src/wp-includes/js/wp-api.js 2017-02-24 22:33:05 UTC (rev 40116)
+++ branches/4.7/src/wp-includes/js/wp-api.js   2017-02-24 22:47:47 UTC (rev 40117)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -120,20 +120,51 @@
</span><span class="cx" style="display: block; padding: 0 10px">        };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Helper function that capitalizes the first word and camel cases any words starting
+        * after dashes, removing the dashes.
+        */
+       wp.api.utils.capitalizeAndCamelCaseDashes = function( str ) {
+               if ( _.isUndefined( str ) ) {
+                       return str;
+               }
+               str = wp.api.utils.capitalize( str );
+
+               return wp.api.utils.camelCaseDashes( str );
+       };
+
+       /**
+        * Helper function to camel case the letter after dashes, removing the dashes.
+        */
+       wp.api.utils.camelCaseDashes = function( str ) {
+               return str.replace( /-([a-z])/g, function( g ) {
+                       return g[ 1 ].toUpperCase();
+               } );
+       };
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Extract a route part based on negative index.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @param {string} route The endpoint route.
-        * @param {int}    part  The number of parts from the end of the route to retrieve. Default 1.
-        *                       Example route `/a/b/c`: part 1 is `c`, part 2 is `b`, part 3 is `a`.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @param {string}   route          The endpoint route.
+        * @param {int}      part           The number of parts from the end of the route to retrieve. Default 1.
+        *                                  Example route `/a/b/c`: part 1 is `c`, part 2 is `b`, part 3 is `a`.
+        * @param {string}  [versionString] Version string, defaults to `wp.api.versionString`.
+        * @param {boolean} [reverse]       Whether to reverse the order when extracting the route part. Optional, default false.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        wp.api.utils.extractRoutePart = function( route, part ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp.api.utils.extractRoutePart = function( route, part, versionString, reverse ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 var routeParts;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                part  = part || 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         part = part || 1;
+               versionString = versionString || wp.api.versionString;
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Remove versions string from route to avoid returning it.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                route = route.replace( wp.api.versionString, '' );
-               routeParts = route.split( '/' ).reverse();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( 0 === route.indexOf( '/' + versionString ) ) {
+                       route = route.substr( versionString.length + 1 );
+               }
+
+               routeParts = route.split( '/' );
+               if ( reverse ) {
+                       routeParts = routeParts.reverse();
+               }
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( _.isUndefined( routeParts[ --part ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        return '';
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1126,10 +1157,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                // Extract the name and any parent from the route.
</span><span class="cx" style="display: block; padding: 0 10px">                                var modelClassName,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                routeName  = wp.api.utils.extractRoutePart( modelRoute.index, 2 ),
-                                               parentName = wp.api.utils.extractRoutePart( modelRoute.index, 4 ),
-                                               routeEnd   = wp.api.utils.extractRoutePart( modelRoute.index, 1 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 routeName  = wp.api.utils.extractRoutePart( modelRoute.index, 2, routeModel.get( 'versionString' ), true ),
+                                       parentName = wp.api.utils.extractRoutePart( modelRoute.index, 1, routeModel.get( 'versionString' ), false ),
+                                       routeEnd   = wp.api.utils.extractRoutePart( modelRoute.index, 1, routeModel.get( 'versionString' ), true );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                // Clear the parent part of the rouite if its actually the version string.
+                               if ( parentName === routeModel.get( 'versionString' ) ) {
+                                       parentName = '';
+                               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                 // Handle the special case of the 'me' route.
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( 'me' === routeEnd ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                        routeName = 'me';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1137,18 +1173,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                // If the model has a parent in its route, add that to its class name.
</span><span class="cx" style="display: block; padding: 0 10px">                                if ( '' !== parentName && parentName !== routeName ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        modelClassName = wp.api.utils.capitalize( parentName ) + wp.api.utils.capitalize( routeName );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( parentName ) + wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
</ins><span class="cx" style="display: block; padding: 0 10px">                                         modelClassName = mapping.models[ modelClassName ] || modelClassName;
</span><span class="cx" style="display: block; padding: 0 10px">                                        loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                                // Return a constructed url based on the parent and id.
</span><span class="cx" style="display: block; padding: 0 10px">                                                url: function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                        var url = routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) +
-                                                                       parentName +  '/' +
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                                 var url =
+                                                               routeModel.get( 'apiRoot' ) +
+                                                               routeModel.get( 'versionString' ) +
+                                                               parentName +  '/' +
</ins><span class="cx" style="display: block; padding: 0 10px">                                                                         ( ( _.isUndefined( this.get( 'parent' ) ) || 0 === this.get( 'parent' ) ) ?
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                                                this.get( 'parent_post' ) :
-                                                                               this.get( 'parent' ) ) + '/' +
-                                                                       routeName;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                                                         ( _.isUndefined( this.get( 'parent_post' ) ) ? '' : this.get( 'parent_post' ) + '/' ) :
+                                                                               this.get( 'parent' ) + '/' ) +
+                                                               routeName;
+
</ins><span class="cx" style="display: block; padding: 0 10px">                                                         if ( ! _.isUndefined( this.get( 'id' ) ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                                                url +=  '/' + this.get( 'id' );
</span><span class="cx" style="display: block; padding: 0 10px">                                                        }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1164,7 +1203,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                                // Include the array of route methods for easy reference.
</span><span class="cx" style="display: block; padding: 0 10px">                                                methods: modelRoute.route.methods,
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                initialize: function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         initialize: function( attributes, options ) {
+                                                       wp.api.WPApiBaseModel.prototype.initialize.call( this, attributes, options );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                                        /**
</span><span class="cx" style="display: block; padding: 0 10px">                                                         * Posts and pages support trashing, other types don't support a trash
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1184,7 +1224,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                } else {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                        // This is a model without a parent in its route
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        modelClassName = wp.api.utils.capitalize( routeName );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
</ins><span class="cx" style="display: block; padding: 0 10px">                                         modelClassName = mapping.models[ modelClassName ] || modelClassName;
</span><span class="cx" style="display: block; padding: 0 10px">                                        loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1212,7 +1252,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                // Add defaults to the new model, pulled form the endpoint.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                wp.api.utils.decorateFromRoute( modelRoute.route.endpoints, loadingObjects.models[ modelClassName ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         wp.api.utils.decorateFromRoute(
+                                       modelRoute.route.endpoints,
+                                       loadingObjects.models[ modelClassName ],
+                                       routeModel.get( 'versionString' )
+                               );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        } );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1226,12 +1270,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                // Extract the name and any parent from the route.
</span><span class="cx" style="display: block; padding: 0 10px">                                var collectionClassName, modelClassName,
</span><span class="cx" style="display: block; padding: 0 10px">                                                routeName  = collectionRoute.index.slice( collectionRoute.index.lastIndexOf( '/' ) + 1 ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                                parentName = wp.api.utils.extractRoutePart( collectionRoute.index, 3 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                         parentName = wp.api.utils.extractRoutePart( collectionRoute.index, 1, routeModel.get( 'versionString' ), false );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                // If the collection has a parent in its route, add that to its class name.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                if ( '' !== parentName && parentName !== routeName ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         if ( '' !== parentName && parentName !== routeName && routeModel.get( 'versionString' ) !== parentName ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        collectionClassName = wp.api.utils.capitalize( parentName ) + wp.api.utils.capitalize( routeName );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 collectionClassName = wp.api.utils.capitalizeAndCamelCaseDashes( parentName ) + wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
</ins><span class="cx" style="display: block; padding: 0 10px">                                         modelClassName      = mapping.models[ collectionClassName ] || collectionClassName;
</span><span class="cx" style="display: block; padding: 0 10px">                                        collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName;
</span><span class="cx" style="display: block; padding: 0 10px">                                        loadingObjects.collections[ collectionClassName ] = wp.api.WPApiBaseCollection.extend( {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1260,7 +1304,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                } else {
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                                        // This is a collection without a parent in its route.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        collectionClassName = wp.api.utils.capitalize( routeName );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 collectionClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
</ins><span class="cx" style="display: block; padding: 0 10px">                                         modelClassName      = mapping.models[ collectionClassName ] || collectionClassName;
</span><span class="cx" style="display: block; padding: 0 10px">                                        collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName;
</span><span class="cx" style="display: block; padding: 0 10px">                                        loadingObjects.collections[ collectionClassName ] = wp.api.WPApiBaseCollection.extend( {
</span></span></pre></div>
<a id="branches47testsqunitfixturesjswidgetsendpointjsfromrev40109trunktestsqunitfixturesjswidgetsendpointjs"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: branches/4.7/tests/qunit/fixtures/js-widgets-endpoint.js (from rev 40109, trunk/tests/qunit/fixtures/js-widgets-endpoint.js)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/tests/qunit/fixtures/js-widgets-endpoint.js                          (rev 0)
+++ branches/4.7/tests/qunit/fixtures/js-widgets-endpoint.js    2017-02-24 22:47:47 UTC (rev 40117)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,562 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* jshint -W109 */
+/* jshint unused:false */
+var jsWidgetsEndpointSchema =
+{
+    "namespace": "js-widgets\/v1",
+    "routes": {
+        "\/js-widgets\/v1": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "namespace": { "required": false, "default": "js-widgets\/v1" },
+                    "context": { "required": false, "default": "view" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1" }
+        },
+        "\/js-widgets\/v1\/widgets\/pages": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "sortby": { "required": false, "default": "menu_order", "enum": ["post_title", "menu_order", "ID"], "description": "How to sort the pages.", "type": "string" },
+                    "exclude": { "required": false, "default": [], "description": "Page IDs to exclude.", "type": ["array", "string"] }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/pages" }
+        },
+        "\/js-widgets\/v1\/widgets\/pages\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "sortby": { "required": false, "default": "menu_order", "enum": ["post_title", "menu_order", "ID"], "description": "How to sort the pages.", "type": "string" },
+                    "exclude": { "required": false, "default": [], "description": "Page IDs to exclude.", "type": ["array", "string"] }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "sortby": { "required": false, "enum": ["post_title", "menu_order", "ID"], "description": "How to sort the pages.", "type": "string" },
+                    "exclude": { "required": false, "description": "Page IDs to exclude.", "type": ["array", "string"] }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/calendar": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/calendar" }
+        },
+        "\/js-widgets\/v1\/widgets\/calendar\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/archives": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "default": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "default": false, "description": "Show post counts", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/archives" }
+        },
+        "\/js-widgets\/v1\/widgets\/archives\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "default": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "default": false, "description": "Show post counts", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "description": "Show post counts", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/meta": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/meta" }
+        },
+        "\/js-widgets\/v1\/widgets\/meta\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/search": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/search" }
+        },
+        "\/js-widgets\/v1\/widgets\/search\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/text": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "text": { "required": false, "description": "The content for the widget.", "type": ["string", "object"] },
+                    "filter": { "required": false, "default": false, "description": "Whether paragraphs will be added for double line breaks (wpautop).", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/text" }
+        },
+        "\/js-widgets\/v1\/widgets\/text\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "text": { "required": false, "description": "The content for the widget.", "type": ["string", "object"] },
+                    "filter": { "required": false, "default": false, "description": "Whether paragraphs will be added for double line breaks (wpautop).", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "text": { "required": false, "description": "The content for the widget.", "type": ["string", "object"] },
+                    "filter": { "required": false, "description": "Whether paragraphs will be added for double line breaks (wpautop).", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/categories": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "default": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "default": false, "description": "Show post counts", "type": "boolean" },
+                    "hierarchical": { "required": false, "default": false, "description": "Show hierarchy", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/categories" }
+        },
+        "\/js-widgets\/v1\/widgets\/categories\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "default": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "default": false, "description": "Show post counts", "type": "boolean" },
+                    "hierarchical": { "required": false, "default": false, "description": "Show hierarchy", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "dropdown": { "required": false, "description": "Display as dropdown", "type": "boolean" },
+                    "count": { "required": false, "description": "Show post counts", "type": "boolean" },
+                    "hierarchical": { "required": false, "description": "Show hierarchy", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/recent-posts": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "default": 5, "description": "The number of posts to display.", "type": "integer" },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/recent-posts" }
+        },
+        "\/js-widgets\/v1\/widgets\/recent-posts\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "default": 5, "description": "The number of posts to display.", "type": "integer" },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "description": "The number of posts to display.", "type": "integer" },
+                    "show_date": { "required": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/recent-comments": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "default": 5, "description": "The number of comments to display.", "type": "integer" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/recent-comments" }
+        },
+        "\/js-widgets\/v1\/widgets\/recent-comments\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "default": 5, "description": "The number of comments to display.", "type": "integer" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "number": { "required": false, "description": "The number of comments to display.", "type": "integer" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/rss": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "url": { "required": false, "default": "", "description": "The RSS feed URL.", "type": "string" },
+                    "items": { "required": false, "default": 10, "description": "The number of RSS items to display.", "type": "integer" },
+                    "show_summary": { "required": false, "default": false, "description": "Whether the summary should be shown.", "type": "boolean" },
+                    "show_author": { "required": false, "default": false, "description": "Whether the author should be shown.", "type": "boolean" },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/rss" }
+        },
+        "\/js-widgets\/v1\/widgets\/rss\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "url": { "required": false, "default": "", "description": "The RSS feed URL.", "type": "string" },
+                    "items": { "required": false, "default": 10, "description": "The number of RSS items to display.", "type": "integer" },
+                    "show_summary": { "required": false, "default": false, "description": "Whether the summary should be shown.", "type": "boolean" },
+                    "show_author": { "required": false, "default": false, "description": "Whether the author should be shown.", "type": "boolean" },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "url": { "required": false, "description": "The RSS feed URL.", "type": "string" },
+                    "items": { "required": false, "description": "The number of RSS items to display.", "type": "integer" },
+                    "show_summary": { "required": false, "description": "Whether the summary should be shown.", "type": "boolean" },
+                    "show_author": { "required": false, "description": "Whether the author should be shown.", "type": "boolean" },
+                    "show_date": { "required": false, "description": "Whether the date should be shown.", "type": "boolean" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/tag_cloud": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "taxonomy": { "required": false, "default": "post_tag", "enum": ["category", "post_tag"], "description": "Taxonomy", "type": "string" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/tag_cloud" }
+        },
+        "\/js-widgets\/v1\/widgets\/tag_cloud\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "taxonomy": { "required": false, "default": "post_tag", "enum": ["category", "post_tag"], "description": "Taxonomy", "type": "string" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "taxonomy": { "required": false, "enum": ["category", "post_tag"], "description": "Taxonomy", "type": "string" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/nav_menu": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "nav_menu": { "required": false, "default": 0, "description": "Selected nav menu", "type": "integer" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/nav_menu" }
+        },
+        "\/js-widgets\/v1\/widgets\/nav_menu\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "nav_menu": { "required": false, "default": 0, "description": "Selected nav menu", "type": "integer" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "nav_menu": { "required": false, "description": "Selected nav menu", "type": "integer" }
+                }
+            }]
+        },
+        "\/js-widgets\/v1\/widgets\/post-collection": {
+            "namespace": "js-widgets\/v1",
+            "methods": ["GET", "POST"],
+            "endpoints": [{
+                "methods": ["GET"],
+                "args": {
+                    "context": { "required": false, "enum": ["view", "embed", "edit"], "description": "Scope under which the request is made; determines fields present in response.", "type": "string" }
+                }
+            }, {
+                "methods": ["POST"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" },
+                    "show_featured_image": { "required": false, "default": false, "description": "Whether the featured image is shown.", "type": "boolean" },
+                    "show_author": { "required": false, "default": false, "description": "Whether the author is shown.", "type": "boolean" },
+                    "posts": { "required": false, "default": [], "description": "The IDs for the collected posts.", "type": "array" }
+                }
+            }],
+            "_links": { "self": "http:\/\/newtest.localhost\/wp-json\/js-widgets\/v1\/widgets\/post-collection" }
+        },
+        "\/js-widgets\/v1\/widgets\/post-collection\/(?P<widget_number>\\d+)": {
+            "namespace": "js-widgets\/v1",
+            "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": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "show_date": { "required": false, "default": false, "description": "Whether the date should be shown.", "type": "boolean" },
+                    "show_featured_image": { "required": false, "default": false, "description": "Whether the featured image is shown.", "type": "boolean" },
+                    "show_author": { "required": false, "default": false, "description": "Whether the author is shown.", "type": "boolean" },
+                    "posts": { "required": false, "default": [], "description": "The IDs for the collected posts.", "type": "array" }
+                }
+            }, {
+                "methods": ["DELETE"],
+                "args": {
+                    "title": { "required": false, "description": "The title for the widget.", "type": ["string", "object"] },
+                    "show_date": { "required": false, "description": "Whether the date should be shown.", "type": "boolean" },
+                    "show_featured_image": { "required": false, "description": "Whether the featured image is shown.", "type": "boolean" },
+                    "show_author": { "required": false, "description": "Whether the author is shown.", "type": "boolean" },
+                    "posts": { "required": false, "description": "The IDs for the collected posts.", "type": "array" }
+                }
+            }]
+        }
+    },
+    "_links": {
+        "up": [
+            { "href": "http:\/\/newtest.localhost\/wp-json\/" }
+        ]
+    }
+};
</ins></span></pre></div>
<a id="branches47testsqunitfixtureswpapijs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/tests/qunit/fixtures/wp-api.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/tests/qunit/fixtures/wp-api.js       2017-02-24 22:33:05 UTC (rev 40116)
+++ branches/4.7/tests/qunit/fixtures/wp-api.js 2017-02-24 22:47:47 UTC (rev 40117)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,4 +1,4 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* global mockedApiResponse, Backbone */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* global mockedApiResponse, Backbone, jsWidgetsEndpointSchema */
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * @var mockedApiResponse defined in wp-api-generated.js
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -23,7 +23,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">        'wp-json/wp/v2/user': mockedApiResponse.UserModel,
</span><span class="cx" style="display: block; padding: 0 10px">        'wp-json/wp/v2/taxonomy': mockedApiResponse.TaxonomyModel,
</span><span class="cx" style="display: block; padding: 0 10px">        'wp-json/wp/v2/status': mockedApiResponse.StatusModel,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        'wp-json/wp/v2/type': mockedApiResponse.TypeModel
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wp-json/wp/v2/type': mockedApiResponse.TypeModel,
+       'wp-json/js-widgets/v1/': jsWidgetsEndpointSchema
</ins><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="branches47testsqunitindexhtml"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/tests/qunit/index.html</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/tests/qunit/index.html       2017-02-24 22:33:05 UTC (rev 40116)
+++ branches/4.7/tests/qunit/index.html 2017-02-24 22:47:47 UTC (rev 40117)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,6 +40,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        <script src="fixtures/customize-menus.js"></script>
</span><span class="cx" style="display: block; padding: 0 10px">                        <script src="fixtures/customize-widgets.js"></script>
</span><span class="cx" style="display: block; padding: 0 10px">                        <script src="fixtures/wp-api-generated.js"></script>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        <script src="fixtures/js-widgets-endpoint.js"></script>
</ins><span class="cx" style="display: block; padding: 0 10px">                         <script src="fixtures/wp-api.js"></script>
</span><span class="cx" style="display: block; padding: 0 10px">                </div>
</span><span class="cx" style="display: block; padding: 0 10px">                <p><a href="editor">TinyMCE tests</a></p>
</span></span></pre></div>
<a id="branches47testsqunitwpincludesjswpapijs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: branches/4.7/tests/qunit/wp-includes/js/wp-api.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- branches/4.7/tests/qunit/wp-includes/js/wp-api.js 2017-02-24 22:33:05 UTC (rev 40116)
+++ branches/4.7/tests/qunit/wp-includes/js/wp-api.js   2017-02-24 22:47:47 UTC (rev 40117)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,4 +192,44 @@
</span><span class="cx" style="display: block; padding: 0 10px">                } );
</span><span class="cx" style="display: block; padding: 0 10px">        } );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+// Test the jswidget custom namespace and endpoints.
+wp.api.init( {
+       'versionString': 'js-widgets/v1/'
+} ).done( function() {
+               var customClasses = [
+                       'WidgetsArchives',
+                       'WidgetsCalendar',
+                       'WidgetsCategories',
+                       'WidgetsMeta',
+                       'WidgetsNav_menu',
+                       'WidgetsPages',
+                       'WidgetsPostCollection',
+                       'WidgetsRecentComments',
+                       'WidgetsRecentPosts',
+                       'WidgetsRss',
+                       'WidgetsSearch',
+                       'WidgetsTag_cloud',
+                       'WidgetsText'
+               ];
+
+               // Check that we have and can get each model type.
+               _.each( customClasses, function( className ) {
+                       QUnit.test( 'Checking ' + className + ' class name.' , function( assert ) {
+                               var done = assert.async();
+
+                               assert.expect( 2 );
+
+                               wp.api.loadPromise.done( function() {
+                                       var theModel = new wp.api.models[ className ]();
+                                       assert.ok( theModel, 'We can instantiate wp.api.models.' + className );
+                                       var theCollection = new wp.api.collections[ className ]();
+                                       assert.ok( theCollection, 'We can instantiate wp.api.collections.' + className );
+                                       // Trigger Qunit async completion.
+                                       done();
+                               } );
+                       } );
+               } );
+
+       } );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> } )( window.QUnit );
</span></span></pre>
</div>
</div>

</body>
</html>