Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression tests to highlight #242 #243

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions t/v2-headers.t
Expand Up @@ -14,6 +14,23 @@ get '/headers' => sub {
},
'dummy';

get '/validate_twice' => sub {

my $c = shift;

my $res = {before => $c->req->headers->header('x-array')};

$c->openapi->valid_input or return;

$res->{first} = $c->req->headers->header('x-array');

$c->openapi->valid_input;
$res->{second} = $c->req->headers->header('x-array');

$c->render(openapi => $res);
},
'twice';

plugin OpenAPI => {url => 'data://main/headers.json'};

my $t = Test::Mojo->new;
Expand All @@ -28,6 +45,13 @@ $what_ever = [qw(1 2 3)];
$t->get_ok('/api/headers' => {'x-array' => '42,24'})->status_is(200)->json_is('/x-array', [42, 24])
->header_is('what-ever', '1, 2, 3');

my $header_value = '42,24, 44';

$t->get_ok('/api/validate_twice' => {'x-array' => $header_value })->status_is(200)
->json_is( '/before' => $header_value )
->json_is( '/first' => $header_value )
->json_is( '/second' => $header_value );

for my $bool (qw(true false 1 0)) {
my $s = $bool =~ /true|1/ ? 'true' : 'false';
$what_ever = '123';
Expand Down Expand Up @@ -71,6 +95,20 @@ __DATA__
}
}
}
},
"/twice" : {
"get" : {
"x-mojo-name": "twice",
"parameters" : [
{ "in": "header", "name": "x-array", "items": { "type": "string" }, "type": "array", "description": "desc..." }
],
"responses" : {
"200" : {
"description": "this is required",
"schema": { "type" : "object" }
}
}
}
}
}
}