[Koha-bugs] [Bug 33556] $c->validation->output should be avoided

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jun 8 18:30:47 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33556

--- Comment #2 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
Created attachment 152213
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=152213&action=edit
Bug 33556: Avoid relying on $c->validation

Talking to the OpenAPI plugin maintainer, he mentioned the use of
$c->validation->output should be avoided as the plugin is not designed to have
a stable behavior there, and he even thought of just removing the method.

That method returns an internal data structure the plugin uses to validate
things, and then updates the request itself.

Take the following example:

GET /patrons/123
x-koha-embed: checkouts,library

without the OpenAPI plugin, requesting the header like this:

$c->req->headers->header('x-koha-embed')

would return a scalar, the string 'checkouts,library'.

When using the plugin, and with `x-koha-embed` being defined as
collectionFormat: csv, that header is entirely replaced by an arrayref.

That's how the plugin works and how it is expected to be used. So we need to
replace the uses of $c->validation format, with normal Mojo usage to avoid
future headaches.

This patch changes:
* $c->validation->param => $c->param
* $c->validation->param('body') => $c->req->json

To test:
1. Run:
   $ ktd --shell
  k$ prove t/db_dependent/api/v1/*.t
=> SUCCESS: Tests pass!
2. Apply this patches
3. Repeat 1
=> SUCCESS: Tests still pass!
4. Sign off :-D

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list