2023-10-31 16:16:36 +00:00
|
|
|
use Test2::V0;
|
|
|
|
|
|
|
|
use Dancer2::Plugin::JsonApi::Registry;
|
|
|
|
|
|
|
|
use experimental qw/ signatures /;
|
|
|
|
|
|
|
|
my $registry = Dancer2::Plugin::JsonApi::Registry->new;
|
|
|
|
|
|
|
|
$registry->add_type(
|
|
|
|
people => {
|
2023-10-31 19:54:28 +00:00
|
|
|
id => 'id',
|
|
|
|
links => {
|
|
|
|
self => sub ( $data, @ ) {
|
2023-10-31 20:29:48 +00:00
|
|
|
no warnings qw/ uninitialized /;
|
2023-10-31 19:54:28 +00:00
|
|
|
return "/peoples/$data->{id}";
|
|
|
|
}
|
|
|
|
} } );
|
2023-10-31 16:16:36 +00:00
|
|
|
|
2023-10-31 19:54:28 +00:00
|
|
|
isa_ok $registry->type('people') =>
|
|
|
|
'Dancer2::Plugin::JsonApi::Registry::Schema';
|
2023-10-31 16:16:36 +00:00
|
|
|
|
2023-10-31 19:54:28 +00:00
|
|
|
like(
|
|
|
|
$registry->serialize( people => {} ),
|
|
|
|
{ jsonapi => { version => '1.0' } } );
|
2023-10-31 16:16:36 +00:00
|
|
|
|
|
|
|
done_testing();
|