@@ -720,8 +720,8 @@ sub _validate_path_parameter ($self, $state, $param_obj, $path_captures) {
720
720
return E({ %$state , keyword => ' style' }, ' only style: simple is supported in path parameters' )
721
721
if ($param_obj -> {style }//' simple' ) ne ' simple' ;
722
722
723
- my $ types = $self -> _type_in_schema($param_obj -> {schema }, { %$state , schema_path => $state -> {schema_path }.' /schema' });
724
- if (grep $_ eq ' array' , @$ types or grep $_ eq ' object' , @$ types ) {
723
+ my @ types = $self -> _type_in_schema($param_obj -> {schema }, { %$state , schema_path => $state -> {schema_path }.' /schema' });
724
+ if (grep $_ eq ' array' , @types or grep $_ eq ' object' , @types ) {
725
725
return E($state , ' deserializing to non-primitive types is not yet supported in path parameters' );
726
726
}
727
727
@@ -761,8 +761,8 @@ sub _validate_query_parameter ($self, $state, $param_obj, $uri) {
761
761
return E({ %$state , keyword => ' style' }, ' only style: form is supported in query parameters' )
762
762
if ($param_obj -> {style }//' form' ) ne ' form' ;
763
763
764
- my $ types = $self -> _type_in_schema($param_obj -> {schema }, { %$state , schema_path => $state -> {schema_path }.' /schema' });
765
- if (grep $_ eq ' array' , @$ types or grep $_ eq ' object' , @$ types ) {
764
+ my @ types = $self -> _type_in_schema($param_obj -> {schema }, { %$state , schema_path => $state -> {schema_path }.' /schema' });
765
+ if (grep $_ eq ' array' , @types or grep $_ eq ' object' , @types ) {
766
766
return E($state , ' deserializing to non-primitive types is not yet supported in query parameters' );
767
767
}
768
768
@@ -791,19 +791,19 @@ sub _validate_header_parameter ($self, $state, $header_name, $header_obj, $heade
791
791
# line value from a field line."
792
792
my @values = map s / ^\s *// r =~ s /\s *$// r , map split (/ ,/ , $_ ), $headers -> every_header($header_name )-> @*;
793
793
794
- my $ types = $self -> _type_in_schema($header_obj -> {schema }, { %$state , schema_path => $state -> {schema_path }.' /schema' });
794
+ my @ types = $self -> _type_in_schema($header_obj -> {schema }, { %$state , schema_path => $state -> {schema_path }.' /schema' });
795
795
796
796
# RFC9110 §5.3-1: "A recipient MAY combine multiple field lines within a field section that have
797
797
# the same field name into one field line, without changing the semantics of the message, by
798
798
# appending each subsequent field line value to the initial field line value in order, separated
799
799
# by a comma (",") and optional whitespace (OWS, defined in Section 5.6.3). For consistency, use
800
800
# comma SP."
801
801
my $data ;
802
- if (grep $_ eq ' array' , @$ types ) {
802
+ if (grep $_ eq ' array' , @types ) {
803
803
# style=simple, explode=false or true: "blue,black,brown" -> ["blue","black","brown"]
804
804
$data = \@values ;
805
805
}
806
- elsif (grep $_ eq ' object' , @$ types ) {
806
+ elsif (grep $_ eq ' object' , @types ) {
807
807
if ($header_obj -> {explode }//false) {
808
808
# style=simple, explode=true: "R=100,G=200,B=150" -> { "R": 100, "G": 200, "B": 150 }
809
809
$data = +{ map m / ^([^=]*)=?(.*)$ / g , @values };
@@ -949,17 +949,25 @@ sub _resolve_ref ($self, $entity_type, $ref, $state) {
949
949
return $schema_info -> {schema };
950
950
}
951
951
952
- # determines the type(s) requested in a schema, and the new schema.
952
+ # determines the type(s) expected in a schema
953
953
sub _type_in_schema ($self , $schema , $state ) {
954
954
return [] if not is_plain_hashref($schema );
955
955
956
- while (my $ref = $schema -> {' $ref' }) {
956
+ my @types ;
957
+
958
+ push @types , is_plain_arrayref($schema -> {type }) ? ($schema -> {types }-> @*) : ($schema -> {type })
959
+ if exists $schema -> {type };
960
+
961
+ push @types , map $self -> _type_in_schema($schema -> {allOf }[$_ ],
962
+ { %$state , schema_path => $state -> {schema_path }.' /allOf/' .$_ }), 0..$schema -> {allOf }-> $# *
963
+ if exists $schema -> {allOf };
964
+
965
+ if (my $ref = $schema -> {' $ref' }) {
957
966
$schema = $self -> _resolve_ref(' schema' , $ref , $state );
967
+ push @types , $self -> _type_in_schema($schema , $state );
958
968
}
959
- my $types = is_plain_hashref($schema ) ? $schema -> {type }//[] : [];
960
- $types = [ $types ] if not is_plain_arrayref($types );
961
969
962
- return $ types ;
970
+ return @ types ;
963
971
}
964
972
965
973
# evaluates data against the subschema at the current state ___location
0 commit comments