[2.0.0-beta5] Use HTTP URL isntead of a stream wrapper in JSON reference

Created on 14 October 2024, about 2 months ago

Problem/Motivation

Currently, SDCs used in UI Patterns components use an arbitrary

$ref: ui-patterns://boolean

Which is valid from the Json-schema specification point of view, but at the same time limits the use of these component schemas somewhere outside of PHP, Drupal and UI Patterns.

At the same time, I see that there are a huge number of tools https://json-schema.org/tools
that extend the capabilities of schemas, allowing you to document, validate, generate data and much, much more. And I can imagine a day when component schemas can be used somewhere else.

But unfortunately, this $ref turns json-schema into php-drupal-ui-patterns-json-schema

Proposed resolution(s)

I am not a PHP developer and I can't imagine the complexity of these changes, but I theoretically see two ways we can improve this:

1.
https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/SchemaMa...

$plugin_id = str_replace('ui-patterns://', '', $uri);

Here I see the search for id from the string. Thus, the $ref string can look something like this:

$ref: http://example.com/ui-patterns#boolean

which will contain the current state of the scheme.
And theoretically in the module code this replacement can look like this:

$plugin_id = str_replace('example.com/ui-patterns#', '', $uri);

And this can work similarly. But the scheme will be more universal.

2.
The second possible solution would be to simply provide
http://example.com/ui-patterns with the current version of the scheme

which can also be used by the module to generate parts of the schemes
https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/Plugin/U...

but will allow developers of other tools to auto-replace
$ref: ui-patterns://boolean
with
$ref: http://example.com/ui-patterns#boolean

Feature request
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

🇷🇸Serbia finnsky

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024