MediaWiki master
|
Wrapper for ParamValidator. More...
Public Member Functions | |
__construct (ObjectFactory $objectFactory, RequestInterface $request, Authority $authority) | |
validateBody (RequestInterface $request, Handler $handler) | |
Validate the body of a request. | |
validateParams (array $paramSettings) | |
Validate parameters. | |
Static Public Member Functions | |
static | getParameterSpec (string $name, array $paramSetting) |
Convert a param settings array into an OpenAPI Parameter Object specification structure. | |
static | getParameterTypeSchemas () |
Returns JSON Schema description of all known parameter types. | |
Public Attributes | |
const | PARAM_DESCRIPTION = 'rest-param-description' |
Parameter description to use in generated documentation. | |
const | PARAM_SOURCE = 'rest-param-source' |
(string) ParamValidator constant to specify the source of the parameter. | |
Wrapper for ParamValidator.
It's intended to be used in the REST API classes by composition.
Definition at line 32 of file Validator.php.
MediaWiki\Rest\Validator\Validator::__construct | ( | ObjectFactory | $objectFactory, |
RequestInterface | $request, | ||
Authority | $authority | ||
) |
ObjectFactory | $objectFactory | |
RequestInterface | $request | |
Authority | $authority |
Definition at line 101 of file Validator.php.
|
static |
Convert a param settings array into an OpenAPI Parameter Object specification structure.
string | $name | |
array | $paramSetting |
Definition at line 226 of file Validator.php.
Referenced by MediaWiki\Rest\Validator\JsonBodyValidator\getOpenAPISpec().
|
static |
Returns JSON Schema description of all known parameter types.
The name of the schema is the name of the parameter type with "-param" appended.
Definition at line 213 of file Validator.php.
MediaWiki\Rest\Validator\Validator::validateBody | ( | RequestInterface | $request, |
Handler | $handler | ||
) |
Validate the body of a request.
This may return a data structure representing the parsed body. When used in the context of Handler::validateParams(), the returned value will be available to the handler via Handler::getValidatedBody().
RequestInterface | $request | |
Handler | $handler | Used to call { |
HttpException | on validation failure |
Definition at line 153 of file Validator.php.
References MediaWiki\Rest\RequestInterface\getBody(), MediaWiki\Rest\Handler\getBodyValidator(), MediaWiki\Rest\RequestInterface\getHeaderLine(), and MediaWiki\Rest\RequestInterface\getMethod().
Referenced by MediaWiki\Rest\Handler\validate().
MediaWiki\Rest\Validator\Validator::validateParams | ( | array | $paramSettings | ) |
Validate parameters.
array[] | $paramSettings | Parameter settings |
HttpException | on validation failure |
Definition at line 121 of file Validator.php.
References Wikimedia\ParamValidator\ValidationException\getFailureMessage(), Wikimedia\ParamValidator\ValidationException\getParamName(), Wikimedia\ParamValidator\ValidationException\getParamValue(), and MediaWiki\Rest\Handler\PARAM_SOURCE.
Referenced by MediaWiki\Rest\Handler\validate().
const MediaWiki\Rest\Validator\Validator::PARAM_DESCRIPTION = 'rest-param-description' |
Parameter description to use in generated documentation.
Definition at line 46 of file Validator.php.
const MediaWiki\Rest\Validator\Validator::PARAM_SOURCE = 'rest-param-source' |
(string) ParamValidator constant to specify the source of the parameter.
Value must be 'path', 'query', or 'body' ('post' is accepted as an alias for 'body'). '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.
Definition at line 41 of file Validator.php.