Canvas is using JSON Schema references. Example:
{$ref: 'json-schema-definitions://experience_builder.module/image'}
They are resolved by JsonSchemaDefinitionsStreamwrapper which is looking fine:
Drupal\canvas\JsonSchemaDefinitionsStreamwrapper:
public: true
tags:
- { name: stream_wrapper, scheme: json-schema-definitions }
So it seems just letting the StreamWrapper do its job is enough. However, at a few places in Canvas code, the stream wrapper is replaced/overriden by a direct call to json_decode()
.
AdapterBase::resolveSchemaReferences():
if (isset($schema['$ref'])) {
$schema = json_decode(file_get_contents($schema['$ref']) ?: '{}', TRUE);
}
PropShape::resolveSchemaReferences():
if (isset($schema['$ref'])) {
$schema = json_decode(file_get_contents($schema['$ref']) ?: '{}', TRUE);
}
JsonSchemaFieldInstanceMatcher::resolveSchemaReferences():
if (isset($schema['$ref'])) {
$schema = json_decode(file_get_contents($schema['$ref']) ?: '{}', TRUE);
}
JsonSchemaObject::__construct():
$schema = \json_decode(\file_get_contents($ref) ?: '{}', TRUE, \JSON_THROW_ON_ERROR);
and:
if (\array_key_exists('$ref', $detail)) {
$prop_schema = \json_decode(\file_get_contents($detail['$ref']) ?: '{}', TRUE, \JSON_THROW_ON_ERROR);
Maybe more...
This is error prone for Canvas and this is breaking all other uses of JSON Schema references in SDC. The ones from UI Patterns → , the module I am maintaining, but also any other a Drupaler may use (including the ones defined outside the Drupal ecosystem).
My knowledge of Canvas is not deep enough to propose a fix for the root causes (see "Follow-up"), but let's try a quick "damage control" fix:
json-schema-definitions://
until
🐛
References must not be required to guess props' JSON schema
Active
is OK) json_decode(file_get_contents($schema['$ref'])
execution to json-schema-definitions://
URI, to prevent the break of non Canvas JSON Schema references. Once this first fix merged:
json_decode(file_get_contents($schema['$ref'])
. JsonSchemaDefinitionsStreamwrapper
is already executing file_get_contents
and all parts of the Canvas app must work on the resolved JSON schema returned by this service. can
None.
Needs work
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.