File tree Expand file tree Collapse file tree
src/wp-includes/rest-api/endpoints
tests/phpunit/tests/rest-api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -191,8 +191,9 @@ public function get_item_permissions_check( $request ) {
191191 /**
192192 * Additional schema keywords to preserve in REST responses.
193193 *
194- * These are not included in rest_get_allowed_schema_keywords(), but are
195- * still recognized as schema traversal locations for ability schemas.
194+ * Ability schemas are exposed to clients as JSON Schema. Preserve additional
195+ * draft-04 keywords so clients can validate richer schemas, even when some
196+ * of those keywords are not enforced by the server-side REST schema validator.
196197 *
197198 * @since 7.1.0
198199 * @var string[]
@@ -201,6 +202,7 @@ public function get_item_permissions_check( $request ) {
201202 'required ' ,
202203 'allOf ' ,
203204 'not ' ,
205+ '$ref ' ,
204206 'definitions ' ,
205207 'dependencies ' ,
206208 'additionalItems ' ,
Original file line number Diff line number Diff line change @@ -962,6 +962,7 @@ public function test_internal_schema_keywords_stripped_from_nested_sub_schemas()
962962 'category ' => 'general ' ,
963963 'input_schema ' => array (
964964 'type ' => 'object ' ,
965+ '$ref ' => '#/definitions/address ' ,
965966 'anyOf ' => array (
966967 array (
967968 'type ' => 'object ' ,
@@ -1063,6 +1064,7 @@ public function test_internal_schema_keywords_stripped_from_nested_sub_schemas()
10631064 $ data = $ response ->get_data ();
10641065
10651066 // Verify internal keywords are stripped from anyOf sub-schemas.
1067+ $ this ->assertSame ( '#/definitions/address ' , $ data ['input_schema ' ]['$ref ' ] );
10661068 $ this ->assertArrayHasKey ( 'anyOf ' , $ data ['input_schema ' ] );
10671069 $ this ->assertArrayNotHasKey ( 'sanitize_callback ' , $ data ['input_schema ' ]['anyOf ' ][0 ] );
10681070 $ this ->assertSame ( 'object ' , $ data ['input_schema ' ]['anyOf ' ][0 ]['type ' ] );
You can’t perform that action at this time.
0 commit comments