Bug 36546: Add a bundled version of the API spec

This patch makes the Koha::REST::V1 class use a bundled version of the
API spec.

For that to happen, this patch also adds:

* a `yarn api:bundle` task for generating the `swagger_bundle.yaml`
  file
* the bundle file to `.gitignore`
* @redocly/cli to the packages.json dependencies (yarn add @redocly/cli)
* `api:bundle` is added to the `yarn build` general command

NOTE: A new workflow is introduced by this patch as developers will need
to call the `yarn api:bundle` command on each API spec change they make.

To test:
1. Have KTD running
2. Verify the API works as usual
=> SUCCESS: The API just works
3. Apply this patch
4. Run:
   $ ktd --shell
  k$ yarn api:bundle
5. Restart plack:
  k$ koha-plack --restart kohadev ; tail -f /var/log/koha/kohadev/*.log
=> SUCCESS: The API loads correctly
6. Repeat 2
=> SUCCESS: Nothing changed
7. Sign off :-D

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Tomas Cohen Arazi 2024-04-23 11:52:37 -03:00 committed by Katrin Fischer
parent b45c0e8999
commit 3939830cdc
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
4 changed files with 665 additions and 13 deletions

2
.gitignore vendored
View File

@ -4,6 +4,8 @@
/pm_to_blib
node_modules/
api/v1/swagger/swagger_bundle.yaml
koha-tmpl/opac-tmpl/bootstrap/css/maps/
koha-tmpl/opac-tmpl/bootstrap/css/opac.css
koha-tmpl/opac-tmpl/bootstrap/css/opac-rtl.css

View File

@ -75,7 +75,7 @@ sub startup {
$self->secrets([$secret_passphrase]);
}
my $spec_file = $self->home->rel_file("api/v1/swagger/swagger.yaml");
my $spec_file = $self->home->rel_file("api/v1/swagger/swagger_bundle.yaml");
push @{$self->routes->namespaces}, 'Koha::Plugin';

View File

@ -13,6 +13,7 @@
"@fortawesome/free-solid-svg-icons": "^6.0.0",
"@fortawesome/vue-fontawesome": "^3.0.0-5",
"@popperjs/core": "^2.11.2",
"@redocly/cli": "^1.11.0",
"@vue/cli-service": "^5.0.1",
"babel-core": "^7.0.0-beta.3",
"bootstrap": "^4.5.2",
@ -49,10 +50,11 @@
"js:build": "webpack --mode development",
"js:watch": "webpack --mode development --watch",
"js:build:prod": "webpack --mode production",
"build": "yarn css:build && yarn js:build",
"build": "yarn css:build && yarn js:build && yarn api:bundle",
"build:prod": "yarn css:build:prod && yarn js:build:prod",
"cypress": "cypress",
"prettier": "prettier"
"prettier": "prettier",
"api:bundle": "redocly bundle api/v1/swagger/swagger.yaml > api/v1/swagger/swagger_bundle.yaml"
},
"repository": {
"type": "git",

668
yarn.lock

File diff suppressed because it is too large Load Diff