Skip to content
Snippets Groups Projects
Verified Commit 4efc11e1 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Pridane trasovaci d error helpery

parent a958e081
Branches
No related tags found
No related merge requests found
...@@ -6,10 +6,36 @@ no warnings qw{ experimental::signatures } ; ...@@ -6,10 +6,36 @@ no warnings qw{ experimental::signatures } ;
sub register ($class, $self, $conf) { sub register ($class, $self, $conf) {
$self->helper( spec_filter => sub { $self->helper(error => sub ($c, $status, $errors=[]) {
my $c = shift;
my $data = shift; if ( scalar @_ == 2 ) {
my $class = shift; $errors = [{ code => shift, message => shift }];
}
elsif ( ref $_[0] eq 'ARRAY' ) {
$errors = shift;
}
elsif ( ref $_[0] eq 'HASH' ) {
$errors = [ shift ];
}
else {
$errors = [{ message => shift, code => undef }];
}
$c->stash(
status => $status,
openapi => { errors => $errors }
);
return undef;
});
$self->helper( trace => sub( $c, $data='' ) {
$data = Dump $data if ref $data;
$c->app->log->debug($data);
});
$self->helper( spec_filter => sub ($c, $data, $class) {
if (my $def =$c->openapi->spec("/components/schemas/$class")) { if (my $def =$c->openapi->spec("/components/schemas/$class")) {
my $filtered = {}; my $filtered = {};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment