Open hoppfrosch opened 8 years ago
t/lib/TestApp/Controller/Root.pm
has an undocumented key base_path
which seems interesting:
{
swagger_version => '1.2',
api_version => '2.2.3',
info => {
title => 'test project',
description => 'test description',
},
resource_path => "/",
base_path => 'http://localhost:3000', #required
authorizations => {},
};
Thx for the hint - at least I got it running with this hint. Nevertheless the documentation should be updated with this information
:+1: Thank you for taking a look a this project - we will be happy to accept and PRs and/or suggestions. I will also re-review the documentation and update as you suggest.
I guess that issue is in "package Swagger::V12":
35 unless (@{$self->configuration}{qw(basePath apiVersion resourcePath)}) { 36 @{$self->configuration}{qw(basePath apiVersion resourcePath)} = 37 delete @{$self->configuration}{qw(base_path api_version resource_path)}; 38 }
Because here is delete from configuration, so when method _build_swag_data is called 2nd time, values are set to null. For instance (i call 2 times /doc/api_doc). First call is ok and returns valid json. Second call (reload page) fail.
HTTP::Server::PSGI: Accepting connections at http://0:3001/ $VAR1 = { 'info' => { 'title' => 'test project', 'description' => 'test description' }, 'resourcePath' => undef, 'apiVersion' => '2.2.3', 'basePath' => '/' }; 6305ms INFO [HP_InfrasecRest.Controller.Root] HP_InfrasecRest::Controller::Root::auto:87 - doc/api_docs $VAR1 = { 'info' => { 'title' => 'test project', 'description' => 'test description' }, 'resourcePath' => undef, 'apiVersion' => undef, 'basePath' => undef }; 8338ms INFO [HP_InfrasecRest.Controller.Root] HP_InfrasecRest::Controller::Root::auto:87 - doc/api_docs 8340ms ERROR [Catalyst] Catalyst::finalize:2076 - Caught exception in HP_InfrasecRest::Controller::Doc->api_docs "A base path must be supplied in the configuration at /usr/share/perl5/vendor_perl/Swagger/V12.pm line 42." 8341ms ERROR [Catalyst] Catalyst::finalize:2076 - Caught exception in HP_InfrasecRest::Controller::Root->end "Can't call method "handle" on an undefined value at /home/erm_users/hpemaspe/web-data/infrasec.git/infrasec-portal-rest/FILES/bin/../lib/Core/Controller/Root.pm line 126."
It's rather a question than an error (maybe missing documentation?). I'm a bloody newbie on Swagger and on integrating swagger into catalyst - therefore bare with me ... ;-)
I tried to run your example within my current catalyst environment:
Doing so everything starts up without errors - and additional pathspecs are provided (
/testswagger/api_docs/...
,/testswagger/test_two/...
,/test_one/*/*/foo/*
)Opening the page
http://127.0.0.1:3001/testswagger/api_docs
in my browser, I get the error:Any idea what's wrong? Maybe the given example might be expanded to address this ...