Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Document/OpenAPI.pm |
Statements | Executed 684792 statements in 5.02s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
466819 | 1 | 1 | 3.31s | 3.31s | CORE:regcomp (opcode) | JSON::Schema::Modern::Document::OpenAPI::
39055 | 1 | 1 | 118ms | 118ms | __ANON__[:144] | JSON::Schema::Modern::Document::OpenAPI::
466826 | 3 | 1 | 60.0ms | 60.0ms | CORE:match (opcode) | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 36.7ms | 104s | traverse | JSON::Schema::Modern::Document::OpenAPI::
965 | 1 | 1 | 22.5ms | 1.18s | _traverse_schema | JSON::Schema::Modern::Document::OpenAPI::
2586 | 1 | 1 | 10.5ms | 10.5ms | __ANON__[:140] | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 723µs | 723µs | CORE:sort (opcode) | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 267µs | 196ms | _add_vocab_and_default_schemas | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 35µs | 38µs | BEGIN@1.241 | OpenAPI::Modern::
1 | 1 | 1 | 19µs | 901µs | BEGIN@12 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 19µs | 33µs | BEGIN@20 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 16µs | 73µs | BEGIN@18 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 16µs | 168µs | __ANON__[:56] | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 15µs | 38µs | BEGIN@15 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 14µs | 44µs | BEGIN@14 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 13µs | 28µs | BEGIN@16 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 13µs | 735µs | BEGIN@26 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 11µs | 11µs | BEGIN@10 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 11µs | 502µs | BEGIN@25 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 11µs | 37µs | BEGIN@33 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 10µs | 34µs | BEGIN@22 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 9µs | 340µs | BEGIN@11 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 9µs | 22µs | BEGIN@17 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 9µs | 27µs | BEGIN@21 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 9µs | 341µs | BEGIN@27 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 122µs | BEGIN@13 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 54µs | BEGIN@31 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 8µs | 35µs | BEGIN@2.242 | OpenAPI::Modern::
1 | 1 | 1 | 7µs | 65µs | BEGIN@24 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 6µs | 32µs | BEGIN@43 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 5µs | 101µs | BEGIN@19 | JSON::Schema::Modern::Document::OpenAPI::
1 | 1 | 1 | 5µs | 19µ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 | 38µs | 2 | 41µs | # spent 38µs (35+3) within OpenAPI::Modern::BEGIN@1.241 which was called:
# once (35µs+3µs) by OpenAPI::Modern::BEGIN@28 at line 1 # spent 38µs making 1 call to OpenAPI::Modern::BEGIN@1.241
# spent 3µs making 1 call to strict::import |
2 | 2 | 48µs | 2 | 62µs | # spent 35µs (8+27) within OpenAPI::Modern::BEGIN@2.242 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.242
# 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.031'; | ||
9 | |||||
10 | 2 | 38µs | 1 | 11µs | # spent 11µs within JSON::Schema::Modern::Document::OpenAPI::BEGIN@10 which was called:
# once (11µs+0s) by OpenAPI::Modern::BEGIN@28 at line 10 # spent 11µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@10 |
11 | 2 | 31µs | 2 | 671µs | # spent 340µs (9+331) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@11 which was called:
# once (9µs+331µs) by OpenAPI::Modern::BEGIN@28 at line 11 # spent 340µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@11
# spent 331µs making 1 call to Moo::import |
12 | 3 | 37µs | 3 | 1.78ms | # spent 901µs (19+882) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@12 which was called:
# once (19µs+882µs) by OpenAPI::Modern::BEGIN@28 at line 12 # spent 901µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@12
# spent 860µs making 1 call to strictures::import
# spent 21µs making 1 call to strictures::VERSION |
13 | 2 | 48µs | 2 | 236µs | # spent 122µs (8+114) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@13 which was called:
# once (8µs+114µs) by OpenAPI::Modern::BEGIN@28 at line 13 # spent 122µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@13
# spent 114µs making 1 call to experimental::import |
14 | 2 | 35µs | 2 | 47µs | # spent 44µs (14+30) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@14 which was called:
# once (14µs+30µs) by OpenAPI::Modern::BEGIN@28 at line 14 # spent 44µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@14
# spent 3µs making 1 call to if::import |
15 | 2 | 29µs | 2 | 41µs | # spent 38µs (15+23) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@15 which was called:
# once (15µs+23µs) by OpenAPI::Modern::BEGIN@28 at line 15 # spent 38µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@15
# spent 3µs making 1 call to if::unimport |
16 | 2 | 32µs | 2 | 30µs | # spent 28µs (13+15) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@16 which was called:
# once (13µs+15µ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 | 29µs | 2 | 23µs | # spent 22µs (9+13) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@17 which was called:
# once (9µs+13µs) by OpenAPI::Modern::BEGIN@28 at line 17 # spent 22µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@17
# spent 1µs making 1 call to if::unimport |
18 | 3 | 40µs | 3 | 130µs | # spent 73µs (16+57) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@18 which was called:
# once (16µs+57µs) by OpenAPI::Modern::BEGIN@28 at line 18 # spent 73µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@18
# spent 49µs making 1 call to Exporter::import
# spent 8µs making 1 call to UNIVERSAL::VERSION |
19 | 2 | 24µs | 2 | 197µs | # spent 101µs (5+96) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@19 which was called:
# once (5µs+96µs) by OpenAPI::Modern::BEGIN@28 at line 19 # spent 101µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@19
# spent 96µs making 1 call to Exporter::import |
20 | 2 | 26µs | 2 | 47µs | # spent 33µs (19+14) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@20 which was called:
# once (19µs+14µs) by OpenAPI::Modern::BEGIN@28 at line 20 # spent 33µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@20
# spent 14µs making 1 call to Exporter::import |
21 | 2 | 24µs | 2 | 45µs | # spent 27µs (9+18) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@21 which was called:
# once (9µs+18µs) by OpenAPI::Modern::BEGIN@28 at line 21 # spent 27µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@21
# spent 18µs making 1 call to Exporter::import |
22 | 2 | 24µs | 2 | 41µ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 7µs making 1 call to List::Util::import |
23 | 2 | 17µs | 2 | 33µs | # spent 19µs (5+14) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@23 which was called:
# once (5µs+14µs) by OpenAPI::Modern::BEGIN@28 at line 23 # spent 19µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@23
# spent 14µs making 1 call to Exporter::import |
24 | 2 | 29µs | 2 | 123µs | # spent 65µs (7+58) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@24 which was called:
# once (7µs+58µs) by OpenAPI::Modern::BEGIN@28 at line 24 # spent 65µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@24
# spent 58µs making 1 call to MooX::HandlesVia::import |
25 | 3 | 40µs | 3 | 993µs | # spent 502µs (11+491) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@25 which was called:
# once (11µs+491µs) by OpenAPI::Modern::BEGIN@28 at line 25 # spent 502µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@25
# spent 485µs making 1 call to MooX::TypeTiny::import
# spent 6µs making 1 call to UNIVERSAL::VERSION |
26 | 2 | 45µs | 2 | 1.46ms | # spent 735µs (13+722) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@26 which was called:
# once (13µs+722µs) by OpenAPI::Modern::BEGIN@28 at line 26 # spent 735µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@26
# spent 722µs making 1 call to Exporter::Tiny::import |
27 | 2 | 44µs | 2 | 673µs | # spent 341µs (9+332) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@27 which was called:
# once (9µs+332µs) by OpenAPI::Modern::BEGIN@28 at line 27 # spent 341µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@27
# spent 332µs making 1 call to namespace::clean::import |
28 | |||||
29 | 1 | 1µs | 1 | 1.18ms | extends 'JSON::Schema::Modern::Document'; # spent 1.18ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::extends |
30 | |||||
31 | 2 | 61µs | 2 | 100µs | # spent 54µs (8+46) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@31 which was called:
# once (8µs+46µs) by OpenAPI::Modern::BEGIN@28 at line 31 # spent 54µ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 37µs (11+26) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@33 which was called:
# once (11µs+26µ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 | 30µs | 2 | 63µs | }; # spent 37µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@33
# spent 26µs making 1 call to constant::import |
42 | |||||
43 | 2 | 1.47ms | 2 | 58µs | # spent 32µs (6+26) within JSON::Schema::Modern::Document::OpenAPI::BEGIN@43 which was called:
# once (6µs+26µs) by OpenAPI::Modern::BEGIN@28 at line 43 # spent 32µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::BEGIN@43
# spent 26µs making 1 call to constant::import |
44 | |||||
45 | 1 | 3µs | 1 | 1.49ms | has '+evaluator' => ( # spent 1.49ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has |
46 | required => 1, | ||||
47 | ); | ||||
48 | |||||
49 | 1 | 2µs | 1 | 1.64ms | has '+metaschema_uri' => ( # spent 1.64ms 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 | 13µs | 2 | 152µs | # spent 168µs (16+152) 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 (16µs+152µs) by JSON::Schema::Modern::Document::OpenAPI::_set_json_schema_dialect at line 28 of (eval 390)[Sub/Quote.pm:3] # spent 142µs making 1 call to Mojo::URL::new
# spent 10µs making 1 call to Safe::Isa::__ANON__[Safe/Isa.pm:23] |
57 | 1 | 11µs | 2 | 1.64ms | ); # spent 1.55ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has
# spent 82µ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 | 15µs | 3 | 2.62ms | ); # spent 2.28ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::has
# spent 339µs making 1 call to Types::Standard::HashRef
# spent 3µs making 1 call to Types::Standard::Str |
71 | |||||
72 | 3 | 2µs | # spent 104s (36.7ms+104) within JSON::Schema::Modern::Document::OpenAPI::traverse which was called:
# once (36.7ms+104s) by JSON::Schema::Modern::Document::BUILD at line 146 of JSON/Schema/Modern/Document.pm | ||
73 | 1 | 9µs | 1 | 196ms | $self->_add_vocab_and_default_schemas; # spent 196ms making 1 call to JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas |
74 | |||||
75 | 1 | 5µs | 1 | 3µs | my $schema = $self->schema; # spent 3µs making 1 call to JSON::Schema::Modern::Document::schema |
76 | 1 | 22µs | 2 | 2µs | my $state = { # spent 1µ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 | 4µs | if ((my $type = get_type($schema)) ne 'object') { # spent 4µ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 | 46µs | return $state if not assert_keyword_exists({ %$state, keyword => 'openapi' }, $schema) # spent 40µs making 1 call to JSON::Schema::Modern::Utilities::assert_keyword_type
# spent 6µ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 | 10µ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 | 0s | and not assert_keyword_type({ %$state, keyword => 'jsonSchemaDialect' }, $schema, 'string'); | ||
108 | |||||
109 | 1 | 2µs | 1 | 3µs | my $json_schema_dialect = $self->json_schema_dialect // $schema->{jsonSchemaDialect}; # spent 3µ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 | 11µs | 4 | 3.12ms | my $check_metaschema_state = $evaluator->traverse({}, { # spent 3.08ms making 1 call to JSON::Schema::Modern::traverse
# spent 41µs making 1 call to Mojo::URL::clone
# spent 1µs making 1 call to JSON::Schema::Modern::Document::canonical_uri
# spent 1µs making 1 call to Mojo::URL::fragment |
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 | 1µs | $state->@{qw(spec_version vocabularies)} = $check_metaschema_state->@{qw(spec_version vocabularies)}; | ||
127 | 1 | 12µs | 1 | 206µs | $self->_set_json_schema_dialect($json_schema_dialect); # spent 206µ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 | 0s | my (@json_schema_paths, @operation_paths); | ||
133 | 2586 | 389µs | my $result = $self->evaluator->evaluate( | ||
134 | $self->schema, | ||||
135 | $self->metaschema_uri, | ||||
136 | { | ||||
137 | callbacks => { | ||||
138 | 5172 | 1.01ms | # spent 10.5ms 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 (10.5ms+0s) by JSON::Schema::Modern::_eval_subschema at line 558 of JSON/Schema/Modern.pm, avg 4µs/call | ||
139 | 2586 | 10.2ms | push @json_schema_paths, $state->{data_path} if $schema->{'$dynamicRef'} eq '#meta'; | ||
140 | }, | ||||
141 | 156220 | 29.2ms | # spent 118ms 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 (118ms+0s) by JSON::Schema::Modern::_eval_subschema at line 558 of JSON/Schema/Modern.pm, avg 3µs/call | ||
142 | push @operation_paths, [ $data->{operationId} => $state->{data_path} ] | ||||
143 | 39055 | 103ms | if $schema->{'$ref'} eq '#/$defs/operation' and defined $data->{operationId}; | ||
144 | }, | ||||
145 | }, | ||||
146 | }, | ||||
147 | 1 | 58µs | 4 | 97.6s | ); # spent 97.6s making 1 call to JSON::Schema::Modern::evaluate
# spent 3µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::evaluator
# spent 3µs making 1 call to JSON::Schema::Modern::Document::schema
# spent 2µs making 1 call to JSON::Schema::Modern::Document::OpenAPI::metaschema_uri |
148 | |||||
149 | 1 | 8µs | 2 | 18µs | if (not $result) { # spent 17µs making 1 call to JSON::Schema::Modern::Result::__ANON__[JSON/Schema/Modern/Result.pm:29]
# spent 1µ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 | 7µs | my @real_json_schema_paths; | ||
156 | 1 | 1.48ms | 1 | 723µs | foreach my $path (sort @json_schema_paths) { # spent 723µ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 | 4.83s | 936224 | 8.19s | next if any { $path =~ m{^\Q$_\E(?:/|\z)} } @real_json_schema_paths; # spent 4.81s making 2586 calls to List::Util::any, avg 1.86ms/call
# spent 3.31s making 466819 calls to JSON::Schema::Modern::Document::OpenAPI::CORE:regcomp, avg 7µs/call
# spent 60.0ms making 466819 calls to JSON::Schema::Modern::Document::OpenAPI::CORE:match, avg 128ns/call |
159 | |||||
160 | 965 | 1.55ms | unshift @real_json_schema_paths, $path; | ||
161 | 965 | 12.6ms | 1930 | 1.24s | $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.23ms/call
# spent 60.0ms making 965 calls to Mojo::JSON::Pointer::get, avg 62µ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 | 7.44ms | return $state; | ||
176 | } | ||||
177 | |||||
178 | ######## NO PUBLIC INTERFACES FOLLOW THIS POINT ######## | ||||
179 | |||||
180 | 2 | 0s | # spent 196ms (267µs+196) within JSON::Schema::Modern::Document::OpenAPI::_add_vocab_and_default_schemas which was called:
# once (267µs+196ms) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 73 | ||
181 | 1 | 0s | 1 | 0s | my $js = $self->evaluator; # spent 0s making 1 call to JSON::Schema::Modern::Document::OpenAPI::evaluator |
182 | 1 | 5µs | 1 | 64.8ms | $js->add_vocabulary('JSON::Schema::Modern::Vocabulary::OpenAPI'); # spent 64.8ms 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 | 18µs | 1 | 1.15ms | ); # spent 1.15ms making 1 call to JSON::Schema::Modern::add_format_validation |
201 | |||||
202 | 1 | 14µs | 1 | 4µs | foreach my $pairs (pairs DEFAULT_SCHEMAS->%*) { # spent 4µs making 1 call to List::Util::pairs |
203 | 6 | 5µs | my ($filename, $uri) = @$pairs; | ||
204 | 6 | 1.25ms | 36 | 126ms | my $document = $js->add_schema($uri, # spent 123ms making 6 calls to JSON::Schema::Modern::add_schema, avg 20.5ms/call
# spent 1.30ms making 6 calls to File::ShareDir::dist_dir, avg 217µs/call
# spent 1.13ms making 6 calls to Cpanel::JSON::XS::decode, avg 188µs/call
# spent 79µs making 6 calls to JSON::Schema::Modern::_json_decoder, avg 13µs/call
# spent 70µs making 6 calls to Path::Tiny::path, avg 12µs/call
# spent 27µ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 | 35µs | 8 | 1.43ms | $js->add_schema($uri.'/latest', $document) if $uri =~ /schema(-base)?$/; # spent 1.41ms making 2 calls to JSON::Schema::Modern::add_schema, avg 707µs/call
# spent 12µ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.10ms | # spent 1.18s (22.5ms+1.16) within JSON::Schema::Modern::Document::OpenAPI::_traverse_schema which was called 965 times, avg 1.23ms/call:
# 965 times (22.5ms+1.16s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 161, avg 1.23ms/call | ||
212 | 965 | 1.47ms | 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 | 12.8ms | 2908 | 1.16s | metaschema_uri => $self->json_schema_dialect, # spent 1.11s making 727 calls to JSON::Schema::Modern::traverse, avg 1.53ms/call
# spent 45.0ms making 727 calls to JSON::Schema::Modern::Utilities::canonical_uri, avg 62µs/call
# spent 1.82ms making 727 calls to JSON::Schema::Modern::Document::OpenAPI::json_schema_dialect, avg 3µs/call
# spent 1.64ms making 727 calls to JSON::Schema::Modern::Document::OpenAPI::evaluator, avg 2µs/call |
219 | }); | ||||
220 | |||||
221 | 727 | 923µs | push $state->{errors}->@*, $subschema_state->{errors}->@*; | ||
222 | 727 | 400µs | return if $subschema_state->{errors}->@*; | ||
223 | |||||
224 | 727 | 5.32ms | push $state->{identifiers}->@*, $subschema_state->{identifiers}->@*; | ||
225 | } | ||||
226 | |||||
227 | 1 | 24µs | 1; | ||
228 | |||||
229 | 1 | 56µs | 1 | 699µs | __END__ # spent 699µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 60.0ms within JSON::Schema::Modern::Document::OpenAPI::CORE:match which was called 466826 times, avg 128ns/call:
# 466819 times (60.0ms+0s) by List::Util::any at line 158, avg 128ns/call
# 6 times (12µ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.31s within JSON::Schema::Modern::Document::OpenAPI::CORE:regcomp which was called 466819 times, avg 7µs/call:
# 466819 times (3.31s+0s) by List::Util::any at line 158, avg 7µs/call | |||||
# spent 723µs within JSON::Schema::Modern::Document::OpenAPI::CORE:sort which was called:
# once (723µs+0s) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 156 |