[Koha-bugs] [Bug 32923] x-koha-embed must a header of collectionFormat csv

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Feb 27 15:01:37 CET 2023


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

Tomás Cohen Arazi <tomascohen at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|BLOCKED                     |Passed QA

--- Comment #24 from Tomás Cohen Arazi <tomascohen at gmail.com> ---
After an exchange with the Mojolicious::Plugin::OpenAPI maintainer and
exchanging pull requests, the conclusion is:

- Validation is not supposed to happen twice
- The validation step is expected to normalize the ->params and ->headers in a
specific way, and we shouldn't be relying on the $c->validation->output
structure as it subject to change and at some point they thought of removing
it. Once validation happens we need to use ->params and ->headers.
- When valid_input is called, the header effectively gets converted into an
array and expecting it to still be a CSv string will lead to problems as we've
seen.
- When collectionFormat is used, we should be using multi, the maintainer
really dislikes the 'csv' implementation.
- I would've expected the plugin to provide us a consistent and usable way to
access parameters through ->validation->output and leave the params untouched,
but this is not the case, by design. And is not going to change.

Having said all that, I agree with this patchset

QA note: I have doubts about the real need for this API spec that points to an
intermediate controller that later calls the *real controller*. I would've just
duplicated the endpoint spec, hardcoding 'ebsco' and 'local' and calling the
appropriate method. The only reason I would accept to keep this, is because you
(ERM devs) might be thinking of extending this with plugins that implement
provider-specific implementations, along the lines of this mocked code:

```perl
sub get {
    my $c = shift->openapi->valid_input or return;

    my @plugins = GetPlugins({  method => 'erm_packages' });

    my $provider = $c->validation->param('provider');
    if ( $provider eq 'ebsco' ) {
        return Koha::REST::V1::ERM::EHoldings::Packages::EBSCO::get($c,
$validated_output);
    } elsif (@plugins) {
        foreach my $plugin (@plugins) {
            if ( $provide eq $plugin->erm_provider ) {
                return $plugin->erm_package_controller::get($c);
            }
        }
    }

    return Koha::REST::V1::ERM::EHoldings::Packages::Local::get($c,
$validated_output);
}
```

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


More information about the Koha-bugs mailing list