th
or request->path eq uri_for('/logout')->path
or request->path eq uri_for('/swagger.json')->path
or index(request->path, uri_for('/swagger-ui')->path) == 0
);
# Dancer wil
> {
'application/json' => { api_key => 'cc9d5c02d8898e5728b7d7a0339c0785' } } },
},
},
post '/login' => sub {
my $api = ((request->accept and request->accept =~ m/(?:json|javascript)/) ? tru
n => \'LOCALTIMESTAMP' });
if ($api) {
header('Content-Type' => 'application/json');
# if there's a current valid token then reissue it and reset timer
$
};
}
if (request->is_ajax) {
my $json = to_json (\@results);
template 'ajax/report/portvlanmismatch.tt', { results => $json }, { layout => 'noop' };
}
else {
est_is_api
Client has requested JSON format data and an endpoint under C</api>.
=cut
sub request_is_api {
return ((request->accept and request->accept =~ m/(?:json|javascript)/) and (
index(r
uild time via 'update-schemas'
# the main OpenAPI document schema, with permissive (unvalidated) JSON Schemas
use constant DEFAULT_METASCHEMA => {
3.1 => 'https://spec.openapis.org/oas/3.1/schema/2
ema/2025-09-17',
};
# metaschema for JSON Schemas contained within OpenAPI documents:
# standard JSON Schema (presently draft2020-12) + OpenAPI vocabulary
use constant DEFAULT_DIALECT => {
3.1 => '
penapis.org/oas/3.2/dialect/2025-09-17',
};
# OpenAPI document schema that forces the use of the JSON Schema dialect (no $schema overrides
# permitted)
use constant DEFAULT_BASE_METASCHEMA => {
3.1
mp_tree >>
Pretty-printed abstract syntax tree (invaluable for debugging).
=item C<< $c->to_json >>
JSON representation of the object (expression, description, bounds, etc.).
=item Accessors
map { $self->_rebuild_from_node($_) } @{ $self->{nodes} } );
}
sub to_json {
my $self = shift;
return JSON::PP::encode_json(
{
expression => $self->_as_string,
descript
requests and responses against an OpenAPI v3.1 or v3.2 document
# KEYWORDS: validation evaluation JSON Schema OpenAPI v3.1 v3.2 Swagger HTTP request response
our $VERSION = '0.107';
use 5.020;
use u
at 'indexed';
use Feature::Compat::Try;
use Encode 2.89 ();
use JSON::Schema::Modern;
use JSON::Schema::Modern::Utilities qw(jsonp unjsonp canonical_uri E abort is_equal is_elements_unique true false)
;
use OpenAPI::Modern::Utilities qw(add_vocab_and_default_schemas);
use JSON::Schema::Modern::Document::OpenAPI;
use MooX::TypeTiny 0.002002;
use Types::Standard qw(InstanceOf Bool);
use Mojo::Util qw
a::Dumper::Indent=1;
use HTML::Entities qw(decode_entities encode_entities);
use CGI::Simple;
use JSON;
use Cwd qw(getcwd);
# Inherit from the Compile module, not loaded until needed though.
#
@ISA
" tags
#
%CGI_TAG_WEBDYNE=map {$_ => 1} (
'block',
'perl',
'subst',
'dump',
'json',
'api',
'include',
'htmx'
);
# Var to hold package wide hash, for data shared ac
}
else {
# html/text/json must be a param
#
my $html_sr=$param_hr->{'html'} || $param_hr->{'text'} || $param_hr->{'json'} ||
return err('no data suppl
push @new_dcf, $field;
next;
}
# snmp_object implies JSON content in the field
$field->{'json_list'} = true;
# snmp_object implies user should not edit in the web
type => 'exec',
event => 'discover',
with => {
# get JSON format of the snmp_object
cmd => (sprintf q![%% ndo %%] show -d '[%% ip %%]' -e %s --
if type=="string" then [.] else . end | [ .[] ] | sort'!
# send the JSON output into device custom_field (action inline)
.q! | [%% ndo %%] %s
rt_multipart_form
end_multipart_form
isindex
dump
include
json
));
# Update - get from CGI module, add special dump tag
#
#%CGI_TAG_IMPLICIT=map {$_ => 1} (
++} qw(
perl
script
style
start_html
end_html
include
div
api
json
htmx
table
);
# Nullify Entities encode & decode
#
*HTML::Entities::encode=sub { };
*H
reate a .psp file with no leading start_html
#
map { $HTML::Tagset::isBodyElement{$_}++ } qw(htmx json dump);
# And that we also block <p> tag closures
#
push @HTML::Tagset::p_closure_barriers, key
As above
#
WEBDYNE_CONTENT_TYPE_TEXT => 'text/plain',
WEBDYNE_CONTENT_TYPE_JSON => 'application/json',
# Script types which are executable so we won't subst strings in them
t mode - recompile loaded modules
#
WEBDYNE_RELOAD => 0,
# Use JSON canonical mode ?
#
WEBDYNE_JSON_CANONICAL => 1,
# Enable the API mode ?
#
WEBDYNE_API_
f',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'pdf' => 'application/pdf',
'svg' => 'image/svg+xml'
},
Netdisco::DB::ResultSet::Device;
use App::Netdisco::DB::ResultSet::DevicePort;
my %device_fields_json = ();
my @inline_device_actions = ();
my @inline_device_port_actions = ();
foreach my $config (@
'name'};
push @inline_device_actions, $config->{'name'};
++$device_fields_json{ $config->{'name'} } if $config->{'json_list'};
}
foreach my $config (@{ setting('custom_fields')->{'device_port'} |
map {( ('cf_'. $_) => \[
($device_fields_json{$_} ? q{ARRAY(SELECT json_array_elements_text((me.custom_fields ->> ?) ::json))::text[]}
: 'me.cu
trict;
use warnings;
use Dancer ':script';
use Moo;
use NetAddr::MAC qw/mac_as_ieee/;
use JSON qw(decode_json);
=head1 PUBLIC METHODS
=over 4
=item B<arpnip($host, $ssh)>
Retrieve ARP entries fro
md_v4 = "show ip arp vrf all | json | no-more\n";
my @out_v4 = $ssh->capture({ stdin_data => $cmd_v4 });
if (!$ssh->error) {
my $data = eval { decode_json(join '', @out_v4) };
"show ipv6 neighbor vrf all | json | no-more\n";
my @out_v6 = $ssh->capture({ stdin_data => $cmd_v6 });
if (!$ssh->error) {
my $data = eval { decode_json(join '', @out_v6) };
event_data => dclone (vars->{'hook_data'} || {}) };
# remove scalar references which to_json cannot handle
visit( $extra->{'event_data'}, sub {
my ($key, $valueref) = @_;
$$valuere
' if ref $$valueref eq 'SCALAR';
});
jq_insert({
action => ('hook::'. lc($conf->{'type'})),
extra => encode_base64( encode('UTF-8', to_json( $extra )), '' ),
});
return 1;
}
true;
$cf = from_json ($item->custom_fields || '{}');
}
elsif (ref {} eq ref $item and exists $item->{'custom_fields'}) {
$cf = from_json ($item->{'custom
$cf = from_json ($item->custom_fields || '{}');
}
elsif (ref {} eq ref $item and exists $item->{'custom_fields'}) {
$cf = from_json ($item->{'
e->headers('Location' => $destination);
};
# neater than using Dancer::Plugin::Res to handle JSON differently
*Dancer::send_error = sub {
my ($body, $status) = @_;
if (request_is_ap
efined $body;
Dancer::Continuation::Route::ErrorSent->new(
return_value => to_json { error => $body, return_url => param('return_url') }
)->throw;
}
Dancer::Con
ta structure for DataTables records per page menu
$tokens->{table_showrecordsmenu} =
to_json( setting('table_showrecordsmenu') );
# linked searches will use these default url path param
pec::Functions qw/splitdir catdir catfile/;
use MIME::Base64 'decode_base64';
use SNMP::Info;
use JSON::PP ();
use base 'Exporter';
our @EXPORT = ();
our @EXPORT_OK = qw/
get_communities
snmp_com
Base64 encoded,
decodes it and then munge to handle data format, before finally pretty
render in JSON format.
=cut
sub get_code_info { return ($_[0]) =~ m/^(.+)::(.*?)$/ }
sub sub_name { retur
ength $encoded;
my $json = JSON::PP->new->utf8->pretty->allow_nonref->allow_unknown->canonical;
$json->sort_by( sub { sortable_oid($JSON::PP::a) cmp sortable_oid($JSON::PP::b) } );
retur
search({ -or => [
-bool => \q{ array_length(oid_parts, 1) IS NULL },
-bool => \q{ jsonb_typeof(value) != 'array' }, ] })->count) {
my @rows = $device->oids->search({},{
],
})->hri->all;
$oids{$_->{oid}} = {
%{ $_ },
value => (@{ from_json($_->{value}) })[0],
} for @rows;
}
# or we have an snmpwalk file on disk
elsif (-f $
=> $oid,
oid_parts => [], # not needed temporarily
value => to_json([ ((defined $type and $type eq 'BASE64') ? $value
ToJSON});
# this replacement will avoid the issue of relation names which override
# field names, causing TO_JSON to return object instances, breaking to_json
*DBIx::Class::Helper::Row::ToJSON:
:TO_JSON = sub {
my $self = shift;
my $columns_info = $self->columns_info($self->serializable_columns);
my $columns_data = { $self->get_columns };
return {
map +($_ =>
$columns_data->{$_}), keys %$columns_info
};
};
}
# for DBIx::Class::Helper::Row::ToJSON
# to allow text columns to be included in results
sub unserializable_data_types {
return {
}
else {
my $stanza = undef;
try {
$stanza = from_json( $line );
debug sprintf '[%s] external credentials stanza added',
$
::Serializer;
my $json_backend = Parse::CPAN::Meta->json_backend;
my $json = $json_backend->new->canonical->pretty->utf8;
my $serializer = 'Dist::Build::Serializer';
sub load_json {
my $filename =
nt = do { local $/; <$fh> };
return $json->decode($content);
}
sub save_json {
my ($filename, $content) = @_;
open my $fh, '>:raw', $filename;
print $fh $json->encode($content);
return;
}
my @o
turn %options;
}
sub Build_PL {
my ($args, $env) = @_;
my $meta = CPAN::Meta->load_file('META.json', { lazy_validation => 0 });
my @env = defined $env->{PERL_MB_OPT} ? split_like_shell($env->{PE