Closed tadamo closed 1 year ago
I'm all set here. I just did my own Plugin to get around this problem:
package My::SpecRenderer;
use Mojo::Base 'Mojolicious::Plugin';
use Cpanel::JSON::XS;
sub register {
my ( $self, $app, $config ) = @_;
$app->routes()->get('/openapi-spec-for-import')->to(
{ cb => sub {
my $c = shift;
$c->res->headers->content_type(
'application/json;charset=UTF-8');
$c->render(
data => Cpanel::JSON::XS->new
->canonical->allow_nonref->allow_unknown->allow_blessed
->convert_blessed->stringify_infnan->allow_dupkeys
->encode(
$config->{openapi}->validator()->data()
)
);
return;
},
}
);
return;
}
1;
Is there any easy or recommended way to prevent the
SpecRenderer
from adding all the escape characters?I'm trying to import a spec into a 3rd party tool that will accept a URL, but it's choking on the escape characters. I don't have the ability to preprocess the JSON before it attempts to import.
Sample error:
I've been doing some testing with
yq
and it throws the same error.But, if I get the escape characters removed, it works ok.
Thanks for the help! Tom