Skip to content

Commit

Permalink
Add support for default collectionFormat when "type" is "array"
Browse files Browse the repository at this point in the history
  • Loading branch information
jhthorsen committed Aug 16, 2022
1 parent 62a36cf commit 1fdf12c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
Revision history for perl distribution JSON-Validator

5.09 Not Released
- Add support for default collectionFormat when "type" is "array"

5.08 2022-03-25T10:00:18+0900
- Fix handling OpenAPIv2 headers with collectionFormat

Expand Down
2 changes: 1 addition & 1 deletion lib/JSON/Validator/Schema/OpenAPIv2.pm
Expand Up @@ -238,7 +238,7 @@ sub _coerce_default_value {
sub _coerce_parameter_format {
my ($self, $val, $param) = @_;
return unless $val->{exists};
return unless my $format = $param->{collectionFormat};
return unless my $format = $param->{collectionFormat} || ($param->{type} eq 'array' ? 'csv' : '');
return $val->{value} = ref $val->{value} eq 'ARRAY' ? $val->{value} : [$val->{value}] if $format eq 'multi';
$val->{value} = $val->{value}[0] // '' if ref $val->{value} eq 'ARRAY';
Expand Down

0 comments on commit 1fdf12c

Please sign in to comment.