Branch Coverage

blib/lib/JSON/Schema/Modern/Document/OpenAPI.pm
Criterion Covered Total %
branch 182 206 88.3


line true false branch
106 1 397 if exists $$args{"json_schema_dialect"}
109 1 397 if defined delete($$args{"specification_version"})
121 0 396 if keys %$config_override
143 1 395 unless exists $$schema{"openapi"}
145 2 393 unless ($$schema{"openapi"} // "") =~ /^\d+\.\d+\.\d+(-.+)?\z/a
152 1170 9 if $supported[0] == $oad_version[0]
155 4 389 unless defined $max_supported
158 30 359 if defined $oad_version[2] and (split(/\./u, $max_supported, 0))[2] < $oad_version[2]
164 8 381 if (exists $$schema{"\$self"})
167 1 7 if ($oad_version[0] == 3 and $oad_version[1] < 2)
175 2 5 unless assert_keyword_type($state, $schema, "string") and assert_uri_reference($state, $schema) and !($$schema{'$self'} =~ /#/u) || E($state, '$self cannot contain a fragment')
184 11 375 if (exists $$schema{"jsonSchemaDialect"})
186 2 9 unless assert_keyword_type($state, $schema, "string") and assert_uri_reference($state, $schema)
197 9 375 exists $$schema{'jsonSchemaDialect'} ? :
200 1 383 if ($json_schema_dialect eq {"3.1" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.1/strict-dialect.json","3.2" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.2/strict-dialect.json"}->{"3.1"} =~ s[/3.1/][/]ru)
205 1 383 if $self->_has_metaschema_uri and $self->metaschema_uri eq {"3.1" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.1/strict-schema.json","3.2" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.2/strict-schema.json"}->{"3.1"} =~ s[/3.1/][/]ru
210 5 379 if $self->_has_metaschema_uri and $self->metaschema_uri eq ({"3.1" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.1/strict-schema.json","3.2" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.2/strict-schema.json"}->{$self->oas_version} // "") or $json_schema_dialect eq ({"3.1" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.1/strict-dialect.json","3.2" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.2/strict-dialect.json"}->{$self->oas_version} // "")
212 24 360 if ($json_schema_dialect eq {3.0 => 'https://spec.openapis.org/oas/3.0/schema/2024-10-18#/definitions/Schema', 3.1 => 'https://spec.openapis.org/oas/3.1/dialect/2024-11-10', 3.2 => 'https://spec.openapis.org/oas/3.2/dialect/2025-09-17'}->{'3.0'} or $json_schema_dialect eq {3.0 => 'https://spec.openapis.org/oas/3.0/schema/2024-10-18#/definitions/Schema', 3.1 => 'https://spec.openapis.org/oas/3.1/dialect/2024-11-10', 3.2 => 'https://spec.openapis.org/oas/3.2/dialect/2025-09-17'}->{'3.0'} =~ s/\b\d{4}-\d{2}-\d{2}\b/latest/ru) { }
214 0 24 if $self->oas_version ne "3.0"
232 2 358 if (@{$$check_metaschema_state{"errors"}})
243 368 14 unless $self->_has_metaschema_uri
247 5 377 if $self->_has_metaschema_uri and $self->metaschema_uri eq ({"3.1" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.1/strict-schema.json","3.2" => "https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/3.2/strict-schema.json"}->{$self->oas_version} // "")
275 784 0 if $$schema{"\$dynamicRef"} eq "#meta"
281 155 11525 if ($self->oas_version eq '3.0') { }
283 155 0 if ($entity = lc join("-", split(/(?=[A-Z])/u, substr($$schema{"\$ref"}, 14), 0)))
284 33 122 if ($entity eq "schema")
286 2 31 if ($$data{"type"} // "") eq "array" and not exists $$data{"items"}
289 2 31 if exists $$data{"exclusiveMinimum"} and not exists $$data{"minimum"}
292 2 31 if exists $$data{"exclusiveMaximum"} and not exists $$data{"maximum"}
297 3 152 if $entity eq "path-item" and exists $$data{"\$ref"}
299 16 139 if ($entity eq "reference")
305 16 0 if ($schema_path =~ s[/oneOf/\K([01])\z][$1 ^ 1;]eu)
307 1 15 if $entity eq "callback"
312 1 154 if $entity eq "callback"
313 80 75 unless grep(($entity eq $_), __entities())
326 28 11497 if ($entity // "") eq "path-item" and exists $$data{"\$ref"}
328 109 11416 if ($$schema{"\$ref"} eq "#/\$defs/reference")
334 1953 9727 if $entity
336 439 11241 if ($$schema{"\$ref"} eq "#/\$defs/operation" or $$schema{"\$ref"} eq "#/definitions/Operation")
338 88 351 if defined $$data{"operationId"}
348 31 1922 if ($entity and $entity eq "path-item" and exists $$data{"\$ref"})
351 4 27 if keys %path_item
354 78 11602 if $$schema{"\$ref"} eq "#/\$defs/server"
362 13 369 unless ($result->valid)
364 1 0 if (($e->keyword // "") eq "not" and $e->absolute_keyword_location->fragment eq "/\$defs/parameters/not" and $e->absolute_keyword_location->clone->fragment(undef) eq {"3.0" => "https://spec.openapis.org/oas/3.0/schema/2024-10-18","3.1" => "https://spec.openapis.org/oas/3.1/schema/2025-11-23","3.2" => "https://spec.openapis.org/oas/3.2/schema/2025-11-23"}->{$self->oas_version})
381 21 348 if $result->defaults
385 6 82 if (my $existing = $self->operationId_path($operation_id)) { }
399 2 0 $our $_[0] eq 'maximum' ? :
2 2 $our $_[0] eq 'minimum' ? :
2 4 $our $_[0] eq 'items' ? :
407 0 205 unless $our $a[1] cmp $our $b[1]
416 0 407 if substr($path, 0, 1) ne "/"
417 3 404 if grep((!/^(?:\{[^{}]+\}|%[0-9A-Fa-f]{2}|[:\@!\$&'()*+,;=A-Za-z0-9._~-]+)+\z/u), split(m[/]u, substr($path, 1), 0))
425 2 176 if (++$seen_names{$name} == 2)
432 3 404 if (my $first_path = $seen_path{$normalized})
452 12 66 unless $$server{"url"} =~ /^(?:\{[^{}]+\}|%[0-9A-Fa-f]{2}|[\x21\x24\x26-\x3B\x3D\x40-\x5B\x5D\x5F\x61-\x7A\x7E\xA0-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}\x{E000}-\x{F8FF}\x{F0000}-\x{FFFFD}\x{100000}-\x{10FFFD}])+\z/u
459 6 60 if (my $first_url = ($seen_url{$servers_location} // {})->{$normalized})
466 33 33 unless ($variables_obj)
468 3 30 if @url_variables
477 3 46 if ++$seen_names{$name} == 2
481 3 46 if $seen_names{$name} == 1 and not exists $$variables_obj{$name}
488 6 43 if exists $$variables_obj{$varname}{"enum"} and not grep(($$variables_obj{$varname}{"default"} eq $_), @{$$variables_obj{$varname}{"enum"}})
499 3 9 if $tag_to_index{$$tag{"name"}} != $tag_idx
503 1 11 if exists $$tag{"parent"} and not exists $tag_to_index{$$tag{"parent"}}
508 1 11 unless defined $tag_to_index{$$tag{"parent"}}
514 3 8 if grep(($_ eq $$tag{"name"}), @seen)
518 6 363 if @{$$state{"errors"}}
532 0 780 if $idx != $#json_schema_paths and substr($json_schema_paths[$idx], 0, length($real_json_schema_paths[-1]) + 1) eq $real_json_schema_paths[-1] . '/'
539 363 0 if $$state{"references"}
542 4 359 if @{$$state{"errors"}}
554 0 6 builtin::blessed($class) ? :
555 0 6 $with_defaults ? :
562 0 7 if $self->errors
564 1 6 unless $to_version =~ /^(3\.\d+)(?:\.\d+)?\z/a
567 1 5 unless grep(($to_oas_version eq $_), Deparse error: Can't locate object method "ARRAY" via package "B::IV" at /usr/local/lib/perl5/5.42.0/B/Deparse.pm line 4577. )
570 3 2 if $to_version =~ /^(3\.\d+)\z/a
575 1 4 if $from_version eq $to_version
578 1 3 if $from_oas_version > $to_oas_version
582 1 2 if $from_oas_version eq $to_oas_version
584 1 1 if ($from_oas_version eq "3.0")
585 1 0 if not keys %{$$schema{"paths"}} and exists $$schema{"components"}
591 1 0 if ($media_type eq "application/octet-stream")
594 1 0 if ($schema and keys %$schema == 2 and ($$schema{"type"} // "") eq "string" and ($$schema{"format"} // "") eq "binary")
605 2 4 if (exists $$subschema{"nullable"})
607 1 1 if delete $$subschema{"nullable"} and exists $$subschema{"type"}
611 1 5 if exists $$subschema{"enum"} and @{$$subschema{"enum"}} == 1
613 1 5 if delete $$subschema{"exclusiveMinimum"}
614 1 5 if delete $$subschema{"exclusiveMaximum"}
616 1 5 if exists $$subschema{"example"}
618 2 4 if (exists $$subschema{"format"})
619 1 1 if ($$subschema{'format'} eq 'binary') { }
1 0 elsif ($$subschema{'format'} eq 'base64') { }
631 1 1 if ($to_oas_version ge "3.2")
635 1 1 if exists $$subschema{"description"} and $$subschema{"description"} eq ""
650 163 617 if (get_type($schema) eq "boolean" or not keys %$schema)
663 617 0 if $$state{"references"}
666 22 7 unless ($$state{"identifiers"}{$new_uri})
674 2 5 unless (is_equal({"canonical_uri", $$new{"canonical_uri"} . '', map(($_, $$new{$_}), ("path", "specification_version", "vocabularies"))}, {"canonical_uri", $$existing{"canonical_uri"} . '', map(($_, $$existing{$_}), ("path", "specification_version", "vocabularies"))}))
684 2 3 if (my $existing_anchor = ($$existing{"anchors"} // {})->{$anchor})
705 0 0 if $evaluator->_get_resource($dialect_uri)
730 0 1 if (defined(my $dialect = delete $$data{"json_schema_dialect"}))
735 0 1 unless exists $$self{"oas_version"}
739 0 2 unless exists $$self{$attr}