Go to the documentation of this file.
10 use Wikimedia\ObjectFactory;
33 'boolean' => [
'class' => BooleanDef::class ],
34 'enum' => [
'class' => EnumDef::class ],
35 'integer' => [
'class' => IntegerDef::class ],
36 'float' => [
'class' => FloatDef::class ],
37 'double' => [
'class' => FloatDef::class ],
39 'class' => StringDef::class,
41 'allowEmptyWhenRequired' =>
true,
44 'password' => [
'class' => PasswordDef::class ],
45 'string' => [
'class' => StringDef::class ],
46 'timestamp' => [
'class' => TimestampDef::class ],
47 'upload' => [
'class' => UploadDef::class ],
58 'application/x-www-form-urlencoded',
59 'multipart/form-data',
73 ObjectFactory $objectFactory,
82 'typeDefs' => self::$typeDefs,
94 $validatedParams = [];
95 foreach ( $paramSettings as $name => $settings ) {
97 $validatedParams[$name] = $this->paramValidator->getValue( $name, $settings, [
101 throw new HttpException(
'Parameter validation failed', 400, [
102 'error' =>
'parameter-validation-failed',
110 return $validatedParams;
126 $method = strtoupper( trim( $request->
getMethod() ) );
129 if ( in_array( $method, self::$noBodyMethods,
true ) ) {
134 list( $ct ) = explode(
';', $request->
getHeaderLine(
'Content-Type' ), 2 );
135 $ct = strtolower( trim( $ct ) );
139 if ( !in_array( $method, self::$bodyMethods,
true ) ) {
141 $size = $body->getSize();
142 if ( $size ===
null ) {
144 if ( $body->isSeekable() ) {
147 $size = $body->read( 1 ) ===
'' ? 0 : 1;
153 throw new HttpException(
"A Content-Type header must be supplied with a request payload.", 415, [
154 'error' =>
'no-content-type',
160 if ( in_array( $ct, self::$formDataContentTypes,
true ) ) {