jenkins-bot has submitted this change and it was merged. Change subject: registration: Support custom classes in "ResourceModules" schema ......................................................................
registration: Support custom classes in "ResourceModules" schema
Instead of expecting everything to be a ResourceLoaderFileModule, use
the "anyOf" property to validate against multiple schemas. The following
schemas are now allowed:
* The ResourceLoaderFileModule schema, now with the "targets" property
* A schema for ResourceLoaderImageModule
* A generic schema that requires the "class" property is set, but not to
"ResourceLoaderFileModule" or "ResourceLoaderImageModule".
The last schema will allow for any custom ResourceLoaderModule class to
be set in extension.json with arbitrary parameters.
One downside of this is that the error messages shown when a file does
not validate get a little more confusing, as it shows the error messages
for each schema it does not match.
Bug: T105236
Change-Id: I5e4bfa69c733187c7b27294c159cac05b3b92e81
---
M docs/extension.schema.json
1 file changed, 165 insertions(+), 108 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
Jforrester: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/docs/extension.schema.json b/docs/extension.schema.json
index 218a19c..dde4fa1 100644
--- a/docs/extension.schema.json
+++ b/docs/extension.schema.json
@@ -302,128 +302,185 @@
"ResourceModules": {
"type": "object",
"description": "ResourceLoader modules to register",
- "additionalProperties": false,
"patternProperties": {
"^[a-zA-Z0-9-\\.]+$": {
"type": "object",
- "description": "A single ResourceLoader
module descriptor",
- "properties": {
- "localBasePath": {
- "type": "string",
- "description": "Base
path to prepend to all local paths in $options. Defaults to $IP"
- },
- "remoteBasePath": {
- "type": "string",
- "description": "Base
path to prepend to all remote paths in $options. Defaults to $wgScriptPath"
- },
- "remoteExtPath": {
- "type": "string",
- "description":
"Equivalent of remoteBasePath, but relative to $wgExtensionAssetsPath"
- },
- "scripts": {
- "type": ["string",
"array"],
- "description": "Scripts
to always include (array of file paths)",
- "items": {
- "type": "string"
- }
- },
- "languageScripts": {
- "type": "object",
- "description": "Scripts
to include in specific language contexts (mapping of language code to file
path(s))",
- "patternProperties": {
-
"^[a-zA-Z0-9-]{2,}$": {
- "type":
[
-
"string",
-
"array"
- ],
+ "anyOf": [
+ {
+ "description": "A
ResourceLoaderFileModule definition",
+ "additionalProperties":
false,
+ "properties": {
+
"localBasePath": {
+ "type":
"string",
+
"description": "Base path to prepend to all local paths in $options. Defaults
to $IP"
+ },
+
"remoteBasePath": {
+ "type":
"string",
+
"description": "Base path to prepend to all remote paths in $options. Defaults
to $wgScriptPath"
+ },
+
"remoteExtPath": {
+ "type":
"string",
+
"description": "Equivalent of remoteBasePath, but relative to
$wgExtensionAssetsPath"
+ },
+ "scripts": {
+ "type":
["string", "array"],
+
"description": "Scripts to always include (array of file paths)",
+
"items": {
+
"type": "string"
+ }
+ },
+
"languageScripts": {
+ "type":
"object",
+
"description": "Scripts to include in specific language contexts (mapping of
language code to file path(s))",
+
"patternProperties": {
+
"^[a-zA-Z0-9-]{2,}$": {
+
"type": [
+
"string",
+
"array"
+
],
+
"items": {
+
"type": "string"
+
}
+
}
+ }
+ },
+ "skinScripts": {
+ "type":
"object",
+
"description": "Scripts to include in specific skin contexts (mapping of skin
name to script(s)",
+
"patternProperties": {
+
".+": {
+
"type": [
+
"string",
+
"array"
+
],
+
"items": {
+
"type": "string"
+
}
+
}
+ }
+ },
+ "debugScripts":
{
+ "type":
["string", "array"],
+
"description": "Scripts to include in debug contexts",
+
"items": {
+
"type": "string"
+ }
+ },
+
"loaderScripts": {
+ "type":
["string", "array"],
+
"description": "Scripts to include in the startup module",
+
"items": {
+
"type": "string"
+ }
+ },
+ "dependencies":
{
+ "type":
["string", "array"],
+
"description": "Modules which must be loaded before this module",
+
"items": {
+
"type": "string"
+ }
+ },
+ "styles": {
+ "type":
["string", "array", "object"],
+
"description": "Styles to always load",
+
"items": {
+
"type": "string"
+ }
+ },
+ "skinStyles": {
+ "type":
"object",
+
"description": "Styles to include in specific skin contexts (mapping of skin
name to style(s))",
+
"patternProperties": {
+
".+": {
+
"type": [
+
"string",
+
"array"
+
],
+
"items": {
+
"type": "string"
+
}
+
}
+ }
+ },
+ "messages": {
+ "type":
["string", "array"],
+
"description": "Messages to always load",
+
"items": {
+
"type": "string"
+ }
+ },
+ "group": {
+ "type":
"string",
+
"description": "Group which this module should be loaded together with"
+ },
+ "position": {
+ "type":
"string",
+
"description": "Position on the page to load this module at",
+ "enum":
[
+
"bottom",
+
"top"
+ ]
+ },
+ "templates": {
+ "type":
"object",
+
"description": "Templates to be loaded for client-side usage"
+ },
+ "targets": {
+ "type":
["string", "array"],
+
"description": "ResourceLoader target the module can run on",
"items": {
"type": "string"
}
}
}
},
- "skinScripts": {
- "type": "object",
- "description": "Scripts
to include in specific skin contexts (mapping of skin name to script(s)",
- "patternProperties": {
- ".+": {
- "type":
[
-
"string",
-
"array"
- ],
-
"items": {
-
"type": "string"
- }
+ {
+ "description": "A
ResourceLoaderImageModule definition",
+ "additionalProperties":
false,
+ "properties": {
+ "class": {
+ "enum":
["ResourceLoaderImageModule"]
+ },
+ "data": {
+ "type":
"string"
+ },
+ "prefix": {
+ "type":
"string"
+ },
+ "selector": {
+ "type":
"string"
+ },
+
"selectorWithoutVariant": {
+ "type":
"string"
+ },
+
"selectorWithVariant": {
+ "type":
"string"
+ },
+ "variants": {
+ "type":
"object"
+ },
+ "images": {
+ "type":
"object"
+ },
+ "position": {
+ "enum":
[
+
"top",
+
"bottom"
+ ]
}
}
},
- "debugScripts": {
- "type": ["string",
"array"],
- "description": "Scripts
to include in debug contexts",
- "items": {
- "type": "string"
- }
- },
- "loaderScripts": {
- "type": ["string",
"array"],
- "description": "Scripts
to include in the startup module",
- "items": {
- "type": "string"
- }
- },
- "dependencies": {
- "type": ["string",
"array"],
- "description": "Modules
which must be loaded before this module",
- "items": {
- "type": "string"
- }
- },
- "styles": {
- "type": ["string",
"array", "object"],
- "description": "Styles
to always load",
- "items": {
- "type": "string"
- }
- },
- "skinStyles": {
- "type": "object",
- "description": "Styles
to include in specific skin contexts (mapping of skin name to style(s))",
- "patternProperties": {
- ".+": {
- "type":
[
-
"string",
-
"array"
- ],
-
"items": {
-
"type": "string"
- }
+ {
+ "description": "An
arbitrary ResourceLoaderModule definition",
+ "properties": {
+ "class": {
+ "type":
"string",
+
"pattern": "^((?!ResourceLoader(File|Image)Module).)*$"
}
- }
- },
- "messages": {
- "type": ["string",
"array"],
- "description":
"Messages to always load",
- "items": {
- "type": "string"
- }
- },
- "group": {
- "type": "string",
- "description": "Group
which this module should be loaded together with"
- },
- "position": {
- "type": "string",
- "description":
"Position on the page to load this module at",
- "enum": [
- "bottom",
- "top"
- ]
- },
- "templates": {
- "type": "object",
- "description":
"Templates to be loaded for client-side usage"
+ },
+ "required": ["class"]
}
- }
+ ]
}
}
},
--
To view, visit https://gerrit.wikimedia.org/r/228753
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5e4bfa69c733187c7b27294c159cac05b3b92e81
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: Waldir <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
