Bugzilla – Attachment 47844 Details for
Bug 15126
REST API: Use newer version of Swagger2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Swagger Minifier
0002-Bug-13799-REST-API-Swagger2-minifier.patch (text/plain), 7.05 KB, created by
Olli-Antti Kivilahti
on 2016-02-10 12:54:46 UTC
(
hide
)
Description:
Swagger Minifier
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2016-02-10 12:54:46 UTC
Size:
7.05 KB
patch
obsolete
>From 11fcc927cc155643d34e34e9eeed87f92dacf574 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Wed, 10 Feb 2016 14:24:36 +0200 >Subject: [PATCH 2/4] Bug 13799 - REST API - Swagger2 minifier! > >--- > api/v1/minifySwagger.pl | 86 ------------------------------------- > api/v1/swagger/minifySwagger.pl | 94 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 94 insertions(+), 86 deletions(-) > delete mode 100755 api/v1/minifySwagger.pl > create mode 100644 api/v1/swagger/minifySwagger.pl > >diff --git a/api/v1/minifySwagger.pl b/api/v1/minifySwagger.pl >deleted file mode 100755 >index 2b6657a..0000000 >--- a/api/v1/minifySwagger.pl >+++ /dev/null >@@ -1,86 +0,0 @@ >-#!/usr/bin/perl >- >-# Copyright 2016 KohaSuomi >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it under the >-# terms of the GNU General Public License as published by the Free Software >-# Foundation; either version 3 of the License, or (at your option) any later >-# version. >-# >-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >-# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License along >-# with Koha; if not, write to the Free Software Foundation, Inc., >-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >- >-use Modern::Perl; >- >-use Getopt::Long qw(:config no_ignore_case); >- >-my $help = 0; >-my $verbose = 0; >-my $swaggerFile = "swagger.json"; >-my $swaggerMinifiedFile = "swagger.min.json"; >-my $validate = 0; >- >-GetOptions( >- 'h|help' => \$help, >- 'v|verbose:i' => \$verbose, >- 's|source:s' => \$swaggerFile, >- 'd|destination:s' => \$swaggerMinifiedFile, >- 'V|validate' => \$validate, >-); >- >-my $usage = <<USAGE; >- >-minifySwagger.pl >- >-Reads the swagger.json -file and all referenced JSON-Schema -files and merges >-them into one merged and minified version. This minified swagger-file is >-intended to be shared to our API consumers. >- >-By default you must run this script from the same directory as the 'swagger.json' >-and the minified specification is written to 'swagger.min.json'. >-This is a convenience to make the minification process as easy as possible. >- >- -h --help This happy helpful help! >- >- -v --verbose 0, default, no output. >- 1, turn on internal Swagger debugging flags >- 2, more verbose Swagger2 debugging >- >- -s --source Which Swagger2-specification file to minify? >- Defaults to "swagger.json" >- >- -d --destination Where to write the minified Swagger2-spec? >- Defaults to "swagger.min.json" >- >- -V --validate Instead of minimizing, prints errors to stdout. >- >-EXAMPLES: >- >- perl minifySwagger.pl -v 1 -s api/v1/swagger/swagger.json -d swag.json >- cd api/v1/swagger && perl minifySwagger.pl >- >-USAGE >- >-if ($help) { >- print $usage; >- exit 0; >-} >-if ($verbose > 0) { >- $ENV{SWAGGER2_DEBUG} = $verbose; >-} >- >- >-require Swagger2; #When you import the Swagger2-libraries, the environment variables are checked and cannot be altered anymore. So set verbosity first, then load libs. >-my $swagger = Swagger2->new($swaggerFile); >-$swagger = $swagger->expand; #Fetch all JSON-Schema references >- >-open(SWOUT, ">:encoding(UTF-8)", $swaggerMinifiedFile) or die "$0: Couldn't open the minified Swagger2 output file:\n $!"; >-print SWOUT $swagger->to_string() if not($validate); >-close(SWOUT); >diff --git a/api/v1/swagger/minifySwagger.pl b/api/v1/swagger/minifySwagger.pl >new file mode 100644 >index 0000000..0421b4f >--- /dev/null >+++ b/api/v1/swagger/minifySwagger.pl >@@ -0,0 +1,94 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 KohaSuomi >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Getopt::Long qw(:config no_ignore_case); >+ >+my $help = 0; >+my $verbose = 0; >+my $swaggerFile = "swagger.json"; >+my $swaggerMinifiedFile = "swagger.min.json"; >+my $validate = 0; >+ >+GetOptions( >+ 'h|help' => \$help, >+ 'v|verbose:i' => \$verbose, >+ 's|source:s' => \$swaggerFile, >+ 'd|destination:s' => \$swaggerMinifiedFile, >+ 'V|validate' => \$validate, >+); >+ >+my $usage = <<USAGE; >+ >+minifySwagger.pl >+ >+Reads the swagger.json -file and all referenced JSON-Schema -files and merges >+them into one merged and minified version. This minified swagger-file is >+intended to be shared to our API consumers. >+ >+By default you must run this script from the same directory as the 'swagger.json' >+and the minified specification is written to 'swagger.min.json'. >+This is a convenience to make the minification process as easy as possible. >+ >+!DO NOT! set the executable flag on, or this can be ran from the internetz. >+ >+ -h --help This happy helpful help! >+ >+ -v --verbose 0, default, no output. >+ 1, turn on internal Swagger debugging flags >+ 2, more verbose Swagger2 debugging >+ >+ -s --source Which Swagger2-specification file to minify? >+ Defaults to "swagger.json" >+ >+ -d --destination Where to write the minified Swagger2-spec? >+ Defaults to "swagger.min.json" >+ >+ -V --validate Instead of minimizing, validates the schema and prints >+ errors to stdout. >+ >+EXAMPLES: >+ >+ perl minifySwagger.pl -v 1 -s api/v1/swagger/swagger.json -d swag.json >+ cd api/v1/swagger && perl minifySwagger.pl >+ >+USAGE >+ >+if ($help) { >+ print $usage; >+ exit 0; >+} >+if ($verbose > 0) { >+ $ENV{SWAGGER2_DEBUG} = $verbose; >+} >+ >+ >+require Swagger2; #When you import the Swagger2-libraries, the environment variables are checked and cannot be altered anymore. So set verbosity first, then load libs. >+my $swagger = Swagger2->new($swaggerFile); >+$swagger = $swagger->expand; #Fetch all JSON-Schema references >+ >+if ($validate) { >+ my @errors = $swagger->validate; >+ print join("\n", "Swagger2: Invalid spec:", @errors)."\n" if @errors; >+} >+ >+open(SWOUT, ">:encoding(UTF-8)", $swaggerMinifiedFile) or die "$0: Couldn't open the minified Swagger2 output file:\n $!"; >+print SWOUT $swagger->to_string() if not($validate); >+close(SWOUT); >-- >1.9.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15126
:
44372
|
44373
|
44374
|
44386
|
47785
|
47828
|
47829
|
47843
|
47844
|
48226
|
49781
|
49782
|
49783
|
49845
|
49846
|
49847
|
50142
|
50916
|
50917
|
50918
|
50919