Closed christopherraa closed 4 years ago
Observing the exact same behaviour even though I disable the spec-renderer for the first invocation to OpenAPI
:
plugin OpenAPI => { url => "data:///foo-spec.json", schema => "v2", plugins => [qw/+Cors +Security/] };
Ok, progress. This is a route matching issue. If basePath
in the two specs are set to /fapi
the both of the endpoint render the spec for bar
like expected.
I've changed the API in 8dcf06cc28720f44f4d5cfdb97350b8df1b8fd14, which should resolve this issue. Will be available on CPAN before you wake up 😄
Dude, you're awesome! Works exactly as expected! I ended up passing undef
as the first argument to render_spec()
since we're not supporting partial renders of it.
sub _api_spec($c) {
state $path = $c->app->home->rel_file($c->app->config->{openapi_spec})->to_string;
state $spec = JSON::Validator->new->schema($path)->bundle;
$c->openapi->render_spec(undef, $spec);
};
Output is just like I had hoped. Thanks!
I think I would suggest passing in empty string instead of undef, in case I start using the path in all cases, but right now I guess it's irrelevant.
Glad it worked out 👍
Given this example application:
For
/api_spec
this is rendered:For
/bar_api_spec
this is rendered:I would have expected to see both of the endpoints render the specification for
bar
, but that isn't happening.