Page MenuHomeWickedGov Phorge

TransformWikitextToLintRevisionHandler.php
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

TransformWikitextToLintRevisionHandler.php

<?php
namespace MediaWiki\Rest\Handler;
use MediaWiki\Rest\Handler;
use Wikimedia\Message\MessageValue;
use Wikimedia\ParamValidator\ParamValidator;
/**
* Handler for transforming content given in the request.
*
* This class primarily deals with parameter validation and OpenAPI spec generation.
* Everything else is handled by the base class.
*
* TODO: reconsider the ParsoidHandler => TransformHandler hierarchy. Consider consolidating
* classes and moving more validation into functions like getParamSettings(),
* getBodyParamSettings(), etc.
*
* @unstable Pending consolidation of the Parsoid extension with core code.
*/
class TransformWikitextToLintRevisionHandler extends TransformHandler {
/** @inheritDoc */
public function getParamSettings() {
return [
'title' => [
self::PARAM_SOURCE => 'path',
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_REQUIRED => true,
Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-transform-title' ),
],
'revision' => [
self::PARAM_SOURCE => 'path',
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_REQUIRED => true,
Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-transform-revision' ),
],
];
}
/**
* The parent TransformHandler class accepts a variety of body parameters in different
* situations, some of which can accept values in multiple types and therefore cannot
* be described in getBodyParamSettings(). See TransformHandler::execute(), and notice
* that both "wikitext" and "html" can be either a string or an object.
*
* We therefore define a request body schema directly rather than the more common approach of
* generating it from definitions in getBodyParamSettings().
*/
protected function getRequestBodySchema( string $mediaType ): array {
return [
'oneOf' => [
[
'type' => 'object',
'properties' => [
'wikitext' => [
'type' => 'string',
]
]
],
[
'type' => 'object',
'properties' => [
'wikitext' => [
'type' => 'object',
'properties' => [
'headers' => [
'type' => 'object',
],
'body' => [
'type' => 'string',
]
]
]
]
]
],
];
}
}

File Metadata

Mime Type
text/x-php
Expires
Aug 15 2026, 08:17 (12 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
de/12/e1c4a3fd1c9ab67214c34e6d3213
Default Alt Text
TransformWikitextToLintRevisionHandler.php (2 KB)

Event Timeline