| Filename | /Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Result.pm |
| Statements | Executed 62 statements in 3.08ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 1.58ms | 7.65ms | JSON::Schema::Modern::Result::BEGIN@20 |
| 1 | 1 | 1 | 41µs | 109µs | JSON::Schema::Modern::Result::BEGIN@23 |
| 1 | 1 | 1 | 23µs | 26µs | JSON::Schema::Modern::BEGIN@1.81 |
| 1 | 1 | 1 | 18µs | 55µs | JSON::Schema::Modern::Result::BUILD |
| 1 | 1 | 1 | 17µs | 28µs | JSON::Schema::Modern::Result::BEGIN@15 |
| 1 | 1 | 1 | 17µs | 18µs | JSON::Schema::Modern::Result::BEGIN@21 |
| 1 | 1 | 1 | 17µs | 20µs | JSON::Schema::Modern::Result::__ANON__[:38] |
| 1 | 1 | 1 | 14µs | 71µs | JSON::Schema::Modern::Result::BEGIN@70 |
| 1 | 1 | 1 | 13µs | 677µs | JSON::Schema::Modern::Result::BEGIN@11 |
| 1 | 1 | 1 | 12µs | 39µs | JSON::Schema::Modern::Result::BEGIN@13 |
| 1 | 1 | 1 | 12µs | 75µs | JSON::Schema::Modern::Result::BEGIN@29 |
| 1 | 1 | 1 | 10µs | 21µs | JSON::Schema::Modern::Result::BEGIN@16 |
| 1 | 1 | 1 | 10µs | 12µs | JSON::Schema::Modern::Result::__ANON__[:29] |
| 1 | 1 | 1 | 9µs | 35µs | JSON::Schema::Modern::Result::BEGIN@24 |
| 1 | 1 | 1 | 8µs | 21µs | JSON::Schema::Modern::Result::BEGIN@14 |
| 1 | 1 | 1 | 8µs | 8µs | JSON::Schema::Modern::Result::BEGIN@9 |
| 1 | 1 | 1 | 7µs | 105µs | JSON::Schema::Modern::Result::BEGIN@12 |
| 1 | 1 | 1 | 7µs | 436µs | JSON::Schema::Modern::Result::BEGIN@18 |
| 1 | 1 | 1 | 6µs | 422µs | JSON::Schema::Modern::Result::BEGIN@17 |
| 1 | 1 | 1 | 6µs | 57µs | JSON::Schema::Modern::Result::BEGIN@19 |
| 1 | 1 | 1 | 6µs | 106µs | JSON::Schema::Modern::Result::BEGIN@25 |
| 1 | 1 | 1 | 6µs | 276µs | JSON::Schema::Modern::Result::BEGIN@26 |
| 1 | 1 | 1 | 5µs | 65µs | JSON::Schema::Modern::BEGIN@2.82 |
| 1 | 1 | 1 | 5µs | 242µs | JSON::Schema::Modern::Result::BEGIN@10 |
| 1 | 1 | 1 | 4µs | 4µs | JSON::Schema::Modern::Result::BEGIN@22 |
| 2 | 2 | 1 | 2µs | 2µs | JSON::Schema::Modern::Result::__ANON__ (xsub) |
| 1 | 1 | 1 | 1µs | 1µs | JSON::Schema::Modern::Result::OUTPUT_FORMATS (xsub) |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::TO_JSON |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::__ANON__[:31] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::__ANON__[:32] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::__ANON__[:45] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::__ANON__[:47] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::__ANON__[:54] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::__ANON__[:63] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::__ANON__[:65] |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::_map_uris |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::combine |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::count |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::dump |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::format |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::result |
| 0 | 0 | 0 | 0s | 0s | JSON::Schema::Modern::Result::stringify |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | 2 | 24µs | 2 | 29µs | # spent 26µs (23+3) within JSON::Schema::Modern::BEGIN@1.81 which was called:
# once (23µs+3µs) by JSON::Schema::Modern::BEGIN@34 at line 1 # spent 26µs making 1 call to JSON::Schema::Modern::BEGIN@1.81
# spent 3µs making 1 call to strict::import |
| 2 | 2 | 31µs | 2 | 125µs | # spent 65µs (5+60) within JSON::Schema::Modern::BEGIN@2.82 which was called:
# once (5µs+60µs) by JSON::Schema::Modern::BEGIN@34 at line 2 # spent 65µs making 1 call to JSON::Schema::Modern::BEGIN@2.82
# spent 60µs making 1 call to warnings::import |
| 3 | package JSON::Schema::Modern::Result; | ||||
| 4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||
| 5 | # ABSTRACT: Contains the result of a JSON Schema evaluation | ||||
| 6 | |||||
| 7 | 1 | 7µs | our $VERSION = '0.558'; | ||
| 8 | |||||
| 9 | 2 | 24µs | 1 | 8µs | # spent 8µs within JSON::Schema::Modern::Result::BEGIN@9 which was called:
# once (8µs+0s) by JSON::Schema::Modern::BEGIN@34 at line 9 # spent 8µs making 1 call to JSON::Schema::Modern::Result::BEGIN@9 |
| 10 | 2 | 25µs | 2 | 479µs | # spent 242µs (5+237) within JSON::Schema::Modern::Result::BEGIN@10 which was called:
# once (5µs+237µs) by JSON::Schema::Modern::BEGIN@34 at line 10 # spent 242µs making 1 call to JSON::Schema::Modern::Result::BEGIN@10
# spent 237µs making 1 call to Moo::import |
| 11 | 3 | 52µs | 3 | 1.34ms | # spent 677µs (13+664) within JSON::Schema::Modern::Result::BEGIN@11 which was called:
# once (13µs+664µs) by JSON::Schema::Modern::BEGIN@34 at line 11 # spent 677µs making 1 call to JSON::Schema::Modern::Result::BEGIN@11
# spent 646µs making 1 call to strictures::import
# spent 17µs making 1 call to strictures::VERSION |
| 12 | 2 | 33µs | 2 | 203µs | # spent 105µs (7+98) within JSON::Schema::Modern::Result::BEGIN@12 which was called:
# once (7µs+98µs) by JSON::Schema::Modern::BEGIN@34 at line 12 # spent 105µs making 1 call to JSON::Schema::Modern::Result::BEGIN@12
# spent 98µs making 1 call to experimental::import |
| 13 | 2 | 26µs | 2 | 43µs | # spent 39µs (12+27) within JSON::Schema::Modern::Result::BEGIN@13 which was called:
# once (12µs+27µs) by JSON::Schema::Modern::BEGIN@34 at line 13 # spent 39µs making 1 call to JSON::Schema::Modern::Result::BEGIN@13
# spent 4µs making 1 call to if::import |
| 14 | 2 | 25µs | 2 | 23µs | # spent 21µs (8+13) within JSON::Schema::Modern::Result::BEGIN@14 which was called:
# once (8µs+13µs) by JSON::Schema::Modern::BEGIN@34 at line 14 # spent 21µs making 1 call to JSON::Schema::Modern::Result::BEGIN@14
# spent 2µs making 1 call to if::unimport |
| 15 | 2 | 17µs | 2 | 30µs | # spent 28µs (17+11) within JSON::Schema::Modern::Result::BEGIN@15 which was called:
# once (17µs+11µs) by JSON::Schema::Modern::BEGIN@34 at line 15 # spent 28µs making 1 call to JSON::Schema::Modern::Result::BEGIN@15
# spent 2µs making 1 call to if::unimport |
| 16 | 2 | 14µs | 2 | 22µs | # spent 21µs (10+11) within JSON::Schema::Modern::Result::BEGIN@16 which was called:
# once (10µs+11µs) by JSON::Schema::Modern::BEGIN@34 at line 16 # spent 21µs making 1 call to JSON::Schema::Modern::Result::BEGIN@16
# spent 1µs making 1 call to if::unimport |
| 17 | 2 | 31µs | 2 | 838µs | # spent 422µs (6+416) within JSON::Schema::Modern::Result::BEGIN@17 which was called:
# once (6µs+416µs) by JSON::Schema::Modern::BEGIN@34 at line 17 # spent 422µs making 1 call to JSON::Schema::Modern::Result::BEGIN@17
# spent 416µs making 1 call to MooX::TypeTiny::import |
| 18 | 2 | 26µs | 2 | 865µs | # spent 436µs (7+429) within JSON::Schema::Modern::Result::BEGIN@18 which was called:
# once (7µs+429µs) by JSON::Schema::Modern::BEGIN@34 at line 18 # spent 436µs making 1 call to JSON::Schema::Modern::Result::BEGIN@18
# spent 429µs making 1 call to Exporter::Tiny::import |
| 19 | 2 | 18µs | 2 | 108µs | # spent 57µs (6+51) within JSON::Schema::Modern::Result::BEGIN@19 which was called:
# once (6µs+51µs) by JSON::Schema::Modern::BEGIN@34 at line 19 # spent 57µs making 1 call to JSON::Schema::Modern::Result::BEGIN@19
# spent 51µs making 1 call to MooX::HandlesVia::import |
| 20 | 2 | 722µs | 2 | 7.65ms | # spent 7.65ms (1.58+6.07) within JSON::Schema::Modern::Result::BEGIN@20 which was called:
# once (1.58ms+6.07ms) by JSON::Schema::Modern::BEGIN@34 at line 20 # spent 7.65ms making 1 call to JSON::Schema::Modern::Result::BEGIN@20
# spent 1µs making 1 call to JSON::Schema::Modern::Result::__ANON__ |
| 21 | 2 | 35µs | 2 | 19µs | # spent 18µs (17+1) within JSON::Schema::Modern::Result::BEGIN@21 which was called:
# once (17µs+1µs) by JSON::Schema::Modern::BEGIN@34 at line 21 # spent 18µs making 1 call to JSON::Schema::Modern::Result::BEGIN@21
# spent 1µs making 1 call to JSON::Schema::Modern::Result::__ANON__ |
| 22 | 2 | 35µs | 1 | 4µs | # spent 4µs within JSON::Schema::Modern::Result::BEGIN@22 which was called:
# once (4µs+0s) by JSON::Schema::Modern::BEGIN@34 at line 22 # spent 4µs making 1 call to JSON::Schema::Modern::Result::BEGIN@22 |
| 23 | 3 | 64µs | 3 | 134µs | # spent 109µs (41+68) within JSON::Schema::Modern::Result::BEGIN@23 which was called:
# once (41µs+68µs) by JSON::Schema::Modern::BEGIN@34 at line 23 # spent 109µs making 1 call to JSON::Schema::Modern::Result::BEGIN@23
# spent 14µs making 1 call to List::Util::import
# spent 11µs making 1 call to UNIVERSAL::VERSION |
| 24 | 2 | 24µs | 2 | 61µs | # spent 35µs (9+26) within JSON::Schema::Modern::Result::BEGIN@24 which was called:
# once (9µs+26µs) by JSON::Schema::Modern::BEGIN@34 at line 24 # spent 35µs making 1 call to JSON::Schema::Modern::Result::BEGIN@24
# spent 26µs making 1 call to Exporter::import |
| 25 | 2 | 26µs | 2 | 206µs | # spent 106µs (6+100) within JSON::Schema::Modern::Result::BEGIN@25 which was called:
# once (6µs+100µs) by JSON::Schema::Modern::BEGIN@34 at line 25 # spent 106µs making 1 call to JSON::Schema::Modern::Result::BEGIN@25
# spent 100µs making 1 call to Exporter::import |
| 26 | 2 | 118µs | 2 | 546µs | # spent 276µs (6+270) within JSON::Schema::Modern::Result::BEGIN@26 which was called:
# once (6µs+270µs) by JSON::Schema::Modern::BEGIN@34 at line 26 # spent 276µs making 1 call to JSON::Schema::Modern::Result::BEGIN@26
# spent 270µs making 1 call to namespace::clean::import |
| 27 | |||||
| 28 | use overload | ||||
| 29 | 1 | 6µs | 1 | 2µs | # spent 12µs (10+2) within JSON::Schema::Modern::Result::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Result.pm:29] which was called:
# once (10µs+2µs) by JSON::Schema::Modern::Document::OpenAPI::traverse at line 149 of JSON/Schema/Modern/Document/OpenAPI.pm
# spent 75µs (12+63) within JSON::Schema::Modern::Result::BEGIN@29 which was called:
# once (12µs+63µs) by JSON::Schema::Modern::BEGIN@34 at line 33 # spent 2µs making 1 call to JSON::Schema::Modern::Result::valid |
| 30 | '&' => \&combine, | ||||
| 31 | '0+' => sub { Scalar::Util::refaddr($_[0]) }, | ||||
| 32 | '""' => sub { $_[0]->stringify }, | ||||
| 33 | 2 | 539µs | 2 | 138µs | fallback => 1; # spent 75µs making 1 call to JSON::Schema::Modern::Result::BEGIN@29
# spent 63µs making 1 call to overload::import |
| 34 | |||||
| 35 | has valid => ( | ||||
| 36 | is => 'ro', | ||||
| 37 | isa => InstanceOf['JSON::PP::Boolean'], | ||||
| 38 | 1 | 16µs | 1 | 3µs | # spent 20µs (17+3) within JSON::Schema::Modern::Result::__ANON__[/Users/ether/.perlbrew/libs/36.0@std/lib/perl5/JSON/Schema/Modern/Result.pm:38] which was called:
# once (17µs+3µs) by JSON::Schema::Modern::Result::new at line 154 of (eval 436)[Sub/Quote.pm:3] # spent 3µs making 1 call to JSON::PP::true |
| 39 | 1 | 17µs | 2 | 1.57ms | ); # spent 1.45ms making 1 call to MooX::HandlesVia::has
# spent 121µs making 1 call to Types::Standard::InstanceOf |
| 40 | sub result { shift->valid } # backcompat only | ||||
| 41 | |||||
| 42 | has exception => ( | ||||
| 43 | is => 'ro', | ||||
| 44 | isa => InstanceOf['JSON::PP::Boolean'], | ||||
| 45 | coerce => sub { $_[0] ? JSON::PP::true : JSON::PP::false }, | ||||
| 46 | lazy => 1, | ||||
| 47 | default => sub { any { $_->exception } $_[0]->errors }, | ||||
| 48 | 1 | 11µs | 2 | 1.92ms | ); # spent 1.83ms making 1 call to MooX::HandlesVia::has
# spent 91µs making 1 call to Types::Standard::InstanceOf |
| 49 | |||||
| 50 | has $_.'s' => ( | ||||
| 51 | is => 'bare', | ||||
| 52 | isa => ArrayRef[InstanceOf['JSON::Schema::Modern::'.ucfirst]], | ||||
| 53 | lazy => 1, | ||||
| 54 | default => sub { [] }, | ||||
| 55 | handles_via => 'Array', | ||||
| 56 | handles => { | ||||
| 57 | $_.'s' => 'elements', | ||||
| 58 | $_.'_count' => 'count', | ||||
| 59 | }, | ||||
| 60 | coerce => do { | ||||
| 61 | 2 | 0s | my $type = $_; | ||
| 62 | sub ($arrayref) { | ||||
| 63 | return $arrayref if all { blessed $_ } $arrayref->@*; | ||||
| 64 | return [ map +(('JSON::Schema::Modern::'.ucfirst $type)->new($_)), $arrayref->@* ]; | ||||
| 65 | }, | ||||
| 66 | 2 | 8µs | }, | ||
| 67 | 1 | 52µs | 6 | 16.1ms | ) foreach qw(error annotation); # spent 12.2ms making 2 calls to MooX::HandlesVia::has, avg 6.09ms/call
# spent 2.67ms making 2 calls to Types::Standard::ArrayRef, avg 1.33ms/call
# spent 1.24ms making 2 calls to Types::Standard::InstanceOf, avg 618µs/call |
| 68 | |||||
| 69 | # strict_basic can only be used with draft2019-09. | ||||
| 70 | 2 | 886µs | 2 | 128µs | # spent 71µs (14+57) within JSON::Schema::Modern::Result::BEGIN@70 which was called:
# once (14µs+57µs) by JSON::Schema::Modern::BEGIN@34 at line 70 # spent 71µs making 1 call to JSON::Schema::Modern::Result::BEGIN@70
# spent 57µs making 1 call to constant::import |
| 71 | |||||
| 72 | 1 | 5µs | 2 | 2.45ms | has output_format => ( # spent 1.28ms making 1 call to MooX::HandlesVia::has
# spent 1.18ms making 1 call to Types::Standard::Enum |
| 73 | is => 'rw', | ||||
| 74 | isa => Enum(OUTPUT_FORMATS), | ||||
| 75 | default => 'basic', | ||||
| 76 | ); | ||||
| 77 | |||||
| 78 | 1 | 4µs | 2 | 589µs | has formatted_annotations => ( # spent 586µs making 1 call to MooX::HandlesVia::has
# spent 3µs making 1 call to Types::Standard::Bool |
| 79 | is => 'ro', | ||||
| 80 | isa => Bool, | ||||
| 81 | default => 1, | ||||
| 82 | ); | ||||
| 83 | |||||
| 84 | 2 | 1µs | # spent 55µs (18+37) within JSON::Schema::Modern::Result::BUILD which was called:
# once (18µs+37µs) by JSON::Schema::Modern::Result::new at line 168 of (eval 436)[Sub/Quote.pm:3] | ||
| 85 | 1 | 16µs | 3 | 37µs | warn 'result is false but there are no errors' if not $self->valid and not $self->error_count; # spent 34µs making 2 calls to JSON::PP::Boolean::__ANON__[JSON/PP/Boolean.pm:7], avg 17µs/call
# spent 3µs making 1 call to JSON::Schema::Modern::Result::valid |
| 86 | } | ||||
| 87 | |||||
| 88 | sub format ($self, $style, $formatted_annotations = undef) { | ||||
| 89 | $formatted_annotations //= $self->formatted_annotations; | ||||
| 90 | |||||
| 91 | if ($style eq 'flag') { | ||||
| 92 | return +{ valid => $self->valid }; | ||||
| 93 | } | ||||
| 94 | elsif ($style eq 'basic') { | ||||
| 95 | return +{ | ||||
| 96 | valid => $self->valid, | ||||
| 97 | $self->valid | ||||
| 98 | ? ($formatted_annotations && $self->annotation_count ? (annotations => [ map $_->TO_JSON, $self->annotations ]) : ()) | ||||
| 99 | : (errors => [ map $_->TO_JSON, $self->errors ]), | ||||
| 100 | }; | ||||
| 101 | } | ||||
| 102 | # note: strict_basic will NOT be supported after draft 2019-09! | ||||
| 103 | elsif ($style eq 'strict_basic') { | ||||
| 104 | return +{ | ||||
| 105 | valid => $self->valid, | ||||
| 106 | $self->valid | ||||
| 107 | ? ($formatted_annotations && $self->annotation_count ? (annotations => [ map _map_uris($_->TO_JSON), $self->annotations ]) : ()) | ||||
| 108 | : (errors => [ map _map_uris($_->TO_JSON), $self->errors ]), | ||||
| 109 | }; | ||||
| 110 | } | ||||
| 111 | elsif ($style eq 'terse') { | ||||
| 112 | my (%instance_locations, %keyword_locations); | ||||
| 113 | |||||
| 114 | my @errors = grep { | ||||
| 115 | my ($keyword, $error) = ($_->keyword, $_->error); | ||||
| 116 | |||||
| 117 | my $keep = 0+!!( | ||||
| 118 | not $keyword | ||||
| 119 | or ( | ||||
| 120 | not grep $keyword eq $_, qw(allOf anyOf if then else dependentSchemas contains propertyNames) | ||||
| 121 | and ($keyword ne 'oneOf' or $error ne 'no subschemas are valid') | ||||
| 122 | and ($keyword ne 'prefixItems' or $error eq 'item not permitted') | ||||
| 123 | and ($keyword ne 'items' or $error eq 'item not permitted' or $error eq 'additional item not permitted') | ||||
| 124 | and ($keyword ne 'additionalItems' or $error eq 'additional item not permitted') | ||||
| 125 | and (not grep $keyword eq $_, qw(properties patternProperties) | ||||
| 126 | or $error eq 'property not permitted') | ||||
| 127 | and ($keyword ne 'additionalProperties' or $error eq 'additional property not permitted')) | ||||
| 128 | and ($keyword ne 'dependentRequired' or $error ne 'not all dependencies are satisfied') | ||||
| 129 | ); | ||||
| 130 | |||||
| 131 | ++$instance_locations{$_->instance_location} if $keep; | ||||
| 132 | ++$keyword_locations{$_->keyword_location} if $keep; | ||||
| 133 | |||||
| 134 | $keep; | ||||
| 135 | } | ||||
| 136 | $self->errors; | ||||
| 137 | |||||
| 138 | die 'uh oh, have no errors left to report' if not $self->valid and not @errors; | ||||
| 139 | |||||
| 140 | return +{ | ||||
| 141 | valid => $self->valid, | ||||
| 142 | $self->valid | ||||
| 143 | ? ($formatted_annotations && $self->annotation_count ? (annotations => [ map $_->TO_JSON, $self->annotations ]) : ()) | ||||
| 144 | : (errors => [ map $_->TO_JSON, @errors ]), | ||||
| 145 | }; | ||||
| 146 | } | ||||
| 147 | elsif ($style eq 'data_only') { | ||||
| 148 | return 'valid' if not $self->error_count; | ||||
| 149 | # Note: this output is going to be confusing when coming from a schema with a 'oneOf', 'not', | ||||
| 150 | # etc. Perhaps generating the strings with indentation levels, as derived from a nested format, | ||||
| 151 | # might be more readable. | ||||
| 152 | return join("\n", uniq(map $_->stringify, $self->errors)); | ||||
| 153 | } | ||||
| 154 | |||||
| 155 | die 'unsupported output format'; | ||||
| 156 | } | ||||
| 157 | |||||
| 158 | sub count { $_[0]->valid ? $_[0]->annotation_count : $_[0]->error_count } | ||||
| 159 | |||||
| 160 | sub combine ($self, $other, $swap) { | ||||
| 161 | die 'wrong type for & operation' if not $other->$_isa(__PACKAGE__); | ||||
| 162 | |||||
| 163 | return $self if refaddr($other) == refaddr($self); | ||||
| 164 | |||||
| 165 | return ref($self)->new( | ||||
| 166 | valid => $self->valid && $other->valid, | ||||
| 167 | annotations => [ | ||||
| 168 | $self->annotations, | ||||
| 169 | $other->annotations, | ||||
| 170 | ], | ||||
| 171 | errors => [ | ||||
| 172 | $self->errors, | ||||
| 173 | $other->errors, | ||||
| 174 | ], | ||||
| 175 | output_format => $self->output_format, | ||||
| 176 | formatted_annotations => $self->formatted_annotations || $other->formatted_annotations, | ||||
| 177 | ); | ||||
| 178 | } | ||||
| 179 | |||||
| 180 | |||||
| 181 | sub stringify ($self) { | ||||
| 182 | return $self->format('data_only'); | ||||
| 183 | } | ||||
| 184 | |||||
| 185 | sub TO_JSON ($self) { | ||||
| 186 | die 'cannot produce JSON output for data_only format' if $self->output_format eq 'data_only'; | ||||
| 187 | $self->format($self->output_format); | ||||
| 188 | } | ||||
| 189 | |||||
| 190 | sub dump ($self) { | ||||
| 191 | my $encoder = JSON::MaybeXS->new(utf8 => 0, convert_blessed => 1, canonical => 1, pretty => 1); | ||||
| 192 | $encoder->indent_length(2) if $encoder->can('indent_length'); | ||||
| 193 | $encoder->encode($self); | ||||
| 194 | } | ||||
| 195 | |||||
| 196 | # turns the JSON pointers in instance_location, keyword_location into a URI fragments, | ||||
| 197 | # for strict draft-201909 adherence | ||||
| 198 | sub _map_uris ($data) { | ||||
| 199 | return +{ | ||||
| 200 | %$data, | ||||
| 201 | map +($_ => Mojo::URL->new->fragment($data->{$_})->to_string), | ||||
| 202 | qw(instanceLocation keywordLocation), | ||||
| 203 | }; | ||||
| 204 | } | ||||
| 205 | |||||
| 206 | 1 | 20µs | 1; | ||
| 207 | |||||
| 208 | 1 | 117µs | 1 | 690µs | __END__ # spent 690µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[B/Hooks/EndOfScope/XS.pm:26] |
# spent 1µs within JSON::Schema::Modern::Result::OUTPUT_FORMATS which was called:
# once (1µs+0s) by OpenAPI::Modern::BEGIN@26 at line 59 of JSON/Schema/Modern.pm | |||||
sub JSON::Schema::Modern::Result::__ANON__; # xsub |