Skip to content
Snippets Groups Projects
Commit 8adb2b0e authored by Michael Stenta's avatar Michael Stenta
Browse files

Merge branch '3322227-document-schema-title' into '8.x-1.x'

Issue #3322227 by symbioquine, m.stenta: Document schema title wrong for multiple resource types

See merge request !20
parents 494c3baf ad37b984
No related branches found
No related tags found
No related merge requests found
Pipeline #497466 passed
......@@ -161,7 +161,7 @@ class JsonApiSchemaController extends ControllerBase {
}, $resource_type);
$title = count($titles) === 2
? implode(' and ', $titles)
: implode(', ', array_slice($titles, -1)) . ', and ' . end($titles);
: implode(', ', array_slice($titles, 0, -1)) . ', and ' . end($titles);
}
else {
$title = $this->getSchemaTitle($this->resourceTypeRepository->getByTypeName($resource_type), $route_type);
......
......@@ -75,6 +75,12 @@ class JsonApiSchemaTest extends KernelTestBase {
'bundle' => ['article', 'blog'],
'cardinality' => -1,
],
'test_entity_reference2' => [
'title' => 'Article content item, Blog content item, and Page content item',
'entity_type' => 'node',
'bundle' => ['article', 'blog', 'page'],
'cardinality' => 1,
],
],
],
'Blog content items' => [
......@@ -102,6 +108,31 @@ class JsonApiSchemaTest extends KernelTestBase {
],
],
],
'Page content items' => [
'entity_type' => 'node',
'bundle' => 'page',
'title' => 'Page content item',
'relationships' => [
'node_type' => [
'title' => 'Content type',
'entity_type' => 'node_type',
'bundle' => 'node_type',
'cardinality' => 1,
],
'revision_uid' => [
'title' => 'User',
'entity_type' => 'user',
'bundle' => 'user',
'cardinality' => 1,
],
'uid' => [
'title' => 'User',
'entity_type' => 'user',
'bundle' => 'user',
'cardinality' => 1,
],
],
],
'Content types' => [
'entity_type' => 'node_type',
'bundle' => 'node_type',
......@@ -200,6 +231,12 @@ class JsonApiSchemaTest extends KernelTestBase {
$this->installEntitySchema('file');
$this->installEntitySchema('node');
// Create a basic page node type.
NodeType::create([
'type' => 'page',
'name' => 'Page',
])->save();
// Create a basic blog node type.
NodeType::create([
'type' => 'blog',
......@@ -255,6 +292,32 @@ class JsonApiSchemaTest extends KernelTestBase {
]);
$field->save();
// Add a second entity_reference field that allows referencing 3 bundles.
$field_storage = FieldStorageConfig::create([
'field_name' => 'test_entity_reference2',
'type' => 'entity_reference',
'entity_type' => 'node',
]);
$field_storage->save();
$field = FieldConfig::create([
'field_name' => 'test_entity_reference2',
'entity_type' => 'node',
'bundle' => 'article',
'label' => 'Test entity reference 2',
'description' => 'Test entity reference 2 description',
'settings' => [
'target_type' => 'node',
'handler_settings' => [
'target_bundles' => [
'article',
'blog',
'page',
],
],
],
]);
$field->save();
// Add a datetime field with "Date only".
$field_storage = FieldStorageConfig::create([
'field_name' => 'test_date',
......@@ -674,6 +737,12 @@ class JsonApiSchemaTest extends KernelTestBase {
'id_type' => 'integer',
'id_title' => 'Content ID',
],
'test_entity_reference2' => [
'title' => 'Test entity reference 2',
'description' => 'Test entity reference 2 description',
'id_type' => 'integer',
'id_title' => 'Content ID',
],
];
foreach ($expected_relationships as $rel => $rel_info) {
......@@ -729,6 +798,7 @@ class JsonApiSchemaTest extends KernelTestBase {
// Test entity_reference fields.
$this->assertEquals(['node--article', 'node--blog'], $data['definitions']['relationships']['properties']['test_entity_reference']['properties']['data']['items']['properties']['type']['enum']);
$this->assertEquals(['node--article', 'node--blog', 'node--page'], $data['definitions']['relationships']['properties']['test_entity_reference2']['properties']['data']['properties']['type']['enum']);
// Test string fields.
$this->assertEquals(255, $data['definitions']['attributes']['properties']['title']['maxLength']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment