line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenAPI::Generator::Util; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
65
|
use 5.006; |
|
3
|
|
|
|
|
10
|
|
4
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
95
|
|
5
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
95
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
17
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
197
|
|
8
|
3
|
|
|
3
|
|
29
|
use Exporter qw(import); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1297
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
11
|
|
|
|
|
|
|
merge_definitions |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub merge_definitions { |
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
1
|
12
|
my(@definitions) = @_; |
17
|
|
|
|
|
|
|
|
18
|
3
|
50
|
|
|
|
14
|
croak 'no definitions to merge' unless @definitions; |
19
|
|
|
|
|
|
|
|
20
|
3
|
100
|
|
|
|
13
|
if (scalar @definitions == 1) { |
21
|
1
|
|
|
|
|
8
|
return $definitions[0]; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
19
|
my %common_def = ( |
25
|
|
|
|
|
|
|
paths => {}, |
26
|
|
|
|
|
|
|
components => { |
27
|
|
|
|
|
|
|
schemas => {}, |
28
|
|
|
|
|
|
|
securitySchemes => {}, |
29
|
|
|
|
|
|
|
parameters => {} |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
9
|
for my $def (@definitions) { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# paths |
36
|
6
|
|
|
|
|
11
|
while (my($path, $path_schema) = each %{$def->{paths}}) { |
|
14
|
|
|
|
|
50
|
|
37
|
8
|
|
|
|
|
15
|
while (my($method, $method_schema) = each %{$path_schema}) { |
|
16
|
|
|
|
|
58
|
|
38
|
8
|
50
|
|
|
|
24
|
if (exists $common_def{paths}{$path}{$method}) { |
39
|
0
|
|
|
|
|
0
|
croak "$method $path duplicates"; |
40
|
|
|
|
|
|
|
} |
41
|
8
|
|
|
|
|
20
|
$common_def{paths}{$path}{$method} = $method_schema; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# comp param |
46
|
6
|
|
|
|
|
10
|
while (my($param, $param_schema) = each %{$def->{components}{parameters}}) { |
|
11
|
|
|
|
|
41
|
|
47
|
5
|
50
|
|
|
|
17
|
if (exists $common_def{components}{parameters}{$param}) { |
48
|
0
|
|
|
|
|
0
|
croak "param $param duplicates" |
49
|
|
|
|
|
|
|
} |
50
|
5
|
|
|
|
|
13
|
$common_def{components}{parameters}{$param} = $param_schema; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# comp schemas |
54
|
6
|
|
|
|
|
14
|
while (my($comp, $comp_schema) = each %{$def->{components}{schemas}}) { |
|
11
|
|
|
|
|
41
|
|
55
|
5
|
50
|
|
|
|
13
|
if (exists $common_def{components}{schemas}{$comp}) { |
56
|
0
|
|
|
|
|
0
|
croak "schema $comp duplicates" |
57
|
|
|
|
|
|
|
} |
58
|
5
|
|
|
|
|
13
|
$common_def{components}{schemas}{$comp} = $comp_schema; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# comp security |
62
|
6
|
|
|
|
|
10
|
while (my($security, $security_schema) = each %{$def->{components}{securitySchemes}}) { |
|
11
|
|
|
|
|
44
|
|
63
|
5
|
50
|
|
|
|
16
|
if (exists $common_def{components}{securitySchemes}{$security}) { |
64
|
0
|
|
|
|
|
0
|
croak "security $security duplicates" |
65
|
|
|
|
|
|
|
} |
66
|
5
|
|
|
|
|
11
|
$common_def{components}{securitySchemes}{$security} = $security_schema; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
27
|
return \%common_def; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |