rest: Use ParamValidator library, add BodyValidator
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 12 Jun 2019 19:51:59 +0000 (15:51 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 4 Sep 2019 14:12:35 +0000 (10:12 -0400)
commitebfbd2d42a57e6cf87feda0d46b0c1bd2c00c2c5
tree78fcbc55641d99594b9d8729597cc3bea3ceeee9
parentbb575f1dc75af99de11568837cdabe28dde5b8e5
rest: Use ParamValidator library, add BodyValidator

Parameter validation is based on parameter definitions like those in the
Action API, using the new ParamValidator library. Handlers should use
the provided Handler methods to access parameters rather than fetching
them directly from the RequestInterface.

Body validation allows the handler to have the (non-form-data) body of a
request parsed and validated. The only validator included in this patch
ignores the body entirely; future patches may implement validation for
JSON bodies based on JSON schemas, or the like.

Bug: T223239
Change-Id: I3c37ea2b432840514b6bff90007c8403989225d5
15 files changed:
includes/Rest/EntryPoint.php
includes/Rest/Handler.php
includes/Rest/Handler/HelloHandler.php
includes/Rest/HttpException.php
includes/Rest/ResponseFactory.php
includes/Rest/Router.php
includes/Rest/SimpleHandler.php
includes/Rest/Validator/BodyValidator.php [new file with mode: 0644]
includes/Rest/Validator/NullBodyValidator.php [new file with mode: 0644]
includes/Rest/Validator/ParamValidatorCallbacks.php [new file with mode: 0644]
includes/Rest/Validator/Validator.php [new file with mode: 0644]
tests/phpunit/includes/Rest/BasicAccess/MWBasicRequestAuthorizerTest.php
tests/phpunit/includes/Rest/EntryPointTest.php
tests/phpunit/unit/includes/Rest/Handler/HelloHandlerTest.php
tests/phpunit/unit/includes/Rest/RouterTest.php