@@ -, +, @@ --- Koha/REST/V1/Illrequests.pm | 10 +++++----- api/v1/swagger/paths/illrequests.json | 36 ++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 8 deletions(-) --- a/Koha/REST/V1/Illrequests.pm +++ a/Koha/REST/V1/Illrequests.pm @@ -20,13 +20,13 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; use Koha::Illrequests; -use Koha::Library; +use Koha::Libraries; sub list { - my ($c, $args, $cb) = @_; + my $c = shift->openapi->valid_input or return; + my $args = $c->req->params->to_hash // {}; my $filter; - $args //= {}; my $output = []; # Create a hash where all keys are embedded values @@ -45,7 +45,7 @@ sub list { my $requests = Koha::Illrequests->search($filter); while (my $request = $requests->next) { - my $unblessed = $request->unblessed; + my $unblessed = $request->TO_JSON; # Add the request's id_prefix $unblessed->{id_prefix} = $request->id_prefix; # Augment the request response with patron details @@ -78,7 +78,7 @@ sub list { push @{$output}, $unblessed } - return $c->$cb( $output, 200 ); + return $c->render( status => 200, openapi => $output ); } --- a/api/v1/swagger/paths/illrequests.json +++ a/api/v1/swagger/paths/illrequests.json @@ -1,8 +1,8 @@ { "/illrequests": { "get": { - "x-mojo-controller": "Koha::REST::V1::Illrequests", - "operationId": "list", + "x-mojo-to": "Illrequests#list", + "operationId": "listIllrequests", "tags": ["illrequests"], "parameters": [{ "name": "embed", @@ -85,7 +85,37 @@ ], "responses": { "200": { - "description": "OK" + "description": "A list of ILL requests" + }, + "401": { + "description": "Authentication required", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "403": { + "description": "Access forbidden", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "404": { + "description": "ILL requests not found", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "500": { + "description": "Internal server error", + "schema": { + "$ref": "../definitions.json#/error" + } + }, + "503": { + "description": "Under maintenance", + "schema": { + "$ref": "../definitions.json#/error" + } } }, "x-koha-authorization": { --