Bug 17102

Summary: Automatically minify swagger.json
Product: Koha Reporter: Lari Taskula <lari.taskula>
Component: Web servicesAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: benjamin.rokseth, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17432
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 16212    
Bug Blocks:    
Attachments: Bug 17102: Automatically minify swagger.json

Description Lari Taskula 2016-08-10 12:33:03 UTC
Since Bug 16212 introduces a minification script, it could be useful for developers to have their specification automatically minified without the need to run minifier for each modification.
Comment 1 Lari Taskula 2016-08-10 12:36:39 UTC
Created attachment 54269 [details] [review]
Bug 17102: Automatically minify swagger.json

This patch adds automatic minification of swagger.json. Since startup subroutine
is executed on each call to REST API, we need to be careful to not do useless
computation by minificating swagger.json when not required. Therefore, we need
some algorithm to determine whether minification is needed. In this patch,
minification is executed in two cases:
1. swagger.min.json does not exist
2. any of the specification files is modified more recently than
   swagger.min.json

Includes tests.

This feature requires Apache user to have write permissions to swagger.min.json,
otherwise we cannot minify the specification automatically. Another solution is
to run the minifySwagger.pl manually after each modification or create a daemon
that listens to file modifications via "inotify" and executes minification when
needed.
Comment 2 Lari Taskula 2016-08-10 12:37:20 UTC
Perhaps some parametrization is needed, it is probably not a good idea to run this in production.
Comment 3 Tomás Cohen Arazi (tcohen) 2016-08-23 18:58:59 UTC
I think this workflow wouldn't fit into Koha's QA process. And as you said, it shouldn't be encouraged in production.

BUT

maybe we could make kohadevbox have this as a feature for developers.
Comment 4 Benjamin Rokseth 2016-09-05 09:13:47 UTC
Just started a discussion on Bug 17243 on minifying swagger.
Basically I propose adding it to the plack build sub of the api.

Any thoughts on this?
Comment 5 Tomás Cohen Arazi (tcohen) 2016-09-05 14:15:47 UTC
I don't think we should automatically regenerate it. The deployed file should be production ready and no source of issues for end-users.

It looks to me that we just need to provide ways for devs to set that if needed. Be it under kohadevbox or on regular dev setups.
Comment 6 Benjamin Rokseth 2016-09-08 11:35:41 UTC
I certainly agree. As long as we keep the minified swagger out of source control, I'm happy.
Comment 7 Katrin Fischer 2016-10-16 11:33:18 UTC

*** This bug has been marked as a duplicate of bug 17432 ***