@@ -, +, @@ --- Koha/REST/V1/Stage.pm | 33 +++++++++++++++++---------------- api/v1/swagger/paths/rotas.json | 1 + 2 files changed, 18 insertions(+), 16 deletions(-) --- a/Koha/REST/V1/Stage.pm +++ a/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; --- a/api/v1/swagger/paths/rotas.json +++ a/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": [{ --