diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2021-01-04 17:48:32 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2021-01-04 17:48:32 +0000 |
commit | fd4b04e08b038b1fa6c61b6d402bc785692e00a6 (patch) | |
tree | 3903151c72cf033094ccff11d81b15375f994eb9 /includes/Rest | |
parent | 0a4cd7c67170574c839676a4b173658361c9f20d (diff) | |
parent | c9371c567181744ca8d0d66d070d54fd6b751cf1 (diff) | |
download | mediawikicore-fd4b04e08b038b1fa6c61b6d402bc785692e00a6.tar.gz mediawikicore-fd4b04e08b038b1fa6c61b6d402bc785692e00a6.zip |
Merge "Improve REST API validation documentation"
Diffstat (limited to 'includes/Rest')
-rw-r--r-- | includes/Rest/Handler.php | 7 | ||||
-rw-r--r-- | includes/Rest/Validator/BodyValidator.php | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/includes/Rest/Handler.php b/includes/Rest/Handler.php index ff8036b28258..e829f2b2f253 100644 --- a/includes/Rest/Handler.php +++ b/includes/Rest/Handler.php @@ -18,6 +18,9 @@ abstract class Handler { /** * (string) ParamValidator constant to specify the source of the parameter. * Value must be 'path', 'query', or 'post'. + * 'post' refers to application/x-www-form-urlencoded or multipart/form-data encoded parameters + * in the body of a POST request (in other words, parameters in PHP's $_POST). For other kinds + * of POST parameters, such as JSON fields, use BodyValidator instead of ParamValidator. */ public const PARAM_SOURCE = 'rest-param-source'; @@ -227,6 +230,10 @@ abstract class Handler { * Every setting must include self::PARAM_SOURCE to specify which part of * the request is to contain the parameter. * + * Can be used for validating parameters inside an application/x-www-form-urlencoded or + * multipart/form-data POST body (i.e. parameters which would be present in PHP's $_POST + * array). For validating other kinds of request bodies, override getBodyValidator(). + * * @stable to override * * @return array[] Associative array mapping parameter names to diff --git a/includes/Rest/Validator/BodyValidator.php b/includes/Rest/Validator/BodyValidator.php index 6eeaf759ce5b..d0fece0e2411 100644 --- a/includes/Rest/Validator/BodyValidator.php +++ b/includes/Rest/Validator/BodyValidator.php @@ -9,6 +9,7 @@ use MediaWiki\Rest\RequestInterface; * Interface for validating a request body * * @stable to implement + * @see \MediaWiki\Rest\Handler::getBodyValidator() */ interface BodyValidator { |