31 $jsonStream = $request->
getBody();
32 $status = FormatJson::parse(
"$jsonStream", FormatJson::FORCE_ASSOC );
34 if ( !$status->isOK() ) {
36 new MessageValue(
'rest-json-body-parse-error', [
"$status" ] ),
41 $data = $status->value;
43 if ( !is_array( $data ) ) {
47 $uncheckedBodyKeys = array_fill_keys( array_keys( $data ),
true );
48 foreach ( $this->bodyParamSettings as $name => $settings ) {
49 if ( !empty( $settings[ParamValidator::PARAM_REQUIRED] ) && !isset( $data[$name] ) ) {
51 new MessageValue(
'rest-missing-body-field', [ $name ] ), 400
55 if ( !isset( $data[$name] ) ) {
56 $data[$name] = $settings[ParamValidator::PARAM_DEFAULT] ??
null;
59 unset( $uncheckedBodyKeys[$name] );
62 if ( $uncheckedBodyKeys ) {
65 'rest-extraneous-body-fields',
66 [
new ListParam( ListType::COMMA, array_keys( $uncheckedBodyKeys ) ) ]