File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -445,10 +445,18 @@ public function normalize_input( $input = null ) {
445445 }
446446
447447 $ input_schema = $ this ->get_input_schema ();
448- if ( ! empty ( $ input_schema ) && array_key_exists ( 'default ' , $ input_schema ) ) {
449- return $ input_schema ['default ' ];
448+ // This tries to compute a default value from the input schema properties.
449+ // It is a very basic implementation and does not cover all JSON Schema features.
450+ // It only looks for `default` values in the top-level `properties`.
451+ if ( ! empty ( $ input_schema ) && array_key_exists ( 'properties ' , $ input_schema ) ) {
452+ $ result = array ();
453+ foreach ( $ input_schema ['properties ' ] as $ property_name => $ property_schema ) {
454+ if ( array_key_exists ( 'default ' , $ property_schema ) ) {
455+ $ result [ $ property_name ] = $ property_schema ['default ' ];
456+ }
457+ }
458+ return $ result ;
450459 }
451-
452460 return null ;
453461 }
454462
Original file line number Diff line number Diff line change @@ -96,11 +96,11 @@ function wp_register_core_abilities(): void {
9696 'type ' => 'string ' ,
9797 'enum ' => $ site_info_fields ,
9898 ),
99+ 'default ' => array (),
99100 'description ' => __ ( 'Optional: Limit response to specific fields. If omitted, all fields are returned. ' ),
100101 ),
101102 ),
102103 'additionalProperties ' => false ,
103- 'default ' => array (),
104104 ),
105105 'output_schema ' => array (
106106 'type ' => 'object ' ,
You can’t perform that action at this time.
0 commit comments