Bug 35613 - Migrate spec to OpenAPI v3
Summary: Migrate spec to OpenAPI v3
Status: ASSIGNED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-20 12:55 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2025-04-03 14:52 UTC (History)
6 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2023-12-20 12:55:49 UTC
Things to do:
- Convert our spec into OpenAPIv3 (probably using redocly)
- Migrate array types ("type" and "null") into using the "nullable": true provided attribute
- Verify no regressions found
- Report potential issues to https://github.com/jhthorsen/mojolicious-plugin-openapi
- Split the bundled spec into pieces as we have now.
- The generated api.koha-community.org documentation needs to be at least the same in terms of information and usability.
Comment 1 Martin Renvoize (ashimema) 2023-12-20 13:20:29 UTC
Awesome!
Comment 2 David Cook 2025-01-21 22:14:57 UTC
How would this affect Koha plugins that add plugin routes? 

Will we just need to make an announcement that all plugins will need to be updated from Koha version xx.yy?
Comment 3 Tomás Cohen Arazi (tcohen) 2025-03-20 13:56:19 UTC
(In reply to David Cook from comment #2)
> How would this affect Koha plugins that add plugin routes? 

A new plugin hook will be added for v3, and plugins not implementing it won't expose an API. A warning should be added in the plugin page.

> Will we just need to make an announcement that all plugins will need to be
> updated from Koha version xx.yy?

Exactly. Instructions will be provided for plugin authors to leverage on things like ChatGPT for the migration.
Comment 4 Tomás Cohen Arazi (tcohen) 2025-04-03 14:52:23 UTC
An update on the status of this report.

What we have is this process for migrating:

* Bundle the API spec (`yarn api:bundle` inside KTD should be enough)
* Have VScode with the `openapi-lint` extension installed
* Open the bundled spec in VSCode
* Use Ctrl+shift+p/Cmd+shift+p to open the keyboard shortcuts menu
* Choose OpenAPI 2.0 to 3.0.0 (YAML/Resolved) and get the spec converted

This yields a new file.

Then, inside KTD, you can run `redocly split` to get the API spec split the way it is in Koha right now, just v3.

I'll provide a patch next week with the required changes to V1.pm.

A good thing is that the `nullable: true` attribute and getting rid of the dual values we had in OpenAPI v2 is solved with this sequence. So that step is no longer required.

It would be worth spending some time checking the options `redocy` provides for doing the sequence in the CLI.