Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lschierer committed Oct 24, 2024
1 parent ca861fb commit 64ebeb7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/Game/EvonyTKR/Web.pm
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ package Game::EvonyTKR::Web {
$self->plugin('DefaultHelpers');

my $OpenAPISchemaFilename = File::Spec->catfile($dist_dir, "openapi.schema.yaml");
my $OpenAPISchema = get_openapi($OpenAPISchemaFilename);
#my $OpenAPISchema = get_openapi($OpenAPISchemaFilename);
$self->config({
openapi => {
document_filename => $OpenAPISchemaFilename,
after_response => \&log_responses,
}
});

$self->plugin('OpenAPI::Modern', $self->config->{openapi});
#$self->plugin('OpenAPI::Modern', $self->config->{openapi});

$self->plugin('Game::EvonyTKR::Web::Routes::Generals', $r);
# Normal route to controller
Expand Down
7 changes: 4 additions & 3 deletions lib/Game/EvonyTKR/Web/Routes/Generals.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ package Game::EvonyTKR::Web::Routes::Generals {
);

my $namedID = $generalRoutes->under('/named/' => sub ($c) {
$c->log()->trace(`in generalRoutes namedID under clause`);
my $result = $c->openapi->validate_request($c->req);
$logger->trace('in generalRoutes namedID under clause');
my $result = true; #$c->openapi->validate_request($c->req);
if(!$result) {
$c->log()->warn('invalid request recieved',);
$logger->warn('invalid request recieved',);
$c->respond_to(
any => { data => 'Invalid Request', status => 404 }
);
}
return 1;
});

$namedID->get('/:name' => [format => ['html','txt', 'json']])->to(
Expand Down
6 changes: 5 additions & 1 deletion script/oapitest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use YAML::XS qw{ LoadFile Load };
use OpenAPI::Modern;
use File::Share qw(dist_dir dist_file);
use Data::Printer;

my $OpenAPISchemaCache;
my $dist_dir = dist_dir('Game-EvonyTKR');
Expand All @@ -22,9 +23,12 @@ ($openapi_filename)
my $openapi_file = Path::Tiny::path($openapi_filename);
my $openapi;
if ($newTemp or $serialized_file->stat->mtime < $openapi_file->stat->mtime) {
my $loadedFile = LoadFile($openapi_file);
say Data::Printer::p($loadedFile);

$openapi = OpenAPI::Modern->new(
openapi_uri => '/',
openapi_schema => Load($openapi_file->slurp_raw), # your openapi document
openapi_schema => $loadedFile, # your openapi document
);
my $frozen = Sereal::Encoder->new({ freeze_callbacks => 1 })->encode($openapi);
$serialized_file->spew_raw($frozen);
Expand Down

0 comments on commit 64ebeb7

Please sign in to comment.