Per T357025 we can get the parsed contents of the request body from HandlerInterface::getParsedBody. This allows ParamValidator to validate body fields in the same way it validates form data. We just need to add support for the "body" source to ParamValidatorCallbacks::getParamsFromSource().
Description
Description
NOTE: This solution is insufficient to cover the need to fail on extraneous fields in the request body. One possible solution would be to provide a method that can explicitly be called from execute() that will perform the necessary check. This way, handlers that need this check can op into applying it in a straight-forward way.
Details
Details
Related Changes in Gerrit:
| Subject | Repo | Branch | Lines +/- | |
|---|---|---|---|---|
| handler: Declare known sources in Validator | mediawiki/core | master | +20 -6 | |
| paramValidator: Add case body to get parsed json | mediawiki/core | master | +101 -0 |
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| In Progress | None | T366833 REST: Request Body Validation (tracking) | |||
| Open | None | T357909 Clarify Handler::getValidatedBody error states | |||
| Resolved | daniel | T305973 JsonBodyValidator does not validate the parameter types | |||
| Resolved | daniel | T358850 Rest: make getValidatedBody return body parameters | |||
| Resolved | daniel | T358560 Rest: Deprecate BodyValidator | |||
| Resolved | Atieno | T358558 Rest ParamValidator should support validation of fields in the request body | |||
| Resolved | Atieno | T357025 Add getParsedBody to RequestInterface in the REST framework |
Event Timeline
Comment Actions
Change 1006873 had a related patch set uploaded (by Atieno; author: Atieno):
[mediawiki/core@master] paramValidator: Add case body to get parsed json
Comment Actions
Change 1006873 merged by jenkins-bot:
[mediawiki/core@master] paramValidator: Add case body to get parsed json
Comment Actions
Change #1014651 had a related patch set uploaded (by Atieno; author: Atieno):
[mediawiki/core@master] handler: Declare know sources in Validator
Comment Actions
Change #1014651 merged by jenkins-bot:
[mediawiki/core@master] handler: Declare known sources in Validator