aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Settings/Source
diff options
context:
space:
mode:
Diffstat (limited to 'includes/Settings/Source')
-rw-r--r--includes/Settings/Source/ReflectionSchemaSource.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/includes/Settings/Source/ReflectionSchemaSource.php b/includes/Settings/Source/ReflectionSchemaSource.php
index 1f6294eb4c63..9fcf150d9e12 100644
--- a/includes/Settings/Source/ReflectionSchemaSource.php
+++ b/includes/Settings/Source/ReflectionSchemaSource.php
@@ -58,10 +58,17 @@ class ReflectionSchemaSource implements SettingsSource {
}
/**
+ * @inheritDoc
+ */
+ public function load(): array {
+ return $this->loadAsComponents();
+ }
+
+ /**
* @throws SettingsBuilderException
* @return array
*/
- public function load(): array {
+ public function loadAsComponents(): array {
$schemas = [];
$defs = [];
$obsolete = [];
@@ -120,6 +127,29 @@ class ReflectionSchemaSource implements SettingsSource {
}
/**
+ * Load the data as a single top-level JSON Schema.
+ *
+ * Returned JSON Schema is for an object, which includes the individual config schemas. The
+ * returned schema may contain `$defs`, which then may be referenced internally in the schema
+ * via `$ref`.
+ *
+ * @return array
+ */
+ public function loadAsSchema(): array {
+ $info = $this->loadAsComponents();
+ $schema = [
+ 'type' => 'object',
+ 'properties' => $info['config-schema'],
+ ];
+
+ if ( $info['schema-definitions'] ) {
+ $schema['$defs'] = $info['schema-definitions'];
+ }
+
+ return $schema;
+ }
+
+ /**
* Returns this file source as a string.
*
* @return string