Hi All I am trying to write a Dancer2 Plugin to handle OpenAPI (Swagger2) configs and I want to configure the plugin via config as usual. In my config.yml, I have :- plugins: OpenAPI: configfile: "openapicfg.yml" my Dancer2::Plugin::OpenAPI.pm looks like this:- package Dancer2::Plugin::OpenAPI; use Dancer2::Plugin; use Dancer2::Plugin::OpenAPI::Core; use Data::Dumper; register OpenAPI => sub { my $self = shift; my $plugin_conf = plugin_setting(); print Dumper { pluginconf => $plugin_conf }; ......... }; and Dancer2::Plugin::OpenAPI::Core has :- package Dancer2::Plugin::OpenAPI::Core; use Moo; use JSON::Validator::OpenAPI; use Data::Dumper; has 'apiconfig' => ( is => 'rw', reader => 'get_apiconfig', writer => 'set_apiconfig' ); sub BUILD { my $self = shift; my $config = shift; my $val = JSON::Validator::OpenAPI->new; my $url = $config->{url}; my $spec = $val->load_and_validate_schema($url); $self->set_apiconfig($val->schema->data); return $self; } 1; My App has this :- package MyApi; use strict; use warnings; use Dancer2; use Dancer2::Plugin::OpenAPI; my $apiconfig = OpenAPI->get_apiconfig; I am using Dancer2 version 0.204001 on Centos 7.3.1611 and Perl 5.16.3 When I run this - the plugin config is empty $VAR1 = { 'pluginconf' => {} }; Anyone got any idea what I am doing wrong here ? Thanks Tony
participants (1)
-
Tony Edwardson