Page MenuHomePhabricator

Add support for files as JSON-schema references
Open, Needs TriagePublic

Description

While adding support for schema references in ReflectionSchemaSource for the MediaWiki-extensions-CommunityConfiguration project an ad-hoc "reference object" (it's actually a PHP associative array) was created to support referencing a schema living in a PHP class from another class. eg:

class ExampleSchema extends JsonSchema {
	public const CCExamplePageTitle = [
		self::REF => [ 'class' => MediaWikiDefinitions::class, 'field' => 'PageTitle'  ]
	];
}

While this approach is valuable for the MediaWiki-extensions-CommunityConfiguration, it was brought (in code review comments), that JSON-schema references can and usually have a different shape, commonly a string with an absolute or relative URI pointing to the referenced schema. eg:

class ExampleSchema extends JsonSchema {
	public const CCExamplePageTitleInternal = [
               // Internal ref
		self::REF => 'src/schemas/mediawiki.pagetitle.schema.json'
	];
	public const CCExamplePageTitleExternal = [
               // External ref
		self::REF => 'https://example.com/mediawiki.schema.json'
	];
}

This work could be helpful for the implementation of T358560: Rest: Deprecate BodyValidator . The task is to clarify what kind of references need to be supported and provide such support.

Notes:
Related code review comments

Event Timeline

Hi @Sgs, can you please associate one or more active project tags with this task (via the Add Action...Change Project Tags dropdown)? That will allow to see a task when looking at project workboards or searching for tasks in certain projects, and get notified about a task when watching a related project tag. Thanks!