Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document/OpenAPI.pm |
Statements | Executed 684792 statements in 5.47s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
466819 | 1 | 1 | 3.50s | 3.50s | CORE:regcomp (opcode) | JSON::Schema::Modern::Document::OpenAPI::
39055 | 1 | 1 | 121ms | 121ms | __ANON__[:144] | JSON::Schema::Modern::Document::OpenAPI::
466826 | 3 | 1 | 69.5ms | 69.5ms | CORE:match (opcode) | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 41.8ms | 94.3s | traverse | JSON::Schema::Modern::Document::OpenAPI::
965 | 1 | 1 | 25.3ms | 1.18s | _traverse_schema | JSON::Schema::Modern::Document::OpenAPI::
2586 | 1 | 1 | 11.2ms | 11.2ms | __ANON__[:140] | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 896µs | 896µs | CORE:sort (opcode) | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 261µs | 195ms | _add_vocab_and_default_schemas | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 28µs | 139µs | BEGIN@19 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 25µs | 969µs | BEGIN@12 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 25µs | 27µs | BEGIN@1.242 | OpenAPI::Modern::
1 | 1 | 1 | 24µs | 54µs | BEGIN@14 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 21µs | 38µs | BEGIN@15 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 17µs | 819µs | BEGIN@26 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 16µs | 81µs | BEGIN@18 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 14µs | 515µs | BEGIN@25 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 12µs | 28µs | BEGIN@16 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 11µs | 355µs | BEGIN@27 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 11µs | 57µs | BEGIN@31 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 11µs | 35µs | BEGIN@33 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 10µs | 10µs | BEGIN@10 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 10µs | 25µs | BEGIN@17 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 10µs | 34µs | BEGIN@22 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 119µs | BEGIN@13 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 35µs | BEGIN@2.243 | OpenAPI::Modern::
1 | 1 | 1 | 7µs | 265µs | BEGIN@11 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 7µs | 82µs | BEGIN@24 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 6µs | 24µs | BEGIN@20 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 6µs | 26µs | BEGIN@43 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 5µs | 20µs | BEGIN@21 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 5µs | 43µs | __ANON__[:56] | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 4µs | 18µs | BEGIN@23 | 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 | 29µs | 2 | 29µs | # spent 27µs (25+2) within OpenAPI::Modern::BEGIN@1.242 which was called:
# once (25µs+2µs) by OpenAPI::Modern::BEGIN@28 at line 1 # spent 27µs making 1 call to OpenAPI::Modern::BEGIN@1.242
# spent 2µs making 1 call to strict::import |
2 | 2 | 48µs | 2 | 62µs | # spent 35µs (8+27) within OpenAPI::Modern::BEGIN@2.243 which was called:
# once (8µs+27µs) by OpenAPI::Modern::BEGIN@28 at line 2 # spent 35µs making 1 call to OpenAPI::Modern::BEGIN@2.243
# spent 27µ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 | 1µs | our $VERSION = '0.037'; | ||
9 | |||||
10 | 2 | 33µs | 1 | 10µs | # spent 10µs within JSON::Schema::Modern::Document::OpenAPI::BEGIN@10 which was called:
# once (10µs+0s) by OpenAPI::Modern::BEGIN@28 at line 10 # spent 10µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@10 |
11 | 2 | 33µs | 2 | 523µs | # spent 265µs (7+258) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@11 which was called:
# once (7µs+258µs) by OpenAPI::Modern::BEGIN@28 at line 11 # spent 265µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@11
# spent 258µs making 1 call to Moo::import |
12 | 3 | 48µs | 3 | 1.91ms | # spent 969µs (25+944) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@12 which was called:
# once (25µs+944µs) by OpenAPI::Modern::BEGIN@28 at line 12 # spent 969µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@12
# spent 925µs making 1 call to strictures::import
# spent 19µs making 1 call to strictures::VERSION |
13 | 2 | 47µs | 2 | 230µs | # spent 119µs (8+111) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@13 which was called:
# once (8µs+111µs) by OpenAPI::Modern::BEGIN@28 at line 13 # spent 119µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@13
# spent 111µs making 1 call to experimental::import |
14 | 2 | 51µs | 2 | 59µs | # spent 54µs (24+30) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@14 which was called:
# once (24µs+30µs) by OpenAPI::Modern::BEGIN@28 at line 14 # spent 54µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@14
# spent 5µs making 1 call to if::import |
15 | 2 | 30µs | 2 | 39µs | # spent 38µs (21+17) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@15 which was called:
# once (21µs+17µs) by OpenAPI::Modern::BEGIN@28 at line 15 # spent 38µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@15
# spent 1µs making 1 call to if::unimport |
16 | 2 | 27µs | 2 | 30µs | # spent 28µs (12+16) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@16 which was called:
# once (12µs+16µs) by OpenAPI::Modern::BEGIN@28 at line 16 # spent 28µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@16
# spent 2µs making 1 call to if::unimport |
17 | 2 | 33µs | 2 | 26µs | # spent 25µs (10+15) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@17 which was called:
# once (10µs+15µs) by OpenAPI::Modern::BEGIN@28 at line 17 # spent 25µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@17
# spent 1µs making 1 call to if::unimport |
18 | 3 | 51µs | 3 | 146µs | # spent 81µs (16+65) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@18 which was called:
# once (16µs+65µs) by OpenAPI::Modern::BEGIN@28 at line 18 # spent 81µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@18
# spent 49µs making 1 call to Exporter::import
# spent 16µs making 1 call to UNIVERSAL::VERSION |
19 | 2 | 30µs | 2 | 250µs | # spent 139µs (28+111) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@19 which was called:
# once (28µs+111µs) by OpenAPI::Modern::BEGIN@28 at line 19 # spent 139µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@19
# spent 111µs making 1 call to Exporter::import |
20 | 2 | 19µs | 2 | 42µs | # spent 24µs (6+18) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@20 which was called:
# once (6µs+18µs) by OpenAPI::Modern::BEGIN@28 at line 20 # spent 24µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@20
# spent 18µs making 1 call to Exporter::import |
21 | 2 | 26µs | 2 | 35µs | # spent 20µs (5+15) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@21 which was called:
# once (5µs+15µs) by OpenAPI::Modern::BEGIN@28 at line 21 # spent 20µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@21
# spent 15µs making 1 call to Exporter::import |
22 | 2 | 22µs | 2 | 43µs | # spent 34µs (10+24) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@22 which was called:
# once (10µs+24µs) by OpenAPI::Modern::BEGIN@28 at line 22 # spent 34µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@22
# spent 9µs making 1 call to List::Util::import |
23 | 2 | 18µs | 2 | 32µs | # spent 18µs (4+14) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@23 which was called:
# once (4µs+14µs) by OpenAPI::Modern::BEGIN@28 at line 23 # spent 18µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@23
# spent 14µs making 1 call to Exporter::import |
24 | 2 | 23µs | 2 | 157µs | # spent 82µs (7+75) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@24 which was called:
# once (7µs+75µs) by OpenAPI::Modern::BEGIN@28 at line 24 # spent 82µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@24
# spent 75µs making 1 call to MooX::HandlesVia::import |
25 | 3 | 48µs | 3 | 1.02ms | # spent 515µs (14+501) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@25 which was called:
# once (14µs+501µs) by OpenAPI::Modern::BEGIN@28 at line 25 # spent 515µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@25
# spent 490µs making 1 call to MooX::TypeTiny::import
# spent 11µs making 1 call to UNIVERSAL::VERSION |
26 | 2 | 58µs | 2 | 1.62ms | # spent 819µs (17+802) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@26 which was called:
# once (17µs+802µs) by OpenAPI::Modern::BEGIN@28 at line 26 # spent 819µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@26
# spent 802µs making 1 call to Exporter::Tiny::import |
27 | 2 | 55µs | 2 | 699µs | # spent 355µs (11+344) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@27 which was called:
# once (11µs+344µs) by OpenAPI::Modern::BEGIN@28 at line 27 # spent 355µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@27
# spent 344µs making 1 call to namespace::clean::import |
28 | |||||
29 | 1 | 2µs | 1 | 1.21ms | extends 'JSON::Schema::Modern::Document'; # spent 1.21ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::extends |
30 | |||||
31 | 2 | 56µs | 2 | 103µs | # spent 57µs (11+46) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@31 which was called:
# once (11µs+46µs) by OpenAPI::Modern::BEGIN@28 at line 31 # spent 57µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@31
# spent 46µs making 1 call to constant::import |
32 | |||||
33 | 1 | 0s | # spent 35µs (11+24) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@33 which was called:
# once (11µs+24µ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 | 27µs | 2 | 59µs | }; # spent 35µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@33
# spent 24µs making 1 call to constant::import |
42 | |||||
43 | 2 | 1.40ms | 2 | 46µs | # spent 26µs (6+20) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@43 which was called:
# once (6µs+20µs) by OpenAPI::Modern::BEGIN@28 at line 43 # spent 26µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@43
# spent 20µs making 1 call to constant::import |
44 | |||||
45 | 1 | 9µs | 1 | 1.61ms | has '+evaluator' => ( # spent 1.61ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has |
46 | required => 1, | ||||
47 | ); | ||||
48 | |||||
49 | 1 | 3µs | 1 | 2.32ms | has '+metaschema_uri' => ( # spent 2.32ms 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 | 5µs | 2 | 38µs | # spent 43µs (5+38) 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 (5µs+38µs) by JSON::Schema::Modern::Document::OpenAPI::_set_json_schema_dialect at line 28 of (eval 394)[Sub/Quote.pm:3] # spent 29µs making 1 call to Mojo::URL::new
# spent 9µs making 1 call to Safe::Isa::__ANON__[Safe/Isa.pm:23] |
57 | 1 | 10µs | 2 | 1.77ms | ); # spent 1.63ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has
# spent 139µ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 | 1.97ms | ); # spent 1.56ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has
# spent 408µs making 1 call to Types::Standard::HashRef
# spent 3µs making 1 call to Types::Standard::Str |
71 | |||||
72 | 3 | 1µs | # spent 94.3s (41.8ms+94.2) within JSON::Schema::Modern::Document::OpenAPI::traverse which was called:
# once (41.8ms+94.2s) by JSON::Schema::Modern::Document::BUILD at line 146 of JSON/Schema/Modern/Document.pm | ||
73 | 1 | 9µs | 1 | 195ms | $self->_add_vocab_and_default_schemas; # spent 195ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas |
74 | |||||
75 | 1 | 17µs | 1 | 5µs | my $schema = $self->schema; # spent 5µs making 1 call to JSON::Schema::Modern::Document::schema |
76 | 1 | 20µs | 2 | 1µs | my $state = { # spent 1µs making 1 call to JSON::Schema::Modern::Document::canonical_uri
# spent 0s 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 | 3µs | if ((my $type = get_type($schema)) ne 'object') { # spent 3µ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 | 11µs | 2 | 39µs | return $state if not assert_keyword_exists({ %$state, keyword => 'openapi' }, $schema) # spent 35µs making 1 call to JSON::Schema::Modern::Utilities::assert_keyword_type
# spent 4µ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 | 0s | return $state if exists $schema->{jsonSchemaDialect} | ||
107 | 1 | 1µs | and not assert_keyword_type({ %$state, keyword => 'jsonSchemaDialect' }, $schema, 'string'); | ||
108 | |||||
109 | 1 | 2µs | 1 | 2µs | my $json_schema_dialect = $self->json_schema_dialect // $schema->{jsonSchemaDialect}; # spent 2µ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 | 2.69ms | my $check_metaschema_state = $evaluator->traverse({}, { # spent 2.65ms making 1 call to JSON::Schema::Modern::traverse
# spent 40µ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 | 6µs | 1 | 63µs | $self->_set_json_schema_dialect($json_schema_dialect); # spent 63µ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 | 507µs | my $result = $self->evaluator->evaluate( | ||
134 | $self->schema, | ||||
135 | $self->metaschema_uri, | ||||
136 | { | ||||
137 | callbacks => { | ||||
138 | 5172 | 1.33ms | # spent 11.2ms 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.2ms+0s) by JSON::Schema::Modern::_eval_subschema at line 588 of JSON/Schema/Modern.pm, avg 4µs/call | ||
139 | 2586 | 11.3ms | push @json_schema_paths, $state->{data_path} if $schema->{'$dynamicRef'} eq '#meta'; | ||
140 | }, | ||||
141 | 156220 | 32.9ms | # spent 121ms 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 (121ms+0s) by JSON::Schema::Modern::_eval_subschema at line 588 of JSON/Schema/Modern.pm, avg 3µs/call | ||
142 | push @operation_paths, [ $data->{operationId} => $state->{data_path} ] | ||||
143 | 39055 | 140ms | if $schema->{'$ref'} eq '#/$defs/operation' and defined $data->{operationId}; | ||
144 | }, | ||||
145 | }, | ||||
146 | }, | ||||
147 | 1 | 40µs | 4 | 87.5s | ); # spent 87.5s making 1 call to JSON::Schema::Modern::evaluate
# spent 2µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::metaschema_uri
# spent 1µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::evaluator
# spent 0s making 1 call to JSON::Schema::Modern::Document::schema |
148 | |||||
149 | 1 | 11µs | 2 | 14µs | if (not $result) { # spent 12µs making 1 call to JSON::Schema::Modern::Result::__ANON__[JSON/Schema/Modern/Result.pm:29]
# spent 2µ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.64ms | 1 | 896µs | foreach my $path (sort @json_schema_paths) { # spent 896µ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 | 5.23s | 936224 | 8.79s | next if any { $path =~ m{^\Q$_\E(?:/|\z)} } @real_json_schema_paths; # spent 5.22s making 2586 calls to List::Util::any, avg 2.02ms/call
# spent 3.50s making 466819 calls to JSON::Schema::Modern::Document::OpenAPI::CORE:regcomp, avg 8µs/call
# spent 69.5ms making 466819 calls to JSON::Schema::Modern::Document::OpenAPI::CORE:match, avg 149ns/call |
159 | |||||
160 | 965 | 1.94ms | unshift @real_json_schema_paths, $path; | ||
161 | 965 | 14.6ms | 1930 | 1.26s | $self->_traverse_schema($self->get($path), { %$state, schema_path => $path }); # spent 1.18s making 965 calls to JSON::Schema::Modern::Document::OpenAPI::_traverse_schema, avg 1.22ms/call
# spent 85.0ms making 965 calls to Mojo::JSON::Pointer::get, avg 88µs/call |
162 | } | ||||
163 | |||||
164 | 1 | 1µ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 | 9.09ms | return $state; | ||
176 | } | ||||
177 | |||||
178 | ######## NO PUBLIC INTERFACES FOLLOW THIS POINT ######## | ||||
179 | |||||
180 | 2 | 0s | # spent 195ms (261µs+194) within JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas which was called:
# once (261µs+194ms) 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 | 61.2ms | $js->add_vocabulary('JSON::Schema::Modern::Vocabulary::OpenAPI'); # spent 61.2ms 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 | 20µs | 1 | 1.19ms | ); # spent 1.19ms making 1 call to JSON::Schema::Modern::add_format_validation |
201 | |||||
202 | 1 | 29µs | 1 | 8µs | foreach my $pairs (pairs DEFAULT_SCHEMAS->%*) { # spent 8µs making 1 call to List::Util::pairs |
203 | 6 | 4µs | my ($filename, $uri) = @$pairs; | ||
204 | 6 | 685µs | 36 | 126ms | my $document = $js->add_schema($uri, # spent 124ms making 6 calls to JSON::Schema::Modern::add_schema, avg 20.7ms/call
# spent 766µs making 6 calls to File::ShareDir::dist_dir, avg 128µs/call
# spent 561µs making 6 calls to Cpanel::JSON::XS::decode, avg 94µs/call
# spent 108µs making 6 calls to JSON::Schema::Modern::_json_decoder, avg 18µs/call
# spent 64µs making 6 calls to Path::Tiny::path, avg 11µs/call
# spent 33µs making 6 calls to Path::Tiny::slurp_raw, avg 6µs/call |
205 | $js->_json_decoder->decode(path(dist_dir('OpenAPI-Modern'), $filename)->slurp_raw)); | ||||
206 | 6 | 41µs | 8 | 1.88ms | $js->add_schema($uri.'/latest', $document) if $uri =~ /schema(-base)?$/; # spent 1.87ms making 2 calls to JSON::Schema::Modern::add_schema, avg 933µs/call
# spent 15µs making 6 calls to JSON::Schema::Modern::Document::OpenAPI::CORE:match, avg 2µs/call |
207 | } | ||||
208 | } | ||||
209 | |||||
210 | # https://spec.openapis.org/oas/v3.1.0#schema-object | ||||
211 | 3860 | 1.14ms | # spent 1.18s (25.3ms+1.15) within JSON::Schema::Modern::Document::OpenAPI::_traverse_schema which was called 965 times, avg 1.22ms/call:
# 965 times (25.3ms+1.15s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 161, avg 1.22ms/call | ||
212 | 965 | 1.93ms | 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 | 14.4ms | 2908 | 1.15s | metaschema_uri => $self->json_schema_dialect, # spent 1.10s making 727 calls to JSON::Schema::Modern::traverse, avg 1.52ms/call
# spent 45.1ms making 727 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 62µs/call
# spent 1.92ms making 727 calls to JSON::Schema::Modern::Document::OpenAPI::json_schema_dialect, avg 3µs/call
# spent 1.75ms making 727 calls to JSON::Schema::Modern::Document::OpenAPI::evaluator, avg 2µs/call |
219 | }); | ||||
220 | |||||
221 | 727 | 1.10ms | push $state->{errors}->@*, $subschema_state->{errors}->@*; | ||
222 | 727 | 327µs | return if $subschema_state->{errors}->@*; | ||
223 | |||||
224 | 727 | 5.84ms | push $state->{identifiers}->@*, $subschema_state->{identifiers}->@*; | ||
225 | } | ||||
226 | |||||
227 | 1 | 16µs | 1; | ||
228 | |||||
229 | 1 | 51µs | 1 | 618µs | __END__ # spent 618µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 69.5ms within JSON::Schema::Modern::Document::OpenAPI::CORE:match which was called 466826 times, avg 149ns/call:
# 466819 times (69.5ms+0s) by List::Util::any at line 158, avg 149ns/call
# 6 times (15µs+0s) by JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas at line 206, avg 2µs/call
# once (7µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 98 | |||||
# spent 3.50s within JSON::Schema::Modern::Document::OpenAPI::CORE:regcomp which was called 466819 times, avg 8µs/call:
# 466819 times (3.50s+0s) by List::Util::any at line 158, avg 8µs/call | |||||
# spent 896µs within JSON::Schema::Modern::Document::OpenAPI::CORE:sort which was called:
# once (896µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 156 |