Page MenuHomePhabricator

REST: add structure test that checks if param schemas are valid
Closed, ResolvedPublic

Description

RestStructureTest should examine any schemas defined in the ArrayDef::PARAM_SCHEMA field of param settings returned by getBodyParamSettings. The value contained in this field should (after applicable normalization) be a valid JSON schema.

The schema validation should be implemented in a (static?) method in ArrayDef, so we keep the knowledge about the validation library in a single place. It should be implemented using JsonSchema\Validator from the justinrainbow/json-validator package, probably using CHECK_MODE_VALIDATE_SCHEMA (though it's not clear how to do that without a known-good target document).

Furthermore, getParamSettings should not be allowed to make use of the "array" parameter type. That type is only supported in getBodyParamSettings.

  • RestStructureTest change implemented
  • getParamSettings prohibited from using array type

Event Timeline

Reedy renamed this task from REST: add structure test that checks if param schemas are valid. to REST: add structure test that checks if param schemas are valid.Jun 21 2024, 9:43 AM
Reedy updated the task description. (Show Details)
daniel changed the task status from Open to In Progress.Jul 8 2024, 3:47 PM

Change #1053637 had a related patch set uploaded (by WQuarshie; author: WQuarshie):

[mediawiki/core@master] add structure test that checks if param schemas are valid

https://gerrit.wikimedia.org/r/1053637

Change #1053637 merged by jenkins-bot:

[mediawiki/core@master] add structure test that checks if param schemas are valid

https://gerrit.wikimedia.org/r/1053637

Change #1056518 had a related patch set uploaded (by WQuarshie; author: WQuarshie):

[mediawiki/core@master] getParamSettings prohibited from using array type

https://gerrit.wikimedia.org/r/1056518

Change #1056518 merged by jenkins-bot:

[mediawiki/core@master] getParamSettings prohibited from using array type

https://gerrit.wikimedia.org/r/1056518

BPirkle updated the task description. (Show Details)