From 9d57f663e5608fff37d5698b1c8b026f2908b737 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 7 Nov 2024 12:59:40 +0000 Subject: [PATCH] Bug 38390: Add subscriptions+count to vendors embed This patch adds the subscriptions+count option to the embeddable enum for the /vendors endpoint. Test plan 1) Inspect the change to t/db_dependant/api/v1/acquisitions_vendors.t and confirm it's testing for the addition of subscriptions_count. 2) Run the above tests and confirm it passes Note: For the above tests to pass, you will need to ensure your api bundle is rebuilt after the patches are applied and restart plack. `yarn build && restart_all` in ktd Signed-off-by: Matt Blenkinsop --- api/v1/swagger/definitions/vendor.yaml | 5 +++++ api/v1/swagger/paths/acquisitions_vendors.yaml | 1 + t/db_dependent/api/v1/acquisitions_vendors.t | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/v1/swagger/definitions/vendor.yaml b/api/v1/swagger/definitions/vendor.yaml index 3bf8a179772..262db4fb10b 100644 --- a/api/v1/swagger/definitions/vendor.yaml +++ b/api/v1/swagger/definitions/vendor.yaml @@ -119,6 +119,11 @@ properties: description: List of aliases items: $ref: "vendor_alias.yaml" + subscriptions_count: + type: + - integer + - "null" + description: Number of linked subscriptions additionalProperties: false required: - name diff --git a/api/v1/swagger/paths/acquisitions_vendors.yaml b/api/v1/swagger/paths/acquisitions_vendors.yaml index ed817cc2a1d..991419e5410 100644 --- a/api/v1/swagger/paths/acquisitions_vendors.yaml +++ b/api/v1/swagger/paths/acquisitions_vendors.yaml @@ -35,6 +35,7 @@ type: string enum: - aliases + - subscriptions+count collectionFormat: csv responses: "200": diff --git a/t/db_dependent/api/v1/acquisitions_vendors.t b/t/db_dependent/api/v1/acquisitions_vendors.t index f9520d886e1..9fd1e6d9dc3 100755 --- a/t/db_dependent/api/v1/acquisitions_vendors.t +++ b/t/db_dependent/api/v1/acquisitions_vendors.t @@ -36,7 +36,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); subtest 'list() and delete() tests | authorized user' => sub { - plan tests => 40; + plan tests => 44; $schema->storage->txn_begin; @@ -100,6 +100,13 @@ subtest 'list() and delete() tests | authorized user' => sub { ->json_is('/0/aliases/0/alias' => 'alias 1', 'alias 1 is embeded') ->json_is('/0/aliases/1/alias' => 'alias 2', 'alias 2 is embeded'); + for ( 0 .. 1 ) { + $builder->build_object( { class => 'Koha::Subscriptions', value => { aqbooksellerid => $vendor->id } } ); + } + $t->get_ok( "//$userid:$password@/api/v1/acquisitions/vendors" => { 'x-koha-embed' => 'subscriptions+count' } ) + ->status_is(200)->json_has( '/0/subscriptions_count', 'subscriptions_count is embeded' ) + ->json_is( '/0/subscriptions_count' => '2', 'subscription count is 2' ); + $t->delete_ok( "//$userid:$password@/api/v1/acquisitions/vendors/" . $vendor->id ) ->status_is(204, 'SWAGGER3.2.4') ->content_is('', 'SWAGGER3.3.4'); -- 2.39.3 (Apple Git-146)