@@ -189,15 +189,21 @@ public function get_item_permissions_check( $request ) {
189189 }
190190
191191 /**
192- * WordPress-internal schema keywords to strip from REST responses.
192+ * Additional schema keywords to preserve in REST responses.
193193 *
194- * @since 7.0.0
195- * @var array<string, true>
194+ * These are not included in rest_get_allowed_schema_keywords(), but are
195+ * still recognized as schema traversal locations for ability schemas.
196+ *
197+ * @since 7.1.0
198+ * @var string[]
196199 */
197- private const INTERNAL_SCHEMA_KEYWORDS = array (
198- 'sanitize_callback ' => true ,
199- 'validate_callback ' => true ,
200- 'arg_options ' => true ,
200+ private const ADDITIONAL_ALLOWED_SCHEMA_KEYWORDS = array (
201+ 'required ' ,
202+ 'allOf ' ,
203+ 'not ' ,
204+ 'definitions ' ,
205+ 'dependencies ' ,
206+ 'additionalItems ' ,
201207 );
202208
203209 /**
@@ -217,12 +223,11 @@ private function is_associative_array( $value ): bool {
217223 /**
218224 * Transforms an ability schema for REST response output.
219225 *
220- * Ability schemas may include WordPress-internal properties like
221- * `sanitize_callback`, `validate_callback`, and `arg_options` that are
222- * used server-side but are not valid JSON Schema keywords. This method
223- * removes those specific keys so they are not exposed in REST responses.
224- * It also converts empty array defaults to objects when the schema type is
225- * 'object' to ensure proper JSON serialization as {} instead of [].
226+ * Ability schemas may include WordPress-internal properties or unsupported
227+ * schema keywords that should not be exposed in REST responses. This method
228+ * strips keys not recognized by the REST API schema handling. It also
229+ * converts empty array defaults to objects when the schema type is 'object'
230+ * to ensure proper JSON serialization as {} instead of [].
226231 *
227232 * @since 7.1.0
228233 *
@@ -237,7 +242,16 @@ private function prepare_schema_for_response( array $schema ): array {
237242 }
238243 }
239244
240- $ schema = array_diff_key ( $ schema , self ::INTERNAL_SCHEMA_KEYWORDS );
245+ $ schema = array_intersect_key (
246+ $ schema ,
247+ array_fill_keys (
248+ array_merge (
249+ rest_get_allowed_schema_keywords (),
250+ self ::ADDITIONAL_ALLOWED_SCHEMA_KEYWORDS
251+ ),
252+ true
253+ )
254+ );
241255
242256 // Sub-schema maps: keys are user-defined, values are sub-schemas.
243257 // Note: 'dependencies' values can also be property-dependency arrays
0 commit comments