package Dancer::Plugin::JSON::Schema;
our $VERSION = '0.001'; # VERSION
use strict;
use warnings;
use utf8;
use Dancer::Plugin;
use JSON ();
use JSON::Schema;
use JSON::Hyper;
use Dancer qw(:syntax)
;
my $schemas = {};
sub json_schema {
my ($self, $name) = plugin_args(@_);
my $cfg = plugin_setting;
if (not defined $name) {
if (keys %$cfg == 1) {
($name) = keys %$cfg;
} elsi
f (keys %$cfg) {
$name = "default";
} else {
die "No JSON Schemas are configured";
}
}
return $schemas->{$name} if $schemas->{$name};
my $options = $cfg->{$name} or die "Th