Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Commit a12c23a

Browse files
Declare full schema for Posts, Pages and Attachments
1 parent 0da1fb5 commit a12c23a

File tree

4 files changed

+53
-19
lines changed

4 files changed

+53
-19
lines changed

lib/endpoints/class-wp-json-posts-controller.php

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,22 +1166,19 @@ public function get_item_schema() {
11661166
* Base properties for every Post
11671167
*/
11681168
'properties' => array(
1169-
'id' => array(
1170-
'description' => 'Unique identifier for the object.',
1171-
'type' => 'integer',
1172-
'context' => array( 'view', 'edit' ),
1173-
),
1174-
'type' => array(
1175-
'description' => 'Type of Post for the object.',
1169+
'date' => array(
1170+
'description' => 'The date the object was published.',
11761171
'type' => 'string',
1172+
'format' => 'date-time',
11771173
'context' => array( 'view', 'edit' ),
11781174
),
1179-
'slug' => array(
1180-
'description' => 'An alphanumeric identifier for the object unique to its type.',
1175+
'date_gmt' => array(
1176+
'description' => 'The date the object was published, as GMT.',
11811177
'type' => 'string',
1182-
'context' => array( 'view', 'edit' ),
1178+
'format' => 'date-time',
1179+
'context' => array( 'edit' ),
11831180
),
1184-
'guid' => array(
1181+
'guid' => array(
11851182
'description' => 'The globally unique identifier for the object.',
11861183
'type' => 'object',
11871184
'context' => array( 'view', 'edit' ),
@@ -1198,24 +1195,49 @@ public function get_item_schema() {
11981195
),
11991196
),
12001197
),
1201-
'link' => array(
1198+
'id' => array(
1199+
'description' => 'Unique identifier for the object.',
1200+
'type' => 'integer',
1201+
'context' => array( 'view', 'edit' ),
1202+
),
1203+
'link' => array(
12021204
'description' => 'URL to the object.',
12031205
'type' => 'string',
12041206
'format' => 'uri',
12051207
'context' => array( 'view', 'edit' ),
12061208
),
1207-
'date' => array(
1208-
'description' => 'The date the object was published.',
1209+
'modified' => array(
1210+
'description' => 'The date the object was last modified.',
12091211
'type' => 'string',
12101212
'format' => 'date-time',
12111213
'context' => array( 'view', 'edit' ),
12121214
),
1213-
'modified' => array(
1214-
'description' => 'The date the object was last modified.',
1215+
'modified_gmt' => array(
1216+
'description' => 'The date the object was last modified, as GMT.',
12151217
'type' => 'string',
12161218
'format' => 'date-time',
12171219
'context' => array( 'view', 'edit' ),
12181220
),
1221+
'password' => array(
1222+
'description' => 'A password to protect access to the post.',
1223+
'type' => 'string',
1224+
'context' => array( 'edit' ),
1225+
),
1226+
'slug' => array(
1227+
'description' => 'An alphanumeric identifier for the object unique to its type.',
1228+
'type' => 'string',
1229+
'context' => array( 'view', 'edit' ),
1230+
),
1231+
'status' => array(
1232+
'description' => 'A named status for the object.',
1233+
'type' => 'string',
1234+
'context' => array( 'edit' ),
1235+
),
1236+
'type' => array(
1237+
'description' => 'Type of Post for the object.',
1238+
'type' => 'string',
1239+
'context' => array( 'view', 'edit' ),
1240+
),
12191241
)
12201242
);
12211243

tests/test-json-attachments-controller.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,21 +233,25 @@ public function test_get_item_schema() {
233233
$response = $this->server->dispatch( $request );
234234
$data = $response->get_data();
235235
$properties = $data['properties'];
236-
$this->assertEquals( 18, count( $properties ) );
236+
$this->assertEquals( 22, count( $properties ) );
237237
$this->assertArrayHasKey( 'author', $properties );
238238
$this->assertArrayHasKey( 'alt_text', $properties );
239239
$this->assertArrayHasKey( 'caption', $properties );
240240
$this->assertArrayHasKey( 'description', $properties );
241241
$this->assertArrayHasKey( 'comment_status', $properties );
242242
$this->assertArrayHasKey( 'date', $properties );
243+
$this->assertArrayHasKey( 'date_gmt', $properties );
243244
$this->assertArrayHasKey( 'guid', $properties );
244245
$this->assertArrayHasKey( 'id', $properties );
245246
$this->assertArrayHasKey( 'link', $properties );
246247
$this->assertArrayHasKey( 'media_type', $properties );
247248
$this->assertArrayHasKey( 'media_details', $properties );
248249
$this->assertArrayHasKey( 'modified', $properties );
250+
$this->assertArrayHasKey( 'modified_gmt', $properties );
251+
$this->assertArrayHasKey( 'password', $properties );
249252
$this->assertArrayHasKey( 'post', $properties );
250253
$this->assertArrayHasKey( 'ping_status', $properties );
254+
$this->assertArrayHasKey( 'status', $properties );
251255
$this->assertArrayHasKey( 'slug', $properties );
252256
$this->assertArrayHasKey( 'source_url', $properties );
253257
$this->assertArrayHasKey( 'title', $properties );

tests/test-json-pages-controller.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,21 +185,25 @@ public function test_get_item_schema() {
185185
$response = $this->server->dispatch( $request );
186186
$data = $response->get_data();
187187
$properties = $data['properties'];
188-
$this->assertEquals( 17, count( $properties ) );
188+
$this->assertEquals( 21, count( $properties ) );
189189
$this->assertArrayHasKey( 'author', $properties );
190190
$this->assertArrayHasKey( 'comment_status', $properties );
191191
$this->assertArrayHasKey( 'content', $properties );
192192
$this->assertArrayHasKey( 'date', $properties );
193+
$this->assertArrayHasKey( 'date_gmt', $properties );
193194
$this->assertArrayHasKey( 'guid', $properties );
194195
$this->assertArrayHasKey( 'excerpt', $properties );
195196
$this->assertArrayHasKey( 'featured_image', $properties );
196197
$this->assertArrayHasKey( 'id', $properties );
197198
$this->assertArrayHasKey( 'link', $properties );
198199
$this->assertArrayHasKey( 'menu_order', $properties );
199200
$this->assertArrayHasKey( 'modified', $properties );
201+
$this->assertArrayHasKey( 'modified_gmt', $properties );
200202
$this->assertArrayHasKey( 'parent', $properties );
203+
$this->assertArrayHasKey( 'password', $properties );
201204
$this->assertArrayHasKey( 'ping_status', $properties );
202205
$this->assertArrayHasKey( 'slug', $properties );
206+
$this->assertArrayHasKey( 'status', $properties );
203207
$this->assertArrayHasKey( 'template', $properties );
204208
$this->assertArrayHasKey( 'title', $properties );
205209
$this->assertArrayHasKey( 'type', $properties );

tests/test-json-posts-controller.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,20 +874,24 @@ public function test_get_item_schema() {
874874
$response = $this->server->dispatch( $request );
875875
$data = $response->get_data();
876876
$properties = $data['properties'];
877-
$this->assertEquals( 16, count( $properties ) );
877+
$this->assertEquals( 20, count( $properties ) );
878878
$this->assertArrayHasKey( 'author', $properties );
879879
$this->assertArrayHasKey( 'comment_status', $properties );
880880
$this->assertArrayHasKey( 'content', $properties );
881881
$this->assertArrayHasKey( 'date', $properties );
882+
$this->assertArrayHasKey( 'date_gmt', $properties );
882883
$this->assertArrayHasKey( 'excerpt', $properties );
883884
$this->assertArrayHasKey( 'featured_image', $properties );
884885
$this->assertArrayHasKey( 'guid', $properties );
885886
$this->assertArrayHasKey( 'format', $properties );
886887
$this->assertArrayHasKey( 'id', $properties );
887888
$this->assertArrayHasKey( 'link', $properties );
888889
$this->assertArrayHasKey( 'modified', $properties );
890+
$this->assertArrayHasKey( 'modified_gmt', $properties );
891+
$this->assertArrayHasKey( 'password', $properties );
889892
$this->assertArrayHasKey( 'ping_status', $properties );
890893
$this->assertArrayHasKey( 'slug', $properties );
894+
$this->assertArrayHasKey( 'status', $properties );
891895
$this->assertArrayHasKey( 'sticky', $properties );
892896
$this->assertArrayHasKey( 'title', $properties );
893897
$this->assertArrayHasKey( 'type', $properties );

0 commit comments

Comments
 (0)