line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenAPI::Generator::From::Definitions; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1203
|
use 5.012; |
|
2
|
|
|
|
|
10
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
5
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
67
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use Carp qw(croak); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
121
|
|
8
|
2
|
|
|
2
|
|
29
|
use File::Find; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
163
|
|
9
|
2
|
|
|
2
|
|
1683
|
use JSON::PP; |
|
2
|
|
|
|
|
34310
|
|
|
2
|
|
|
|
|
181
|
|
10
|
2
|
|
|
2
|
|
19
|
use YAML; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
113
|
|
11
|
2
|
|
|
2
|
|
698
|
use OpenAPI::Generator::Util qw(merge_definitions); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
969
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
1
|
5
|
bless {}, shift |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub generate { |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
1
|
3
|
my($self, $conf) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
3
|
my $src = $conf->{src}; |
23
|
1
|
|
|
|
|
4
|
$self->_check_src($src); |
24
|
1
|
|
|
|
|
3
|
my @files = $self->_src_as_files($src); |
25
|
|
|
|
|
|
|
|
26
|
1
|
50
|
|
|
|
7
|
if (!@files) { |
27
|
0
|
|
|
|
|
0
|
croak "no files found in $src"; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
2
|
my @defs = @{ $conf->{definitions} }; |
|
1
|
|
|
|
|
4
|
|
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
4
|
for my $file (@files) { |
33
|
3
|
50
|
|
|
|
11062
|
croak "$file is not readable" unless -r $file; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
28
|
local $/ = ''; |
36
|
3
|
50
|
|
|
|
185
|
open my $fh, '<', $file or croak "can't open file $file"; |
37
|
3
|
|
|
|
|
127
|
my $content = <$fh>; |
38
|
3
|
|
|
|
|
44
|
close $fh; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
3
|
100
|
|
|
|
23
|
if ($file =~ /\.json$/) { |
42
|
1
|
|
|
|
|
6
|
push @defs, JSON::PP::decode_json($content); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
2
|
|
|
|
|
16
|
push @defs, YAML::Load($content); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
6886
|
merge_definitions(@defs) |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _check_src { |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
33
|
1
|
|
50
|
croak "$_[1] is not file or directory" unless(-f $_[1] or -d $_[1]); |
55
|
1
|
50
|
|
|
|
19
|
croak "$_[1] is not readable" unless(-r $_[1]); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _src_as_files { |
59
|
|
|
|
|
|
|
|
60
|
1
|
50
|
|
1
|
|
15
|
return $_[1] if -f $_[1]; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
3
|
my @files; |
63
|
1
|
100
|
|
4
|
|
124
|
find sub { push @files, $File::Find::name if /\.(yml|yaml|json)$/ }, $_[1]; |
|
4
|
|
|
|
|
193
|
|
64
|
|
|
|
|
|
|
@files |
65
|
1
|
|
|
|
|
9
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1 |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |