From fb5cd7ce3aceb082a7a9761b22edd135074aa35a Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Wed, 1 Nov 2023 15:28:47 -0400 Subject: [PATCH] flesh up the example --- t/example.t | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/t/example.t b/t/example.t index 6ea4b4b..6127a05 100644 --- a/t/example.t +++ b/t/example.t @@ -66,10 +66,15 @@ $registry->add_type( self => sub($data,@) { return "/articles/" . $data->{id}; }, + }, + relationships => { + 'tags' => { type => 'tag' }, } } ); +$registry->add_type('tag'); + my $output = $registry->serialize('article', $data, { count => 2 } ); like $output => { @@ -83,6 +88,26 @@ like $output => { "links"=> { "self"=> "/articles" }, + "data"=> [{ + "type"=> "article", + "id"=> "1", + "attributes"=> { + "title"=> "JSON API paints my bikeshed!", + "body"=> "The shortest article. Ever.", + "created"=> "2015-05-22T14:56:29.000Z" + }, + "relationships"=> { + "tags"=> { + "data"=> [{ + "type"=> "tag", + "id"=> "1" + }, { + "type"=> "tag", + "id"=> "2" + }] + }, + } + }], }; done_testing();