From bbd03cd37d3b04cdda0a782649dddd4b716aa4c8 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 3 Mar 2022 14:31:35 -0300 Subject: [PATCH] Bug 30193: Remove use of allow_invalid_ref This patch removes the code that makes Koha allow an invalid spec It is expected to break the API. As an excercise, try saving the raw output from http://localhost:8080/api/v1 into swagger.json along the swagger.yaml file, and tweak V1.pm to point to the json version. Notice the API works! The idea, is we adapt our API so it conforms to the standard as much as possible, while keeping some modularity. --- Koha/REST/Plugin/PluginRoutes.pm | 1 - Koha/REST/V1.pm | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/Koha/REST/Plugin/PluginRoutes.pm b/Koha/REST/Plugin/PluginRoutes.pm index cf7eea882b..5aae160f4a 100644 --- a/Koha/REST/Plugin/PluginRoutes.pm +++ b/Koha/REST/Plugin/PluginRoutes.pm @@ -153,7 +153,6 @@ sub spec_ok { $validator->load_and_validate_schema( $spec, { - allow_invalid_ref => 1, schema => ( $schema ) ? $schema : undef, } ); diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm index 1c22a769d7..236f617e2b 100644 --- a/Koha/REST/V1.pm +++ b/Koha/REST/V1.pm @@ -78,7 +78,6 @@ sub startup { try { $spec = $validator->bundle( { - replace => 1, schema => $self->home->rel_file("api/v1/swagger/swagger.yaml") } ); @@ -95,10 +94,6 @@ sub startup { spec => $spec, route => $self->routes->under('/api/v1')->to('Auth#under'), schema => ( $swagger_schema ) ? $swagger_schema : undef, - allow_invalid_ref => - 1, # required by our spec because $ref directly under - # Paths-, Parameters-, Definitions- & Info-object - # is not allowed by the OpenAPI specification. } ); } @@ -114,7 +109,6 @@ sub startup { $validator->load_and_validate_schema( $self->home->rel_file("api/v1/swagger/swagger.yaml"), { - allow_invalid_ref => 1, schema => ( $swagger_schema ) ? $swagger_schema : undef, } ); @@ -131,10 +125,6 @@ sub startup { OpenAPI => { spec => $spec, route => $self->routes->under('/api/v1')->to('Auth#under'), - allow_invalid_ref => - 1, # required by our spec because $ref directly under - # Paths-, Parameters-, Definitions- & Info-object - # is not allowed by the OpenAPI specification. } ); } -- 2.35.1