diff --git a/src/api/endpoints/class-tainacan-rest-metadata-controller.php b/src/api/endpoints/class-tainacan-rest-metadata-controller.php index d2bc9e0a5..5cbba59e1 100644 --- a/src/api/endpoints/class-tainacan-rest-metadata-controller.php +++ b/src/api/endpoints/class-tainacan-rest-metadata-controller.php @@ -587,7 +587,6 @@ class REST_Metadata_Controller extends REST_Controller { return $endpoint_args; } - function get_schema() { $schema = [ '$schema' => 'http://json-schema.org/draft-04/schema#', diff --git a/src/api/endpoints/class-tainacan-rest-terms-controller.php b/src/api/endpoints/class-tainacan-rest-terms-controller.php index a5eef4c20..cf74853d6 100644 --- a/src/api/endpoints/class-tainacan-rest-terms-controller.php +++ b/src/api/endpoints/class-tainacan-rest-terms-controller.php @@ -45,7 +45,8 @@ class REST_Terms_Controller extends REST_Controller { 'callback' => array($this, 'get_items'), 'permission_callback' => array($this, 'get_items_permissions_check'), 'args' => $this->get_wp_query_params() - ) + ), + 'schema' => [$this, 'get_schema'] ) ); register_rest_route($this->namespace,'/taxonomy/(?P[\d]+)/'. $this->rest_base . '/(?P[\d]+)' , @@ -71,7 +72,8 @@ class REST_Terms_Controller extends REST_Controller { 'callback' => array($this, 'get_item'), 'permission_callback' => array($this, 'get_item_permissions_check'), 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE) - ) + ), + 'schema' => [$this, 'get_schema'] ) ); } @@ -463,6 +465,28 @@ class REST_Terms_Controller extends REST_Controller { return $query_params; } + + function get_schema() { + $schema = [ + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'term', + 'type' => 'object' + ]; + + $main_schema = parent::get_repository_schema( $this->terms_repository ); + $permissions_schema = parent::get_permissions_schema(); + + // $taxonomy_scheme = parent::get_repository_schema( $this->taxonomy_repository ); + + $schema['properties'] = array_merge( + parent::get_base_properties_schema(), + $main_schema, + $permissions_schema + // $taxonomy_scheme + ); + + return $schema; + } } ?> \ No newline at end of file