WP_REST_Abilities_V1_List_Controller::get_item_schemapublicWP 6.9.0

Retrieves the ability's schema, conforming to JSON Schema.

Method of the class: WP_REST_Abilities_V1_List_Controller{}

No Hooks.

Returns

array<string, mixed>. Item schema data.

Usage

$WP_REST_Abilities_V1_List_Controller = new WP_REST_Abilities_V1_List_Controller();
$WP_REST_Abilities_V1_List_Controller->get_item_schema(): array;

Changelog

Since 6.9.0 Introduced.

WP_REST_Abilities_V1_List_Controller::get_item_schema() code WP 7.1

public function get_item_schema(): array {
	$schema = array(
		'$schema'    => 'http://json-schema.org/draft-04/schema#',
		'title'      => 'ability',
		'type'       => 'object',
		'properties' => array(
			'name'          => array(
				'description' => __( 'Unique identifier for the ability.' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit', 'embed' ),
				'readonly'    => true,
			),
			'label'         => array(
				'description' => __( 'Display label for the ability.' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit', 'embed' ),
				'readonly'    => true,
			),
			'description'   => array(
				'description' => __( 'Description of the ability.' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'category'      => array(
				'description' => __( 'Ability category this ability belongs to.' ),
				'type'        => 'string',
				'context'     => array( 'view', 'edit', 'embed' ),
				'readonly'    => true,
			),
			'input_schema'  => array(
				'description' => __( 'JSON Schema for the ability input.' ),
				'type'        => 'object',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'output_schema' => array(
				'description' => __( 'JSON Schema for the ability output.' ),
				'type'        => 'object',
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
			'meta'          => array(
				'description' => __( 'Meta information about the ability.' ),
				'type'        => 'object',
				'properties'  => array(
					'annotations' => array(
						'description'          => __( 'Behavioral annotations for the ability.' ),
						'type'                 => 'object',
						'properties'           => array(
							'readonly'    => array(
								'description' => __( 'Whether the ability does not modify its environment.' ),
								'type'        => array( 'boolean', 'null' ),
							),
							'destructive' => array(
								'description' => __( 'Whether the ability may perform destructive updates to its environment.' ),
								'type'        => array( 'boolean', 'null' ),
							),
							'idempotent'  => array(
								'description' => __( 'Whether repeated calls with the same arguments have no additional effect.' ),
								'type'        => array( 'boolean', 'null' ),
							),
						),
						'additionalProperties' => true,
					),
					'public'      => array(
						'description' => __( 'Whether the ability is meant to be available to clients such as the REST API, MCP, or AI agents. Defaults to false, but individual channel settings such as show_in_rest can override it.' ),
						'type'        => 'boolean',
					),
				),
				'context'     => array( 'view', 'edit' ),
				'readonly'    => true,
			),
		),
	);

	return $this->add_additional_fields_schema( $schema );
}