From bb353beb397066986513aff40e0fcfb92277f8d0 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 9 Aug 2017 11:54:42 +0100 Subject: [PATCH] Bug 11897: Move from ::Swagger to ::OpenAPI. * Koha/REST/V1/Stage.pm * api/v1/swagger/paths/rotas.json Signed-off-by: Kathleen Milne --- Koha/REST/V1/Stage.pm | 33 +++++++++++++++++---------------- api/v1/swagger/paths/rotas.json | 1 + 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Koha/REST/V1/Stage.pm b/Koha/REST/V1/Stage.pm index 5d2cfcb398..fa4ca7ad2b 100644 --- a/Koha/REST/V1/Stage.pm +++ b/Koha/REST/V1/Stage.pm @@ -23,25 +23,26 @@ use Koha::StockRotationRotas; use Koha::StockRotationStages; sub move { - my ($c, $args, $cb) = @_; - - my $rota = Koha::StockRotationRotas->find($args->{rota_id}); - my $stage = Koha::StockRotationStages->find($args->{stage_id}); - - if ($stage && $rota) { - my $result = $stage->move_to($args->{position}); - return $c->$cb({}, 200) if $result; - return $c->$cb( - { error => "Bad request - new position invalid"}, - 400 + my $c = shift->openapi->valid_input or return; + my $input = $c->validation->output; + + my $rota = Koha::StockRotationRotas->find( $input->{rota_id} ); + my $stage = Koha::StockRotationStages->find( $input->{stage_id} ); + + if ( $stage && $rota ) { + my $result = $stage->move_to( $input->{position} ); + return $c->render( openapi => {}, status => 200 ) if $result; + return $c->render( + openapi => { error => "Bad request - new position invalid" }, + status => 400 ); - } else { - return $c->$cb( - { error => "Not found - Invalid rota or stage ID"}, - 404 + } + else { + return $c->render( + openapi => { error => "Not found - Invalid rota or stage ID" }, + status => 404 ); } - } 1; diff --git a/api/v1/swagger/paths/rotas.json b/api/v1/swagger/paths/rotas.json index ff13ae1e16..97196e27ea 100644 --- a/api/v1/swagger/paths/rotas.json +++ b/api/v1/swagger/paths/rotas.json @@ -1,6 +1,7 @@ { "/rotas/{rota_id}/stages/{stage_id}/position": { "put": { + "x-mojo-to": "Stage#move", "operationId": "moveStage", "tags": ["rotas"], "parameters": [{ -- 2.11.0