summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authore0ipso2018-04-28 15:37:47 (GMT)
committerMateu Aguiló Bosch2018-04-28 15:37:47 (GMT)
commit5f53854050d04805ceaabf43075573deba6ce8e8 (patch)
tree3b4fd7de7338489b9e65c05a0ae2399b0b5c214f
parentde1e261ea13c4a209be6691bd6372b7415f86f9d (diff)
Issue #2967573 by e0ipso: Small inaccuracies for JSON API schemas8.x-2.0-rc38.x-2.0
-rw-r--r--src/Normalizer/SchemataSchemaNormalizer.php13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Normalizer/SchemataSchemaNormalizer.php b/src/Normalizer/SchemataSchemaNormalizer.php
index 5210af6..7b17cbc 100644
--- a/src/Normalizer/SchemataSchemaNormalizer.php
+++ b/src/Normalizer/SchemataSchemaNormalizer.php
@@ -41,13 +41,14 @@ class SchemataSchemaNormalizer extends SchemataJsonSchemaSchemataSchemaNormalize
}
// Alter the attributes according to the resource config.
+ $root = &$normalized['properties']['data']['properties'];
foreach (['attributes', 'relationships'] as $property_type) {
- if (!isset($normalized['properties'][$property_type]['required'])) {
- $normalized['properties'][$property_type]['required'] = [];
+ if (!isset($root[$property_type]['required'])) {
+ $root[$property_type]['required'] = [];
}
$required_fields = [];
- foreach ($normalized['properties'][$property_type]['properties'] as $fieldname => $schema) {
- $properties = &$normalized['properties'][$property_type]['properties'];
+ foreach ($root[$property_type]['properties'] as $fieldname => $schema) {
+ $properties = &$root[$property_type]['properties'];
unset($properties[$fieldname]);
if (!$resource_type->isFieldEnabled($fieldname)) {
@@ -58,12 +59,12 @@ class SchemataSchemaNormalizer extends SchemataJsonSchemaSchemataSchemaNormalize
// Otherwise, substitute the public name.
$public_name = $resource_type->getPublicName($fieldname);
$properties[$public_name] = $schema;
- if (in_array($fieldname, $normalized['properties'][$property_type]['required'])) {
+ if (in_array($fieldname, $root[$property_type]['required'])) {
$required_fields[] = $public_name;
}
}
}
- $normalized['properties'][$property_type]['required'] = $required_fields;
+ $root[$property_type]['required'] = $required_fields;
}
return $normalized;