@@ -720,8 +720,8 @@ sub _validate_path_parameter ($self, $state, $param_obj, $path_captures) {
720720 return E({ %$state , keyword => ' style' }, ' only style: simple is supported in path parameters' )
721721 if ($param_obj -> {style }//' simple' ) ne ' simple' ;
722722
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 ) {
725725 return E($state , ' deserializing to non-primitive types is not yet supported in path parameters' );
726726 }
727727
@@ -761,8 +761,8 @@ sub _validate_query_parameter ($self, $state, $param_obj, $uri) {
761761 return E({ %$state , keyword => ' style' }, ' only style: form is supported in query parameters' )
762762 if ($param_obj -> {style }//' form' ) ne ' form' ;
763763
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 ) {
766766 return E($state , ' deserializing to non-primitive types is not yet supported in query parameters' );
767767 }
768768
@@ -791,19 +791,19 @@ sub _validate_header_parameter ($self, $state, $header_name, $header_obj, $heade
791791 # line value from a field line."
792792 my @values = map s / ^\s *// r =~ s /\s *$// r , map split (/ ,/ , $_ ), $headers -> every_header($header_name )-> @*;
793793
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' });
795795
796796 # RFC9110 §5.3-1: "A recipient MAY combine multiple field lines within a field section that have
797797 # the same field name into one field line, without changing the semantics of the message, by
798798 # appending each subsequent field line value to the initial field line value in order, separated
799799 # by a comma (",") and optional whitespace (OWS, defined in Section 5.6.3). For consistency, use
800800 # comma SP."
801801 my $data ;
802- if (grep $_ eq ' array' , @$ types ) {
802+ if (grep $_ eq ' array' , @types ) {
803803 # style=simple, explode=false or true: "blue,black,brown" -> ["blue","black","brown"]
804804 $data = \@values ;
805805 }
806- elsif (grep $_ eq ' object' , @$ types ) {
806+ elsif (grep $_ eq ' object' , @types ) {
807807 if ($header_obj -> {explode }//false) {
808808 # style=simple, explode=true: "R=100,G=200,B=150" -> { "R": 100, "G": 200, "B": 150 }
809809 $data = +{ map m / ^([^=]*)=?(.*)$ / g , @values };
@@ -949,17 +949,25 @@ sub _resolve_ref ($self, $entity_type, $ref, $state) {
949949 return $schema_info -> {schema };
950950}
951951
952- # determines the type(s) requested in a schema, and the new schema.
952+ # determines the type(s) expected in a schema
953953sub _type_in_schema ($self , $schema , $state ) {
954954 return [] if not is_plain_hashref($schema );
955955
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' }) {
957966 $schema = $self -> _resolve_ref(' schema' , $ref , $state );
967+ push @types , $self -> _type_in_schema($schema , $state );
958968 }
959- my $types = is_plain_hashref($schema ) ? $schema -> {type }//[] : [];
960- $types = [ $types ] if not is_plain_arrayref($types );
961969
962- return $ types ;
970+ return @ types ;
963971}
964972
965973# evaluates data against the subschema at the current state location
0 commit comments