aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Rest/Handler
diff options
context:
space:
mode:
authorAtieno <pnjira@wikimedia.org>2024-11-06 11:14:14 +0300
committerAtieno <pnjira@wikimedia.org>2024-11-15 12:29:00 +0300
commit401d6a7fdad866b6d26d6204c606dfe1229256ae (patch)
treeedbd853fa43a5e0ab7f5e55929c6998fc7d8ce31 /includes/Rest/Handler
parent45bb2713e534f66204bf39e7f22d9fc4e263cebf (diff)
downloadmediawikicore-401d6a7fdad866b6d26d6204c606dfe1229256ae.tar.gz
mediawikicore-401d6a7fdad866b6d26d6204c606dfe1229256ae.zip
REST: Allow specifying param descriptions as MessageValue objects
Previously, parameter descriptions could only be specified as strings. We want OpenAPI specs generated from parameter definitions to be internationalizable, so allow specifying descriptions as MessageValue objects, which can be translated using normal MediaWiki mechanisms. Bug: T376493 Change-Id: I8cd4f77c23c113906d2d04697b9d3680487dea0c
Diffstat (limited to 'includes/Rest/Handler')
-rw-r--r--includes/Rest/Handler/Helper/HtmlInputTransformHelper.php6
-rw-r--r--includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php2
-rw-r--r--includes/Rest/Handler/Helper/PageContentHelper.php2
3 files changed, 10 insertions, 0 deletions
diff --git a/includes/Rest/Handler/Helper/HtmlInputTransformHelper.php b/includes/Rest/Handler/Helper/HtmlInputTransformHelper.php
index 6f8adaec06f2..4adacd2a6c72 100644
--- a/includes/Rest/Handler/Helper/HtmlInputTransformHelper.php
+++ b/includes/Rest/Handler/Helper/HtmlInputTransformHelper.php
@@ -188,6 +188,7 @@ class HtmlInputTransformHelper {
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_DEFAULT => '',
ParamValidator::PARAM_REQUIRED => false,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-html-input-title' )
],
// XXX: Needed for compatibility with the parsoid transform endpoint.
// But revid should just be part of the info about the original data
@@ -197,6 +198,7 @@ class HtmlInputTransformHelper {
ParamValidator::PARAM_TYPE => 'int',
ParamValidator::PARAM_DEFAULT => 0,
ParamValidator::PARAM_REQUIRED => false,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-html-input-oldid' )
],
// XXX: Supported for compatibility with the parsoid transform endpoint.
// If given, it should be 'html' or 'pagebundle'.
@@ -205,6 +207,7 @@ class HtmlInputTransformHelper {
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_DEFAULT => '',
ParamValidator::PARAM_REQUIRED => false,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-html-input-from' )
],
// XXX: Supported for compatibility with the parsoid transform endpoint.
// Ignored.
@@ -213,18 +216,21 @@ class HtmlInputTransformHelper {
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_DEFAULT => '',
ParamValidator::PARAM_REQUIRED => false,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-html-input-format' )
],
'contentmodel' => [ // XXX: get this from the Accept header?
Handler::PARAM_SOURCE => 'query',
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_DEFAULT => '',
ParamValidator::PARAM_REQUIRED => false,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-html-input-contentmodel' )
],
'language' => [ // TODO: get this from Accept-Language header?!
Handler::PARAM_SOURCE => 'query',
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_DEFAULT => '',
ParamValidator::PARAM_REQUIRED => false,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-html-input-language' )
]
];
}
diff --git a/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php b/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php
index b41aab237a09..2eca213ebdaf 100644
--- a/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php
+++ b/includes/Rest/Handler/Helper/HtmlOutputRendererHelper.php
@@ -598,12 +598,14 @@ class HtmlOutputRendererHelper implements HtmlOutputHelper {
ParamValidator::PARAM_TYPE => 'boolean',
ParamValidator::PARAM_DEFAULT => false,
ParamValidator::PARAM_REQUIRED => false,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-html-output-stash' )
],
'flavor' => [
Handler::PARAM_SOURCE => 'query',
ParamValidator::PARAM_TYPE => self::OUTPUT_FLAVORS,
ParamValidator::PARAM_DEFAULT => 'view',
ParamValidator::PARAM_REQUIRED => false,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-html-output-flavor' )
],
];
}
diff --git a/includes/Rest/Handler/Helper/PageContentHelper.php b/includes/Rest/Handler/Helper/PageContentHelper.php
index 7437de25c70e..6f136494ca82 100644
--- a/includes/Rest/Handler/Helper/PageContentHelper.php
+++ b/includes/Rest/Handler/Helper/PageContentHelper.php
@@ -331,12 +331,14 @@ class PageContentHelper {
Handler::PARAM_SOURCE => 'path',
ParamValidator::PARAM_TYPE => 'string',
ParamValidator::PARAM_REQUIRED => true,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-page-content-title' ),
],
'redirect' => [
Handler::PARAM_SOURCE => 'query',
ParamValidator::PARAM_TYPE => 'boolean',
ParamValidator::PARAM_REQUIRED => false,
ParamValidator::PARAM_DEFAULT => true,
+ Handler::PARAM_DESCRIPTION => new MessageValue( 'rest-param-desc-page-content-redirect' ),
]
];
}