From 84412db2eddcf845817f38de260a060768fab2c5 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Mon, 3 Jul 2017 15:54:01 +0300 Subject: [PATCH] Bug 18890: REST API: Fix fetching operation spec in route chain Mojolicious::Plugin::OpenAPI version 1.17 added a feature for fetching API spec in route chain. For us, this type of functionality is used in authentication with our own workaround introduced in Bug 18137. Our own workaround no longer works if M::P::OpenAPI version >=1.17. When upgrading Mojolicious::Plugin::OpenAPI dependency, this patch will fix the issue. To test: 1. prove t/db_dependent/api/v1 --- C4/Installer/PerlDependencies.pm | 2 +- Koha/REST/V1/Auth.pm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm index 9f241e2..5efd20b 100644 --- a/C4/Installer/PerlDependencies.pm +++ b/C4/Installer/PerlDependencies.pm @@ -785,7 +785,7 @@ our $PERL_DEPS = { 'Mojolicious::Plugin::OpenAPI' => { 'usage' => 'REST API', 'required' => '1', - 'min_ver' => '1.13', + 'min_ver' => '1.17', }, 'JSON::Validator' => { 'usage' => 'REST API', diff --git a/Koha/REST/V1/Auth.pm b/Koha/REST/V1/Auth.pm index 77864eb..27ee431 100644 --- a/Koha/REST/V1/Auth.pm +++ b/Koha/REST/V1/Auth.pm @@ -108,7 +108,7 @@ if authorization is required and user has required permissions to access. sub authenticate_api_request { my ( $c ) = @_; - my $spec = $c->match->endpoint->pattern->defaults->{'openapi.op_spec'}; + my $spec = $c->openapi->spec; my $authorization = $spec->{'x-koha-authorization'}; my $cookie = $c->cookie('CGISESSID'); my ($session, $user); -- 2.7.4