diff --git a/api/v1/swagger/definitions/vendor.yaml b/api/v1/swagger/definitions/vendor.yaml index 3bf8a17977..262db4fb10 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 ed817cc2a1..991419e541 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 f9520d886e..9fd1e6d9dc 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');