<!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>[2355] 2013/rmccue/trunk/docs/schema.md: Update the schema to match latest changes</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">
<dt>Revision</dt> <dd><a href="http://gsoc.trac.wordpress.org/changeset/2355">2355</a></dd>
<dt>Author</dt> <dd>rmccue</dd>
<dt>Date</dt> <dd>2013-09-22 04:04:40 +0000 (Sun, 22 Sep 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update the schema to match latest changes

See <a href="http://gsoc.trac.wordpress.org/ticket/264">#264</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#2013rmccuetrunkdocsschemamd">2013/rmccue/trunk/docs/schema.md</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="2013rmccuetrunkdocsschemamd"></a>
<div class="modfile"><h4>Modified: 2013/rmccue/trunk/docs/schema.md (2354 => 2355)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/rmccue/trunk/docs/schema.md 2013-09-22 01:40:51 UTC (rev 2354)
+++ 2013/rmccue/trunk/docs/schema.md    2013-09-22 04:04:40 UTC (rev 2355)
</span><span class="lines">@@ -4,7 +4,10 @@
</span><span class="cx"> Entities are JSON objects representing internal objects, both abstract and
</span><span class="cx"> WordPress objects. Collections are JSON arrays of Entities.
</span><span class="cx"> 
</span><ins>+This document is for clients and providers wanting to ensure full compliance
+with the specification.
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> Defintions
</span><span class="cx"> ==========
</span><span class="cx"> The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
</span><span class="lines">@@ -14,7 +17,7 @@
</span><span class="cx"> * Provider: A site making the API available for use
</span><span class="cx"> * Consumer: An application accessing and interacting with the API
</span><span class="cx"> * slug: A URL-friendly human-readable identifier, usually derived from the title
</span><del>-        of the entity.
</del><ins>+                of the entity.
</ins><span class="cx"> 
</span><span class="cx"> [RFC2119]: http://tools.ietf.org/html/rfc2119
</span><span class="cx"> 
</span><span class="lines">@@ -64,13 +67,21 @@
</span><span class="cx"> URL part either a static string, or a route variable encased in angle brackets.
</span><span class="cx"> 
</span><span class="cx">  route            = ( "/"
</span><del>-                        / *( "/" ( token / route-variable ) ) )
</del><ins>+                                         / *( "/" ( token / route-variable ) ) )
</ins><span class="cx">   route-variable   = "<" token ">"
</span><span class="cx"> 
</span><span class="cx"> These routes can be converted into URLs by replacing all route variables with
</span><span class="cx"> their relevant values, then concatenating the relative URL to the API base.
</span><span class="cx"> 
</span><ins>+The route descriptor is an object with the following defined properties.
</ins><span class="cx"> 
</span><ins>+* `supports`: A JSON array of supported HTTP methods (verbs). Possible values
+  are "HEAD", "GET", "POST", "PUT", "PATCH", "DELETE"
+* `accepts_json`: A boolean indicating whether data can be passed directly via a
+  POST request body. Default for missing properties is false.
+* `meta`: An Entity Meta entity. Typical `links` values consist of a `self` link
+  pointing to the route's full URL.
+
</ins><span class="cx"> ### `meta`
</span><span class="cx"> The `meta` field is a Entity Meta entity with metadata relating to the entity
</span><span class="cx"> representation.
</span><span class="lines">@@ -78,11 +89,83 @@
</span><span class="cx"> Typical `links` values for the meta object consist of a `help` key with the
</span><span class="cx"> value indicating a human-readable documentation page about the API.
</span><span class="cx"> 
</span><ins>+### Example
</ins><span class="cx"> 
</span><ins>+       {
+               "name": "My WordPress Site",
+               "description": "Just another WordPress site",
+               "URL": "http:\/\/example.com",
+               "routes": {
+                       "\/": {
+                               "supports": [
+                                       "HEAD",
+                                       "GET"
+                               ],
+                               "meta": {
+                                       "self": "http:\/\/example.com\/wp-json.php\/"
+                               }
+                       },
+                       "\/posts": {
+                               "supports": [
+                                       "HEAD",
+                                       "GET",
+                                       "POST"
+                               ],
+                               "meta": {
+                                       "self": "http:\/\/example.com\/wp-json.php\/posts"
+                               },
+                               "accepts_json": true
+                       },
+                       "\/posts\/<id>": {
+                               "supports": [
+                                       "HEAD",
+                                       "GET",
+                                       "POST",
+                                       "PUT",
+                                       "PATCH",
+                                       "DELETE"
+                               ],
+                               "accepts_json": true
+                       },
+                       "\/posts\/<id>\/revisions": {
+                               "supports": [
+                                       "HEAD",
+                                       "GET"
+                               ]
+                       },
+                       "\/posts\/<id>\/comments": {
+                               "supports": [
+                                       "HEAD",
+                                       "GET",
+                                       "POST"
+                               ],
+                               "accepts_json": true
+                       },
+                       "\/posts\/<id>\/comments\/<comment>": {
+                               "supports": [
+                                       "HEAD",
+                                       "GET",
+                                       "POST",
+                                       "PUT",
+                                       "PATCH",
+                                       "DELETE"
+                               ],
+                               "accepts_json": true
+                       },
+               },
+               "meta": {
+                       "links": {
+                               "help": "https:\/\/github.com\/rmccue\/WP-API",
+                               "profile": "https:\/\/raw.github.com\/rmccue\/WP-API\/master\/docs\/schema.json"
+                       }
+               }
+       }
+
</ins><span class="cx"> Post
</span><span class="cx"> ----
</span><del>-The Post entity is a JSON object of post properties. The following properties
-are defined for the Post entity object:
</del><ins>+The Post entity is a JSON object of post properties. Unless otherwise defined,
+properties are available in all contexts. The following properties are defined
+for the Post entity object:
</ins><span class="cx"> 
</span><span class="cx"> ### `title`
</span><span class="cx"> The `title` field is a string with the post's title.
</span><span class="lines">@@ -171,15 +254,30 @@
</span><span class="cx"> Consumers who encounter a missing excerpt MAY present a shortened version of the
</span><span class="cx"> `content` field instead.
</span><span class="cx"> 
</span><ins>+### `content_raw`, `excerpt_raw`
+The `content_raw` and `excerpt_raw` fields are strings with the post's content
+and excerpt respectively. Unlike the `content` and `excerpt` fields, the value
+has not been passed through internal filtering, and is suitable for editing.
+
+(Context Availability: `edit`)
+
</ins><span class="cx"> ### `parent`
</span><del>-The `parent` field is an integer with the post's parent post ID. A literal zero
-indicates that the post does not have a parent post.
</del><ins>+The `parent` field is an integer or JSON object with the post's parent
+post ID. A literal zero indicates that the post does not have a parent
+post.
</ins><span class="cx"> 
</span><span class="cx">  post-parent = "0" / 1*DIGIT
</span><span class="cx"> 
</span><span class="cx"> Consumers who encounter a missing parent ID MUST treat it the same as a parent
</span><span class="cx"> post ID of 0.
</span><span class="cx"> 
</span><ins>+Parent fields will be expanded into a full Post entity in the `view` or `edit`
+contexts, but only one level deep. The embedded Post entity will be rendered
+using the `parent` context.
+
+In the `parent` context, the field will contain an integer with the post's
+parent post ID as above.
+
</ins><span class="cx"> ### `link`
</span><span class="cx"> The `link` field is a string with the full URL to the post's canonical view.
</span><span class="cx"> This is typically the human-readable location of the entity.
</span><span class="lines">@@ -252,7 +350,77 @@
</span><span class="cx"> The `meta` field is a Entity Meta entity with metadata relating to the entity
</span><span class="cx"> representation.
</span><span class="cx"> 
</span><ins>+### Example
</ins><span class="cx"> 
</span><ins>+       {
+               "ID": 1,
+               "title": "Hello world!q",
+               "status": "publish",
+               "type": "post",
+               "author": {
+                       "ID": 1,
+                       "name": "admin",
+                       "slug": "admin",
+                       "URL": "",
+                       "avatar": "http:\/\/0.gravatar.com\/avatar\/c57c8945079831fa3c19caef02e44614&d=404&r=G",
+                       "meta": {
+                               "links": {
+                                       "self": "http:\/\/example.com\/wp-json.php\/users\/1",
+                                       "archives": "http:\/\/example.com\/wp-json.php\/users\/1\/posts"
+                               }
+                       },
+                       "first_name": "",
+                       "last_name": ""
+               },
+               "content": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!<\/p>\n",
+               "parent": 0,
+               "link": "http:\/\/example.com\/2013\/06\/02\/hello-world\/",
+               "date": "2013-06-02T05:28:00+10:00",
+               "modified": "2013-06-30T13:56:57+10:00",
+               "format": "standard",
+               "slug": "hello-world",
+               "guid": "http:\/\/example.com\/?p=1",
+               "excerpt": "",
+               "menu_order": 0,
+               "comment_status": "open",
+               "ping_status": "open",
+               "sticky": false,
+               "date_tz": "Australia\/Brisbane",
+               "date_gmt": "2013-06-02T05:28:00+00:00",
+               "modified_tz": "Australia\/Brisbane",
+               "modified_gmt": "2013-06-30T03:56:57+00:00",
+               "password": "",
+               "post_meta": [
+               ],
+               "meta": {
+                       "links": {
+                               "self": "http:\/\/example.com\/wp-json.php\/posts\/1",
+                               "author": "http:\/\/example.com\/wp-json.php\/users\/1",
+                               "collection": "http:\/\/example.com\/wp-json.php\/posts",
+                               "replies": "http:\/\/example.com\/wp-json.php\/posts\/1\/comments",
+                               "version-history": "http:\/\/example.com\/wp-json.php\/posts\/1\/revisions"
+                       }
+               },
+               "featured_image": null,
+               "terms": {
+                       "category": {
+                               "ID": 1,
+                               "name": "Uncategorized",
+                               "slug": "uncategorized",
+                               "parent": null,
+                               "count": 7,
+                               "meta": {
+                                       "links": {
+                                               "collection": "http:\/\/example.com\/wp-json.php\/posts\/types\/post\/taxonomies\/category\/terms",
+                                               "self": "http:\/\/example.com\/wp-json.php\/posts\/types\/post\/taxonomies\/category\/terms\/1"
+                                       }
+                               }
+                       }
+               }
+       }
+
+
+
</ins><span class="cx"> Entity Meta
</span><span class="cx"> -----------
</span><span class="cx"> The Entity Meta entity is a JSON object with custom metadata relating to the
</span><span class="lines">@@ -265,6 +433,12 @@
</span><span class="cx"> item's key is a link relation as per the [IANA Link Relations registry][] with
</span><span class="cx"> the value of the item being the corresponding link URL.
</span><span class="cx"> 
</span><ins>+Typical link relations are:
+
+* `self`: A URL pointing to the current entity's location.
+* `up`: A URL pointing to the parent entity's location.
+* `collection`: A URL pointing to a collection that the entity is a member of.
+
</ins><span class="cx"> [IANA Link Relations registry]: http://www.iana.org/assignments/link-relations/link-relations.xml
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -579,28 +753,6 @@
</span><span class="cx"> The body of a User document is a User entity.
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-Endpoints
-=========
-
-The following endpoints return the given document with associated headers.
-
-       /: Index
-       /posts: Post Collection
-       /posts/<id>: Post
-       /posts/<id>/revisions: Post Collection
-       /posts/<id>/comments: Comment Collection
-       /posts/<id>/comments/<comment>: Comment
-
-       /taxonomies: Taxonomy Collection
-       /taxonomies/<tax>: Taxonomy
-       /taxonomies/<tax>/terms: Term Collection
-       /taxonomies/<tax>/terms/<term>: Term
-
-       /users: User Collection
-       /users/me: User
-       /users/<user>: User
-
-
</del><span class="cx"> Appendix A: JSON Schema
</span><span class="cx"> =======================
</span><span class="cx"> The JSON Schema describing the entities in this document is available in
</span></span></pre>
</div>
</div>

</body>
</html>