- Issue created by @penyaskito
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Iβd swear this was already working, but I guess not?! π€ͺ
Thanks to the solid test infra + @penyaskitoβs excellent issue summary, I believe this is doable for a novice contributor π
- First commit to issue fork.
- πΊπΈUnited States partyka
Turns out there are already some SDC components, using "object" already committed to the `xb_test_sdc` testing
Specifically these SDCs:
tests/modules/xb_test_sdc/components/image-optional-with-example
tests/modules/xb_test_sdc/components/image-optional-with-example-and-additional-prop
tests/modules/xb_test_sdc/components/image-optional-without-example/image-optional-without-example.component.yml
tests/modules/xb_test_sdc/components/image-required-with-example
tests/modules/xb_test_sdc/components/image-required-with-invalid-example
tests/modules/xb_test_sdc/components/image-required-without-exampleThis was uncovered in a slack chat with @penyaskito.. It was also mentioned in the chat that an array of objects is OK.
- πͺπΈSpain penyaskito Seville π, Spain πͺπΈ, UTC+2 πͺπΊ
Looking at
config/schema/experience_builder.json_schema
we can find thattype: object
is valid, but only if$ref
is defined too:'$ref': # β οΈ Note the absence of `requiredKey: false` here: XB does not (yet) support arbitrary `type: object` shapes, so # `$ref` is actually REQUIRED for such props!
In
/schema.json
we can see the accepted values for$ref
.So we should validate in
ComponentMetadataRequirementsChecker::check
that if type is object,$ref
is present.Later we could actually validate that
$ref
is one of the valid values (onlyjson-schema-definitions://experience_builder.module/image
for now), but we probably want to leave that out for now.Updated the requirements in the issue summary.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Looking at
config/schema/experience_builder.json_schema
we can find thattype: object
is valid, but only if$ref
is defined too:Correct. Because we don't have π [PP-1] Support `{type: object, β¦}` prop shapes that require *multiple* field types Postponed yet. See
\Drupal\experience_builder\JsonSchemaInterpreter\JsonSchemaType::computeStorablePropShape()
and\Drupal\experience_builder\Hook\ShapeMatchingHooks::datetimeRangeStoragePropShapeAlter()
β those are the two only object shapes currently supported by XB.Later we could actually validate that
$ref
is one of the valid values (onlyjson-schema-definitions://experience_builder.module/image
for now), but we probably want to leave that out for now.That is actually already handled in
\Drupal\experience_builder\ComponentMetadataRequirementsChecker::check()
, thanks to this bit:// Every prop must have a StorablePropShape. $component_prop_expression = new ComponentPropExpression($component_id, $prop_name); $prop_shape = $props_for_metadata[(string) $component_prop_expression]; $storable_prop_shape = $prop_shape->getStorage(); if ($storable_prop_shape instanceof StorablePropShape) { continue; } $messages[] = \sprintf('Experience Builder does not know of a field type/widget to allow populating the <code>%s
prop, with the shape
%s
.', $prop_name, json_encode($prop_shape->schema, JSON_UNESCAPED_SLASHES));
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Wow, looks like @partyka pretty much did everything needed here, but just didn't create an MR yet? :D
Awesome, thanks so much! π€©
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Lovely, thanks, @partyka! π
-
wim leers β
committed 83bdae14 on 0.x
Issue #3523625 by partyka, wim leers, penyaskito:...
-
wim leers β
committed 83bdae14 on 0.x