Skip to content

Commit 0499b19

Browse files
authored
allow non namepsaced schema (#8)
1 parent ac07c56 commit 0499b19

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

example/schemaTemplates/embedded/Book.avsc

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"type": "record",
3-
"namespace": "com.example",
43
"name": "Book",
54
"fields": [
65
{ "name": "title", "type": "string" },

example/schemaTemplates/embedded/Collection.avsc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"name": "Collection",
55
"fields": [
66
{ "name": "name", "type": "string" },
7-
{ "name": "items", "type": {"type": "array", "items": ["com.example.Book", "com.example.CD"] }, "default": [] }
7+
{ "name": "items", "type": {"type": "array", "items": ["Book", "com.example.CD"] }, "default": [] }
88
]
99
}

src/Registry/SchemaRegistry.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ public function getSchemaId(array $schemaData, SchemaTemplateInterface $template
150150
return str_replace('.' . Avro::FILE_EXTENSION, '', $template->getFilename());
151151
}
152152

153-
return $schemaData['namespace'] . '.' . $schemaData['name'];
153+
if (true === isset($schemaData['namespace'])) {
154+
return $schemaData['namespace'] . '.' . $schemaData['name'];
155+
}
156+
157+
return $schemaData['name'];
154158
}
155159

156160
/**

tests/Integration/Registry/SchemaRegistryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testSchemaDirectories()
2727
public function testLoad()
2828
{
2929
$schemaIds = [
30-
'com.example.Book',
30+
'Book',
3131
'com.example.CD',
3232
'com.example.Collection',
3333
'com.example.Page',

0 commit comments

Comments
 (0)