This repository was archived by the owner on Sep 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 647
Expand file tree
/
Copy pathclass-wp-rest-test-controller.php
More file actions
69 lines (65 loc) · 1.79 KB
/
class-wp-rest-test-controller.php
File metadata and controls
69 lines (65 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
class WP_REST_Test_Controller extends WP_REST_Controller {
/**
* Get the Post type's schema, conforming to JSON Schema
*
* @return array
*/
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'type',
'type' => 'object',
'properties' => array(
'somestring' => array(
'type' => 'string',
'description' => 'A pretty string.',
'context' => array( 'view' ),
),
'someinteger' => array(
'type' => 'integer',
'context' => array( 'view' ),
),
'someboolean' => array(
'type' => 'boolean',
'context' => array( 'view' ),
),
'someurl' => array(
'type' => 'string',
'format' => 'uri',
'context' => array( 'view' ),
),
'somedate' => array(
'type' => 'string',
'format' => 'date-time',
'context' => array( 'view' ),
),
'someemail' => array(
'type' => 'string',
'format' => 'email',
'context' => array( 'view' ),
),
'someenum' => array(
'type' => 'string',
'enum' => array( 'a', 'b', 'c' ),
'context' => array( 'view' ),
),
'someargoptions' => array(
'type' => 'integer',
'required' => true,
'arg_options' => array(
'required' => false,
'sanitize_callback' => '__return_true',
),
),
'somedefault' => array(
'type' => 'string',
'enum' => array( 'a', 'b', 'c' ),
'context' => array( 'view' ),
'default' => 'a',
),
),
);
return $schema;
}
}