- Issue created by @wim leers
See https://opis.io/json-schema/2.x/formats.html#uri vs https://opis.io/json-schema/2.x/formats.html#uri-reference.
format: uri
allows only absolute URLs, format: uri-reference
allows both absolute and relative URLs.
However, \Drupal\Tests\experience_builder\Kernel\PropShapeToFieldInstanceTest::provider()
shows we're not properly respecting this, because entity:file␝uri␞␟url
evaluates to a relative URL, and is among the suggested DynamicPropSource
s for format: uri
(absolute only), which will negatively impact
🌱
[META] Content templates
Active
:
'REQUIRED, type=string&format=uri' => [
…
'static prop source' => 'ℹ︎link␟url',
'instances' => [
'ℹ︎␜entity:file␝uri␞␟url',
'ℹ︎␜entity:file␝uri␞␟value',
'ℹ︎␜entity:media:baby_videos␝field_media_video_file␞␟entity␜␜entity:file␝uri␞␟url',
'ℹ︎␜entity:media:baby_videos␝field_media_video_file␞␟entity␜␜entity:file␝uri␞␟value',
'ℹ︎␜entity:media:vacation_videos␝field_media_video_file_1␞␟entity␜␜entity:file␝uri␞␟url',
'ℹ︎␜entity:media:vacation_videos␝field_media_video_file_1␞␟entity␜␜entity:file␝uri␞␟value',
'ℹ︎␜entity:node:foo␝field_silly_image␞␟entity␜␜entity:file␝uri␞␟url',
'ℹ︎␜entity:node:foo␝field_silly_image␞␟entity␜␜entity:file␝uri␞␟value',
'ℹ︎␜entity:node:foo␝field_silly_image␞␟src_with_alternate_widths',
],
…
],
Refine both
// TRICKY: Drupal core does not support RFC3987 aka IRIs, but it's a superset of RFC3986.
// TRICKY: the `uri` and `iri` prop types will only pass validation with absolute paths, so we
// instead use the link widget which is more permissive about the URI/IRI content.
// @see \Drupal\Core\Field\Plugin\Field\FieldType\UriItem
// @see \Drupal\link\Plugin\Field\FieldType\LinkItem::defaultFieldSettings()
static::UriReference, static::Uri, static::IriReference, static::Iri => new StorablePropShape(
shape: $shape,
fieldTypeProp: new FieldTypePropExpression('link', 'url'),
// @see \Drupal\link\Plugin\Field\FieldType\LinkItem::defaultFieldSettings()
fieldInstanceSettings: [
// This shape only needs the URI, not a title.
'title' => 0,
],
fieldWidget: 'link_default',
),
(for format: uri
, use \Drupal\link\LinkItemInterface::LINK_GENERIC
, and \Drupal\link\LinkItemInterface::LINK_INTERNAL
for format: uri-reference
)
// TRICKY: Drupal core does not support RFC3987 aka IRIs, but it's a superset of RFC3986.
static::UriReference, static::Uri, static::Iri, static::IriReference => new DataTypeShapeRequirement('PrimitiveType', [], UriInterface::class),
No more incorrect suggestions provided by 📌 Move `PropSourceEndpointTest` into new `XbConfigEntityHttpApiTest::testComponent()` Active .
Active
1.0
Shape matching