- Issue created by @wim leers
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
The intent has been from the start to avoid adding "Drupalism" to SDC's use of JSON Schema.
That's why we started using
/schema.json
and defined$ref: json-schema-definitions://experience_builder.module/image-uri
.However, given that ⨠[PP-1] Make link widget autocomplete work (for uri and uri-reference props) Postponed is proposing to add a variation for
format: uri
namedformat: uri+entity_autocomplete
(which required a core change: š ComponentValidator ignores the set validator and creates a new one Active )So, an alternative HERE could be that we start using custom
format
s (fortype: string
). Which is exactly what @lauriii expressed he'd strongly prefer over at #3462705-47: [META] Missing features in SDC needed for XB ā . (Note that JSON Schema does support custom format attributes: https://json-schema.org/draft/2020-12/json-schema-validation#section-7 + https://json-schema.org/draft/2020-12/json-schema-validation#name-custom...)Or better yet: use
contentMediaType
.So then we'd go from:
"image-uri": { "title": "Image URL", "type": "string", "format": "uri-reference", "pattern": "^(/|https?://)?.*\\.(png|gif|jpg|jpeg|webp)(\\?.*)?(#.*)?$" },
to:
"image-uri": { "title": "Image URL", "type": "string", "format": "uri-reference", "contentMediaType": "image/*" },
⦠which is not quite exactly how
contentMediaType
is meant to be used (that's really describing the contents of the string itself), but is ⦠close enough? Something along these lines has been proposed asresourceMediaType
.Examples of actually defining new JSON Schema formats seem impossible to find.
This would then also allow us to apply a similar improvement to "video URLs", which is being added at ⨠Define JSON Schema $refs for linking/embedding videos and linking documents Active .
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
Related but different: š Decouple image shape matching from the `image` MediaType Active .
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
Bumping to priority. Because without this, we'll need to keep doing awkward dances/updates and we'll never match all image fields.
IOW: without this, we won't be able to match any image fields or image media on existing Drupal sites that do not allow AVIF uploads. That's bad! XB users will be (rightfully!) baffled and frustrated that they can't use their years worth of uploaded images.
- Issue was unassigned.
- Status changed to Needs review
6 days ago 2:38pm 19 August 2025 - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
Same is true for video, which is currently limited to just MP4.
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
The pivot from
uri-reference
touri
should be uneventful, because as described in https://github.com/json-schema/json-schema/issues/81, URI references are a subset of URLs.But in practice, this does not seem to be the case, due to the utterly broken JSON Schema validation of URIs in
justinrainbow/json-schema
. Hopefully #3540470-14: Support for latest 6.x version of justinrainbow/json-schema package ā brings relief.For now, sticking to
uri-reference
to reign in scope. - Merge request !1464Draft: Resolve #3530351 "Decouple imagevideo uri" ā (Closed) created by wim leers
- Merge request !1465Updated `StaticPropSource` computation logic: update... ā (Open) created by wim leers
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
Looks like #7 is turning out to become a reality, but for a different reason š
The problem appears to be that
pattern: ^(/|https?://)?
is not considered valid in 5.3 (which CI is testing with), but is considered valid in 6.4. š« Which I'm developing against locally, and I don't really have a choice, because I'm on a non-ancient version of Composer, which forces this:$ composer require justinrainbow/json-schema:^5.3 justinrainbow/json-schema is currently present in the require-dev key and you ran the command without the --dev flag, which will move it to the require key. Do you want to move this requirement? [no]? yes ./composer.json has been updated Running composer update justinrainbow/json-schema > Drupal\Composer\Composer::ensureComposerVersion Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages. Problem 1 - Root composer.json requires justinrainbow/json-schema ^5.3, found justinrainbow/json-schema[5.3.0, 5.x-dev] but these were not loaded, likely because it conflicts with another require. Problem 2 - composer/composer is locked to version 2.8.9 and an update of this package was not requested. - composer/composer 2.8.9 requires justinrainbow/json-schema ^6.3.1 -> found justinrainbow/json-schema[dev-master, 6.3.1, ..., 6.x-dev (alias of dev-master)] but it conflicts with your root composer.json require (^5.3). Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions. Installation failed, reverting ./composer.json and ./composer.lock to their original content.
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
The 5.3 regex validation logic is apparently this:
protected function validateRegex($regex) { return false !== @preg_match('/' . $regex . '/u', ''); }
ā https://github.com/jsonrainbow/json-schema/blob/5.3.0/src/JsonSchema/Con...
Which indeed fails: https://3v4l.org/hPCA3.
In 6.3.1 and later it is very different: https://github.com/jsonrainbow/json-schema/blob/6.3.1/src/JsonSchema/Con...
- š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
LOLOL reading š Allow 6.x version of justinrainbow/json-schema Active points to Composer 2.8.6 vs 2.8.8, while here 2.8.10 is used. https://github.com/composer/composer/releases/tag/2.8.10 points to https://github.com/composer/composer/pull/12376, which is ⦠very much a similar problem š (It touches upon
pattern
being quite brittle, and literally does what we did in š Img prop constraints require extension to be lower case Active !) - š§šŖBelgium wim leers Ghent š§šŖšŖšŗ
The
justinrainbow/json-schema
version bump didn't work, root cause was #3538439-13: Running tests locally is difficult to match with the CI ā . Being fixed at #3540470-16: Support for latest 6.x version of justinrainbow/json-schema package ā .Will continue after the weekend.