experiments: suggested organization of API parameter definitions
This commit is contained in:
parent
6e9f1be4c1
commit
606f8ab116
|
@ -87,11 +87,11 @@ class REST_Collections_Controller extends REST_Controller {
|
||||||
'callback' => array($this, 'update_metadata_section_order'),
|
'callback' => array($this, 'update_metadata_section_order'),
|
||||||
'permission_callback' => array($this, 'update_metadata_section_order_permissions_check'),
|
'permission_callback' => array($this, 'update_metadata_section_order_permissions_check'),
|
||||||
'args' => [
|
'args' => [
|
||||||
'metadata_section_order' => [
|
'collection_id' => [
|
||||||
'description' => __( 'The order of the metadata section in the collection, an array of objects with integer ID and bool enabled.', 'tainacan' ),
|
'description' => 'ID da coleção',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'validate_callback' => [$this, 'validate_metadata_section_order']
|
],
|
||||||
]
|
'metadata_section_order' => $this->collections_repository->get_map()['metadata_section_order']
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
'schema' => [$this, 'get_schema'],
|
'schema' => [$this, 'get_schema'],
|
||||||
|
@ -889,7 +889,8 @@ class REST_Collections_Controller extends REST_Controller {
|
||||||
$schema = [
|
$schema = [
|
||||||
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
'title' => 'collection',
|
'title' => 'collection',
|
||||||
'type' => 'object'
|
'type' => 'object',
|
||||||
|
'tags' => ['collection'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$main_schema = parent::get_repository_schema( $this->collections_repository );
|
$main_schema = parent::get_repository_schema( $this->collections_repository );
|
||||||
|
|
|
@ -1572,7 +1572,8 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
$schema = [
|
$schema = [
|
||||||
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
'title' => 'item',
|
'title' => 'item',
|
||||||
'type' => 'object'
|
'type' => 'object',
|
||||||
|
'tags' => ['item'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$main_schema = parent::get_repository_schema( $this->items_repository );
|
$main_schema = parent::get_repository_schema( $this->items_repository );
|
||||||
|
@ -1592,7 +1593,8 @@ class REST_Items_Controller extends REST_Controller {
|
||||||
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
||||||
'title' => 'items',
|
'title' => 'items',
|
||||||
'type' => 'array',
|
'type' => 'array',
|
||||||
'items' => $this->get_schema()
|
'items' => $this->get_schema(),
|
||||||
|
'tags' => ['item'],
|
||||||
];
|
];
|
||||||
return $schema;
|
return $schema;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,8 +134,24 @@ class Collections extends Repository {
|
||||||
'metadata_section_order' => [
|
'metadata_section_order' => [
|
||||||
'map' => 'meta',
|
'map' => 'meta',
|
||||||
'title' => __( 'Metadata order', 'tainacan' ),
|
'title' => __( 'Metadata order', 'tainacan' ),
|
||||||
'type' => ['array', 'object', 'string'],
|
'type' => 'array',
|
||||||
'items' => [ 'type' => ['array', 'string', 'integer', 'object'] ],
|
'items' => [
|
||||||
|
'type' => 'object',
|
||||||
|
"properties" => [
|
||||||
|
"id" => [
|
||||||
|
"description" => "IDs.",
|
||||||
|
"type" => "integer",
|
||||||
|
],
|
||||||
|
"enabled" => [
|
||||||
|
"description" => "enabled.",
|
||||||
|
"type" => "boolean",
|
||||||
|
],
|
||||||
|
"metadata_order" => [
|
||||||
|
"description" => "metadata_order.",
|
||||||
|
"type" => "array",
|
||||||
|
],
|
||||||
|
]
|
||||||
|
],
|
||||||
'description' => __( 'The order of the metadata section in the collection', 'tainacan' ),
|
'description' => __( 'The order of the metadata section in the collection', 'tainacan' ),
|
||||||
],
|
],
|
||||||
'metadata_order' => [
|
'metadata_order' => [
|
||||||
|
|
Loading…
Reference in New Issue