experiments: suggested organization of API parameter definitions

This commit is contained in:
vnmedeiros 2023-06-26 11:13:21 -03:00
parent 6e9f1be4c1
commit 606f8ab116
3 changed files with 28 additions and 9 deletions

View File

@ -87,11 +87,11 @@ class REST_Collections_Controller extends REST_Controller {
'callback' => array($this, 'update_metadata_section_order'),
'permission_callback' => array($this, 'update_metadata_section_order_permissions_check'),
'args' => [
'metadata_section_order' => [
'description' => __( 'The order of the metadata section in the collection, an array of objects with integer ID and bool enabled.', 'tainacan' ),
'collection_id' => [
'description' => 'ID da coleção',
'required' => true,
'validate_callback' => [$this, 'validate_metadata_section_order']
]
],
'metadata_section_order' => $this->collections_repository->get_map()['metadata_section_order']
],
),
'schema' => [$this, 'get_schema'],
@ -889,7 +889,8 @@ class REST_Collections_Controller extends REST_Controller {
$schema = [
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'collection',
'type' => 'object'
'type' => 'object',
'tags' => ['collection'],
];
$main_schema = parent::get_repository_schema( $this->collections_repository );

View File

@ -1572,7 +1572,8 @@ class REST_Items_Controller extends REST_Controller {
$schema = [
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'item',
'type' => 'object'
'type' => 'object',
'tags' => ['item'],
];
$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#',
'title' => 'items',
'type' => 'array',
'items' => $this->get_schema()
'items' => $this->get_schema(),
'tags' => ['item'],
];
return $schema;
}

View File

@ -134,8 +134,24 @@ class Collections extends Repository {
'metadata_section_order' => [
'map' => 'meta',
'title' => __( 'Metadata order', 'tainacan' ),
'type' => ['array', 'object', 'string'],
'items' => [ 'type' => ['array', 'string', 'integer', 'object'] ],
'type' => 'array',
'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' ),
],
'metadata_order' => [