Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document/OpenAPI.pm |
Statements | Executed 684792 statements in 6.75s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
466819 | 1 | 1 | 4.35s | 4.35s | CORE:regcomp (opcode) | JSON::Schema::Modern::Document::OpenAPI::
39055 | 1 | 1 | 122ms | 122ms | __ANON__[:144] | JSON::Schema::Modern::Document::OpenAPI::
466826 | 3 | 1 | 90.7ms | 90.7ms | CORE:match (opcode) | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 51.5ms | 108s | traverse | JSON::Schema::Modern::Document::OpenAPI::
965 | 1 | 1 | 34.0ms | 1.41s | _traverse_schema | JSON::Schema::Modern::Document::OpenAPI::
2586 | 1 | 1 | 11.0ms | 11.0ms | __ANON__[:140] | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 578µs | 578µs | CORE:sort (opcode) | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 364µs | 223ms | _add_vocab_and_default_schemas | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 52µs | 102µs | BEGIN@14 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 47µs | 225µs | BEGIN@19 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 29µs | 32µs | BEGIN@1.241 | OpenAPI::Modern::
1 | 1 | 1 | 28µs | 73µs | BEGIN@22 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 22µs | 52µs | BEGIN@15 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 20µs | 656µs | BEGIN@25 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 18µs | 44µs | BEGIN@17 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 17µs | 632µs | BEGIN@12 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 17µs | 40µs | BEGIN@16 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 16µs | 125µs | BEGIN@18 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 11µs | 90µs | BEGIN@21 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 11µs | 111µs | BEGIN@24 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 10µs | 38µs | BEGIN@20 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 9µs | 397µs | BEGIN@26 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 9µs | 51µs | BEGIN@31 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 9µs | 70µs | __ANON__[:56] | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 8µs | BEGIN@10 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 202µs | BEGIN@11 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 249µs | BEGIN@27 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 41µs | BEGIN@2.242 | OpenAPI::Modern::
1 | 1 | 1 | 7µs | 88µs | BEGIN@13 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 7µs | 26µs | BEGIN@33 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 6µs | 24µs | BEGIN@23 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 4µs | 20µs | BEGIN@43 | JSON::Schema::Modern::Document::OpenAPI::
0 | 0 | 0 | 0s | 0s | __ANON__[:158] | JSON::Schema::Modern::Document::OpenAPI::
0 | 0 | 0 | 0s | 0s | __ANON__[:190] | JSON::Schema::Modern::Document::OpenAPI::
0 | 0 | 0 | 0s | 0s | __ANON__[:196] | JSON::Schema::Modern::Document::OpenAPI::
0 | 0 | 0 | 0s | 0s | __ANON__[:197] | JSON::Schema::Modern::Document::OpenAPI::
0 | 0 | 0 | 0s | 0s | __ANON__[:198] | JSON::Schema::Modern::Document::OpenAPI::
0 | 0 | 0 | 0s | 0s | __ANON__[:199] | JSON::Schema::Modern::Document::OpenAPI::
0 | 0 | 0 | 0s | 0s | __ANON__[:69] | JSON::Schema::Modern::Document::OpenAPI::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 28µs | 2 | 35µs | # spent 32µs (29+3) within OpenAPI::Modern::BEGIN@1.241 which was called:
# once (29µs+3µs) by OpenAPI::Modern::BEGIN@28 at line 1 # spent 32µs making 1 call to OpenAPI::Modern::BEGIN@1.241
# spent 3µs making 1 call to strict::import |
2 | 2 | 41µs | 2 | 74µs | # spent 41µs (8+33) within OpenAPI::Modern::BEGIN@2.242 which was called:
# once (8µs+33µs) by OpenAPI::Modern::BEGIN@28 at line 2 # spent 41µs making 1 call to OpenAPI::Modern::BEGIN@2.242
# spent 33µs making 1 call to warnings::import |
3 | package JSON::Schema::Modern::Document::OpenAPI; | ||||
4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||
5 | # ABSTRACT: One OpenAPI v3.1 document | ||||
6 | # KEYWORDS: JSON Schema data validation request response OpenAPI | ||||
7 | |||||
8 | 1 | 0s | our $VERSION = '0.034'; | ||
9 | |||||
10 | 2 | 29µs | 1 | 8µs | # spent 8µs within JSON::Schema::Modern::Document::OpenAPI::BEGIN@10 which was called:
# once (8µs+0s) by OpenAPI::Modern::BEGIN@28 at line 10 # spent 8µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@10 |
11 | 2 | 23µs | 2 | 396µs | # spent 202µs (8+194) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@11 which was called:
# once (8µs+194µs) by OpenAPI::Modern::BEGIN@28 at line 11 # spent 202µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@11
# spent 194µs making 1 call to Moo::import |
12 | 3 | 38µs | 3 | 1.25ms | # spent 632µs (17+615) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@12 which was called:
# once (17µs+615µs) by OpenAPI::Modern::BEGIN@28 at line 12 # spent 632µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@12
# spent 599µs making 1 call to strictures::import
# spent 15µs making 1 call to strictures::VERSION |
13 | 2 | 43µs | 2 | 169µs | # spent 88µs (7+81) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@13 which was called:
# once (7µs+81µs) by OpenAPI::Modern::BEGIN@28 at line 13 # spent 88µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@13
# spent 81µs making 1 call to experimental::import |
14 | 2 | 73µs | 2 | 105µs | # spent 102µs (52+50) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@14 which was called:
# once (52µs+50µs) by OpenAPI::Modern::BEGIN@28 at line 14 # spent 102µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@14
# spent 3µs making 1 call to if::import |
15 | 2 | 44µs | 2 | 54µs | # spent 52µs (22+30) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@15 which was called:
# once (22µs+30µs) by OpenAPI::Modern::BEGIN@28 at line 15 # spent 52µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@15
# spent 2µs making 1 call to if::unimport |
16 | 2 | 68µs | 2 | 41µs | # spent 40µs (17+23) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@16 which was called:
# once (17µs+23µs) by OpenAPI::Modern::BEGIN@28 at line 16 # spent 40µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@16
# spent 1µs making 1 call to if::unimport |
17 | 2 | 43µs | 2 | 47µs | # spent 44µs (18+26) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@17 which was called:
# once (18µs+26µs) by OpenAPI::Modern::BEGIN@28 at line 17 # spent 44µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@17
# spent 3µs making 1 call to if::unimport |
18 | 3 | 61µs | 3 | 234µs | # spent 125µs (16+109) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@18 which was called:
# once (16µs+109µs) by OpenAPI::Modern::BEGIN@28 at line 18 # spent 125µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@18
# spent 97µs making 1 call to Exporter::import
# spent 12µs making 1 call to UNIVERSAL::VERSION |
19 | 2 | 44µs | 2 | 403µs | # spent 225µs (47+178) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@19 which was called:
# once (47µs+178µs) by OpenAPI::Modern::BEGIN@28 at line 19 # spent 225µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@19
# spent 178µs making 1 call to Exporter::import |
20 | 2 | 41µs | 2 | 66µs | # spent 38µs (10+28) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@20 which was called:
# once (10µs+28µs) by OpenAPI::Modern::BEGIN@28 at line 20 # spent 38µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@20
# spent 28µs making 1 call to Exporter::import |
21 | 2 | 122µs | 2 | 169µs | # spent 90µs (11+79) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@21 which was called:
# once (11µs+79µs) by OpenAPI::Modern::BEGIN@28 at line 21 # spent 90µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@21
# spent 79µs making 1 call to Exporter::import |
22 | 2 | 50µs | 2 | 88µs | # spent 73µs (28+45) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@22 which was called:
# once (28µs+45µs) by OpenAPI::Modern::BEGIN@28 at line 22 # spent 73µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@22
# spent 15µs making 1 call to List::Util::import |
23 | 2 | 25µs | 2 | 42µs | # spent 24µs (6+18) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@23 which was called:
# once (6µs+18µs) by OpenAPI::Modern::BEGIN@28 at line 23 # spent 24µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@23
# spent 18µs making 1 call to Exporter::import |
24 | 2 | 41µs | 2 | 211µs | # spent 111µs (11+100) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@24 which was called:
# once (11µs+100µs) by OpenAPI::Modern::BEGIN@28 at line 24 # spent 111µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@24
# spent 100µs making 1 call to MooX::HandlesVia::import |
25 | 3 | 50µs | 3 | 1.29ms | # spent 656µs (20+636) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@25 which was called:
# once (20µs+636µs) by OpenAPI::Modern::BEGIN@28 at line 25 # spent 656µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@25
# spent 625µs making 1 call to MooX::TypeTiny::import
# spent 11µs making 1 call to UNIVERSAL::VERSION |
26 | 2 | 31µs | 2 | 785µs | # spent 397µs (9+388) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@26 which was called:
# once (9µs+388µs) by OpenAPI::Modern::BEGIN@28 at line 26 # spent 397µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@26
# spent 388µs making 1 call to Exporter::Tiny::import |
27 | 2 | 44µs | 2 | 490µs | # spent 249µs (8+241) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@27 which was called:
# once (8µs+241µs) by OpenAPI::Modern::BEGIN@28 at line 27 # spent 249µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@27
# spent 241µs making 1 call to namespace::clean::import |
28 | |||||
29 | 1 | 1µs | 1 | 807µs | extends 'JSON::Schema::Modern::Document'; # spent 807µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::extends |
30 | |||||
31 | 2 | 48µs | 2 | 93µs | # spent 51µs (9+42) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@31 which was called:
# once (9µs+42µs) by OpenAPI::Modern::BEGIN@28 at line 31 # spent 51µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@31
# spent 42µs making 1 call to constant::import |
32 | |||||
33 | 1 | 0s | # spent 26µs (7+19) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@33 which was called:
# once (7µs+19µs) by OpenAPI::Modern::BEGIN@28 at line 41 | ||
34 | # local filename => identifier to add the schema as | ||||
35 | 'oas/dialect/base.schema.json' => 'https://spec.openapis.org/oas/3.1/dialect/base', # metaschema for json schemas contained within openapi documents | ||||
36 | 'oas/meta/base.schema.json' => 'https://spec.openapis.org/oas/3.1/meta/base', # vocabulary definition | ||||
37 | 'oas/schema-base.json' => 'https://spec.openapis.org/oas/3.1/schema-base', # the main openapi document schema + draft2020-12 jsonSchemaDialect | ||||
38 | 'oas/schema.json' => 'https://spec.openapis.org/oas/3.1/schema', # the main openapi document schema + permissive jsonSchemaDialect | ||||
39 | 'strict-schema.json' => 'https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/strict-schema.json', | ||||
40 | 'strict-dialect.json' => 'https://raw.githubusercontent.com/karenetheridge/OpenAPI-Modern/master/share/strict-dialect.json', | ||||
41 | 1 | 80µs | 2 | 45µs | }; # spent 26µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@33
# spent 19µs making 1 call to constant::import |
42 | |||||
43 | 2 | 1.07ms | 2 | 36µs | # spent 20µs (4+16) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@43 which was called:
# once (4µs+16µs) by OpenAPI::Modern::BEGIN@28 at line 43 # spent 20µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@43
# spent 16µs making 1 call to constant::import |
44 | |||||
45 | 1 | 2µs | 1 | 1.48ms | has '+evaluator' => ( # spent 1.48ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has |
46 | required => 1, | ||||
47 | ); | ||||
48 | |||||
49 | 1 | 3µs | 1 | 2.27ms | has '+metaschema_uri' => ( # spent 2.27ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has |
50 | default => DEFAULT_METASCHEMA, | ||||
51 | ); | ||||
52 | |||||
53 | has json_schema_dialect => ( | ||||
54 | is => 'rwp', | ||||
55 | isa => InstanceOf['Mojo::URL'], | ||||
56 | 1 | 8µs | 2 | 61µs | # spent 70µs (9+61) within JSON::Schema::Modern::Document::OpenAPI::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document/OpenAPI.pm:56] which was called:
# once (9µs+61µs) by JSON::Schema::Modern::Document::OpenAPI::_set_json_schema_dialect at line 28 of (eval 390)[Sub/Quote.pm:3] # spent 52µs making 1 call to Mojo::URL::new
# spent 9µs making 1 call to Safe::Isa::__ANON__[Safe/Isa.pm:23] |
57 | 1 | 7µs | 2 | 1.14ms | ); # spent 1.07ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has
# spent 69µs making 1 call to Types::Standard::InstanceOf |
58 | |||||
59 | # operationId => document path | ||||
60 | has operationIds => ( | ||||
61 | is => 'bare', | ||||
62 | isa => HashRef[Str], | ||||
63 | handles_via => 'Hash', | ||||
64 | handles => { | ||||
65 | _add_operationId => 'set', | ||||
66 | get_operationId_path => 'get', | ||||
67 | }, | ||||
68 | lazy => 1, | ||||
69 | default => sub { {} }, | ||||
70 | 1 | 10µs | 3 | 2.17ms | ); # spent 1.86ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has
# spent 302µs making 1 call to Types::Standard::HashRef
# spent 2µs making 1 call to Types::Standard::Str |
71 | |||||
72 | 3 | 0s | # spent 108s (51.5ms+108) within JSON::Schema::Modern::Document::OpenAPI::traverse which was called:
# once (51.5ms+108s) by JSON::Schema::Modern::Document::BUILD at line 146 of JSON/Schema/Modern/Document.pm | ||
73 | 1 | 8µs | 1 | 223ms | $self->_add_vocab_and_default_schemas; # spent 223ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas |
74 | |||||
75 | 1 | 12µs | 1 | 3µs | my $schema = $self->schema; # spent 3µs making 1 call to JSON::Schema::Modern::Document::schema |
76 | 1 | 28µs | 2 | 4µs | my $state = { # spent 3µs making 1 call to JSON::Schema::Modern::Document::canonical_uri
# spent 1µs making 1 call to JSON::Schema::Modern::SPECIFICATION_VERSION_DEFAULT |
77 | initial_schema_uri => $self->canonical_uri, | ||||
78 | traversed_schema_path => '', | ||||
79 | schema_path => '', | ||||
80 | data_path => '', | ||||
81 | errors => [], | ||||
82 | evaluator => $evaluator, | ||||
83 | identifiers => [], | ||||
84 | configs => {}, | ||||
85 | spec_version => $evaluator->SPECIFICATION_VERSION_DEFAULT, | ||||
86 | vocabularies => [], | ||||
87 | }; | ||||
88 | |||||
89 | 1 | 3µs | 1 | 5µs | if ((my $type = get_type($schema)) ne 'object') { # spent 5µs making 1 call to JSON::Schema::Modern::Utilities::get_type |
90 | ()= E($state, 'invalid document type: %s', $type); | ||||
91 | return $state; | ||||
92 | } | ||||
93 | |||||
94 | # /openapi: https://spec.openapis.org/oas/v3.1.0#openapi-object | ||||
95 | 1 | 17µs | 2 | 48µs | return $state if not assert_keyword_exists({ %$state, keyword => 'openapi' }, $schema) # spent 43µs making 1 call to JSON::Schema::Modern::Utilities::assert_keyword_type
# spent 5µs making 1 call to JSON::Schema::Modern::Utilities::assert_keyword_exists |
96 | or not assert_keyword_type({ %$state, keyword => 'openapi' }, $schema, 'string'); | ||||
97 | |||||
98 | 1 | 11µs | 1 | 7µs | if ($schema->{openapi} !~ /^3\.1\.[0-9]+(-.+)?$/) { # spent 7µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::CORE:match |
99 | ()= E({ %$state, keyword => 'openapi' }, 'unrecognized openapi version %s', $schema->{openapi}); | ||||
100 | return $state; | ||||
101 | } | ||||
102 | |||||
103 | |||||
104 | # /jsonSchemaDialect: https://spec.openapis.org/oas/v3.1.0#specifying-schema-dialects | ||||
105 | { | ||||
106 | 1 | 1µs | return $state if exists $schema->{jsonSchemaDialect} | ||
107 | 1 | 1µs | and not assert_keyword_type({ %$state, keyword => 'jsonSchemaDialect' }, $schema, 'string'); | ||
108 | |||||
109 | 1 | 7µs | 1 | 4µs | my $json_schema_dialect = $self->json_schema_dialect // $schema->{jsonSchemaDialect}; # spent 4µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::json_schema_dialect |
110 | |||||
111 | # "If [jsonSchemaDialect] is not set, then the OAS dialect schema id MUST be used for these Schema Objects." | ||||
112 | 1 | 1µs | $json_schema_dialect //= DEFAULT_DIALECT; | ||
113 | |||||
114 | # traverse an empty schema with this metaschema uri to confirm it is valid | ||||
115 | 1 | 10µs | 4 | 4.13ms | my $check_metaschema_state = $evaluator->traverse({}, { # spent 4.08ms making 1 call to JSON::Schema::Modern::traverse
# spent 41µs making 1 call to Mojo::URL::clone
# spent 2µs making 1 call to Mojo::URL::fragment
# spent 1µs making 1 call to JSON::Schema::Modern::Document::canonical_uri |
116 | metaschema_uri => $json_schema_dialect, | ||||
117 | initial_schema_uri => $self->canonical_uri->clone->fragment('/jsonSchemaDialect'), | ||||
118 | }); | ||||
119 | |||||
120 | # we cannot continue if the metaschema is invalid | ||||
121 | 1 | 1µs | if ($check_metaschema_state->{errors}->@*) { | ||
122 | push $state->{errors}->@*, $check_metaschema_state->{errors}->@*; | ||||
123 | return $state; | ||||
124 | } | ||||
125 | |||||
126 | 1 | 2µs | $state->@{qw(spec_version vocabularies)} = $check_metaschema_state->@{qw(spec_version vocabularies)}; | ||
127 | 1 | 11µs | 1 | 96µs | $self->_set_json_schema_dialect($json_schema_dialect); # spent 96µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::_set_json_schema_dialect |
128 | } | ||||
129 | |||||
130 | # evaluate the document against its metaschema to find any errors, to identify all schema | ||||
131 | # resources within to add to the global resource index, and to extract all operationIds | ||||
132 | 1 | 1µs | my (@json_schema_paths, @operation_paths); | ||
133 | 2586 | 663µs | my $result = $self->evaluator->evaluate( | ||
134 | $self->schema, | ||||
135 | $self->metaschema_uri, | ||||
136 | { | ||||
137 | callbacks => { | ||||
138 | 5172 | 1.21ms | # spent 11.0ms within JSON::Schema::Modern::Document::OpenAPI::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document/OpenAPI.pm:140] which was called 2586 times, avg 4µs/call:
# 2586 times (11.0ms+0s) by JSON::Schema::Modern::_eval_subschema at line 584 of JSON/Schema/Modern.pm, avg 4µs/call | ||
139 | 2586 | 10.1ms | push @json_schema_paths, $state->{data_path} if $schema->{'$dynamicRef'} eq '#meta'; | ||
140 | }, | ||||
141 | 156220 | 29.5ms | # spent 122ms within JSON::Schema::Modern::Document::OpenAPI::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document/OpenAPI.pm:144] which was called 39055 times, avg 3µs/call:
# 39055 times (122ms+0s) by JSON::Schema::Modern::_eval_subschema at line 584 of JSON/Schema/Modern.pm, avg 3µs/call | ||
142 | push @operation_paths, [ $data->{operationId} => $state->{data_path} ] | ||||
143 | 39055 | 121ms | if $schema->{'$ref'} eq '#/$defs/operation' and defined $data->{operationId}; | ||
144 | }, | ||||
145 | }, | ||||
146 | }, | ||||
147 | 1 | 33µs | 4 | 99.9s | ); # spent 99.9s making 1 call to JSON::Schema::Modern::evaluate
# spent 3µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::metaschema_uri
# spent 2µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::evaluator
# spent 2µs making 1 call to JSON::Schema::Modern::Document::schema |
148 | |||||
149 | 1 | 9µs | 2 | 25µs | if (not $result) { # spent 22µs making 1 call to JSON::Schema::Modern::Result::__ANON__[JSON/Schema/Modern/Result.pm:29]
# spent 3µs making 1 call to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:7] |
150 | $_->mode('evaluate') foreach $result->errors; | ||||
151 | push $state->{errors}->@*, $result->errors; | ||||
152 | return $state; | ||||
153 | } | ||||
154 | |||||
155 | 1 | 0s | my @real_json_schema_paths; | ||
156 | 1 | 1.97ms | 1 | 578µs | foreach my $path (sort @json_schema_paths) { # spent 578µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::CORE:sort |
157 | # disregard paths that are not the root of each embedded subschema. | ||||
158 | 469405 | 6.52s | 936224 | 10.9s | next if any { $path =~ m{^\Q$_\E(?:/|\z)} } @real_json_schema_paths; # spent 6.50s making 2586 calls to List::Util::any, avg 2.51ms/call
# spent 4.35s making 466819 calls to JSON::Schema::Modern::Document::OpenAPI::CORE:regcomp, avg 9µs/call
# spent 90.7ms making 466819 calls to JSON::Schema::Modern::Document::OpenAPI::CORE:match, avg 194ns/call |
159 | |||||
160 | 965 | 2.36ms | unshift @real_json_schema_paths, $path; | ||
161 | 965 | 18.4ms | 1930 | 1.48s | $self->_traverse_schema($self->get($path), { %$state, schema_path => $path }); # spent 1.41s making 965 calls to JSON::Schema::Modern::Document::OpenAPI::_traverse_schema, avg 1.46ms/call
# spent 75.3ms making 965 calls to Mojo::JSON::Pointer::get, avg 78µs/call |
162 | } | ||||
163 | |||||
164 | 1 | 159µs | foreach my $pair (@operation_paths) { | ||
165 | my ($operation_id, $path) = @$pair; | ||||
166 | if (my $existing = $self->get_operationId_path($operation_id)) { | ||||
167 | ()= E({ %$state, keyword => 'operationId', schema_path => $path }, | ||||
168 | 'duplicate of operationId at %s', $existing); | ||||
169 | } | ||||
170 | else { | ||||
171 | $self->_add_operationId($operation_id => $path); | ||||
172 | } | ||||
173 | } | ||||
174 | |||||
175 | 1 | 11.3ms | return $state; | ||
176 | } | ||||
177 | |||||
178 | ######## NO PUBLIC INTERFACES FOLLOW THIS POINT ######## | ||||
179 | |||||
180 | 2 | 1µs | # spent 223ms (364µs+222) within JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas which was called:
# once (364µs+222ms) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 73 | ||
181 | 1 | 1µs | 1 | 0s | my $js = $self->evaluator; # spent 0s making 1 call to JSON::Schema::Modern::Document::OpenAPI::evaluator |
182 | 1 | 7µs | 1 | 66.5ms | $js->add_vocabulary('JSON::Schema::Modern::Vocabulary::OpenAPI'); # spent 66.5ms making 1 call to JSON::Schema::Modern::add_vocabulary |
183 | |||||
184 | $js->add_format_validation( | ||||
185 | int32 => +{ type => 'integer', sub => sub ($x) { | ||||
186 | require Math::BigInt; | ||||
187 | $x = Math::BigInt->new($x); | ||||
188 | my $bound = Math::BigInt->new(2) ** 31; | ||||
189 | $x >= -$bound && $x < $bound; | ||||
190 | } }, | ||||
191 | int64 => +{ type => 'integer', sub => sub ($x) { | ||||
192 | require Math::BigInt; | ||||
193 | $x = Math::BigInt->new($x); | ||||
194 | my $bound = Math::BigInt->new(2) ** 63; | ||||
195 | $x >= -$bound && $x < $bound; | ||||
196 | } }, | ||||
197 | float => +{ type => 'number', sub => sub ($) { 1 } }, | ||||
198 | double => +{ type => 'number', sub => sub ($) { 1 } }, | ||||
199 | password => +{ type => 'string', sub => sub ($) { 1 } }, | ||||
200 | 1 | 16µs | 1 | 790µs | ); # spent 790µs making 1 call to JSON::Schema::Modern::add_format_validation |
201 | |||||
202 | 1 | 41µs | 1 | 4µs | foreach my $pairs (pairs DEFAULT_SCHEMAS->%*) { # spent 4µs making 1 call to List::Util::pairs |
203 | 6 | 4µs | my ($filename, $uri) = @$pairs; | ||
204 | 6 | 726µs | 36 | 149ms | my $document = $js->add_schema($uri, # spent 148ms making 6 calls to JSON::Schema::Modern::add_schema, avg 24.6ms/call
# spent 952µs making 6 calls to File::ShareDir::dist_dir, avg 159µs/call
# spent 535µs making 6 calls to Cpanel::JSON::XS::decode, avg 89µs/call
# spent 97µs making 6 calls to JSON::Schema::Modern::_json_decoder, avg 16µs/call
# spent 59µs making 6 calls to Path::Tiny::path, avg 10µs/call
# spent 26µs making 6 calls to Path::Tiny::slurp_raw, avg 4µs/call |
205 | $js->_json_decoder->decode(path(dist_dir('OpenAPI-Modern'), $filename)->slurp_raw)); | ||||
206 | 6 | 43µs | 8 | 1.68ms | $js->add_schema($uri.'/latest', $document) if $uri =~ /schema(-base)?$/; # spent 1.67ms making 2 calls to JSON::Schema::Modern::add_schema, avg 832µs/call
# spent 17µs making 6 calls to JSON::Schema::Modern::Document::OpenAPI::CORE:match, avg 3µs/call |
207 | } | ||||
208 | } | ||||
209 | |||||
210 | # https://spec.openapis.org/oas/v3.1.0#schema-object | ||||
211 | 3860 | 1.31ms | # spent 1.41s (34.0ms+1.37) within JSON::Schema::Modern::Document::OpenAPI::_traverse_schema which was called 965 times, avg 1.46ms/call:
# 965 times (34.0ms+1.37s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 161, avg 1.46ms/call | ||
212 | 965 | 2.00ms | return if not is_plain_hashref($schema) or not keys %$schema; | ||
213 | |||||
214 | my $subschema_state = $self->evaluator->traverse($schema, { | ||||
215 | %$state, # so we don't have to enumerate everything that may be in config_override | ||||
216 | initial_schema_uri => canonical_uri($state), | ||||
217 | traversed_schema_path => $state->{traversed_schema_path}.$state->{schema_path}, | ||||
218 | 727 | 20.5ms | 2908 | 1.37s | metaschema_uri => $self->json_schema_dialect, # spent 1.32s making 727 calls to JSON::Schema::Modern::traverse, avg 1.81ms/call
# spent 50.2ms making 727 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 69µs/call
# spent 2.18ms making 727 calls to JSON::Schema::Modern::Document::OpenAPI::evaluator, avg 3µs/call
# spent 1.91ms making 727 calls to JSON::Schema::Modern::Document::OpenAPI::json_schema_dialect, avg 3µs/call |
219 | }); | ||||
220 | |||||
221 | 727 | 1.09ms | push $state->{errors}->@*, $subschema_state->{errors}->@*; | ||
222 | 727 | 315µs | return if $subschema_state->{errors}->@*; | ||
223 | |||||
224 | 727 | 7.32ms | push $state->{identifiers}->@*, $subschema_state->{identifiers}->@*; | ||
225 | } | ||||
226 | |||||
227 | 1 | 18µs | 1; | ||
228 | |||||
229 | 1 | 39µs | 1 | 410µs | __END__ # spent 410µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 90.7ms within JSON::Schema::Modern::Document::OpenAPI::CORE:match which was called 466826 times, avg 194ns/call:
# 466819 times (90.7ms+0s) by List::Util::any at line 158, avg 194ns/call
# 6 times (17µs+0s) by JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas at line 206, avg 3µs/call
# once (7µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 98 | |||||
# spent 4.35s within JSON::Schema::Modern::Document::OpenAPI::CORE:regcomp which was called 466819 times, avg 9µs/call:
# 466819 times (4.35s+0s) by List::Util::any at line 158, avg 9µs/call | |||||
# spent 578µs within JSON::Schema::Modern::Document::OpenAPI::CORE:sort which was called:
# once (578µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 156 |