[Koha-bugs] [Bug 33503] Plugin OpenAPI2.0 specification schema fragments are not resolved. Merge full schema definitions.

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Sep 27 19:39:08 CEST 2023


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

Olli-Antti Kivilahti <olli-antti.kivilahti at hypernova.fi> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #149533|0                           |1
        is obsolete|                            |

--- Comment #5 from Olli-Antti Kivilahti <olli-antti.kivilahti at hypernova.fi> ---
Created attachment 156304
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=156304&action=edit
Bug 33503 - Plugin OpenAPI2.0 specification schema fragments are not resolved.
Merge full schema definitions.

Koha::REST::Plugin::PluginRoutes.pm simply injects a plugin's OpenAPI2.0 route
definitions into the /paths -object.
Possibly after Bug 30194, dereferencing OpenAPI2.0 schema fragments/components
has started to fail.
This plugin:
   
https://github.com/Hypernova-Oy/koha-plugin-self-service/releases/tag/v1.0.11
used to get it's REST API paths injected and dereferenced/bundled correctly,
for Koha versions 22.05 and before, but in the new Koha version the same schema
definitions no longer work.

This patch adds a new plugin hook,
    api_spec
which injects a full OpenAPI2.0 compatible schema into the full Koha schema,
avoiding to overwrite any existing definitions/parameters/info/paths/etc.
This way we maintain backwards compatibility with existing plugins, which are
not broken, and maintain updated plugins' ability to use complex schemas.
We need to inject full schema definitions, because of the way how the
new OpenAPI validator does dereferencing,
by creating /parameters and /definitions -objects inside the plugin's OpenAPI
schema object. The api_route()-plugin hook then proceeds to strip away only the
paths/routes and loses the internal data structure references to the schema
fragments/components.

If the api_spec is defined in the plugin, the api_routes-hook is never called.

TEST PLAN:

a) Run the modified test.
or
b) Install this plugin, and observe the routes are not loaded into the REST
API.
  
https://github.com/Hypernova-Oy/koha-plugin-self-service/releases/tag/v1.0.11
b1) Deploying this patch doesnt fix the plugin, as the whole subsystem to load
    OpenAPI2 spec has changed, and the plugins updated with workarounds.
    Plugins can be updated to support api_spec once it has been pushed.

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


More information about the Koha-bugs mailing list