wiki.techinc.nl/tests/phpunit/unit/includes/Settings/Source/ExampleDefinitionsClass.php
Sergio Gimeno e5064359c6 JsonSchemaTrait: normalize resolved references
Why:
In I130326e5762e706be4889e308eeec45a6c7683c5 we introduced
support for json schema references by traversing
and resolving any schema with a $ref property. However
the change missed to normalize the resolved references
along the process resulting in invalid json schema documents
with a $ref property of shape:
["class" => 'SomeClass', 'field' => 'SomeField' ]
instead of a json pointer string to the reference in the
document: "#defs/SomeClass/SomeField"

What:
Instead of spinning a separate reference traversal for
each $ref'ing schema, compute only the current node
reference and recursively call normalizeJsonSchema
on the resolved reference (aka definition)

Bug: T363111
Change-Id: Ic1b11eddebcdd546412ea9f27f3e037d5c242d64
2024-04-26 15:23:55 +02:00

27 lines
485 B
PHP

<?php
namespace MediaWiki\Tests\Unit\Settings\Source;
class ExampleDefinitionsClass {
public const SOME_SCHEMA = [
'type' => 'string'
];
public const REFERENCING_SCHEMA = [
'$ref' => [
'class' => self::class, 'field' => 'SOME_SCHEMA'
]
];
public const CYCLED_SCHEMA = [
'$ref' => [
'class' => self::class, 'field' => 'CYCLED_SCHEMA_LAST'
]
];
public const CYCLED_SCHEMA_LAST = [
'$ref' => [
'class' => self::class, 'field' => 'CYCLED_SCHEMA'
]
];
}