@@ -1120,33 +1120,47 @@ func multipartBodyDecoder(body io.Reader, header http.Header, schema *openapi3.S
11201120 enc = encFn (name )
11211121 }
11221122 subEncFn := func (string ) * openapi3.Encoding { return enc }
1123- // If the property's schema has type "array" it is means that the form contains a few parts with the same name.
1124- // Every such part has a type that is defined by an items schema in the property's schema.
1123+
11251124 var valueSchema * openapi3.SchemaRef
1126- var exists bool
1127- valueSchema , exists = schema .Value .Properties [name ]
1128- if ! exists {
1129- anyProperties := schema .Value .AdditionalPropertiesAllowed
1130- if anyProperties != nil {
1131- switch * anyProperties {
1132- case true :
1133- //additionalProperties: true
1134- continue
1135- default :
1136- //additionalProperties: false
1137- return nil , & ParseError {Kind : KindOther , Cause : fmt .Errorf ("part %s: undefined" , name )}
1125+ if len (schema .Value .AllOf ) > 0 {
1126+ var exists bool
1127+ for _ , sr := range schema .Value .AllOf {
1128+ valueSchema , exists = sr .Value .Properties [name ]
1129+ if exists {
1130+ break
11381131 }
11391132 }
1140- if schema . Value . AdditionalProperties == nil {
1133+ if ! exists {
11411134 return nil , & ParseError {Kind : KindOther , Cause : fmt .Errorf ("part %s: undefined" , name )}
11421135 }
1143- valueSchema , exists = schema .Value .AdditionalProperties .Value .Properties [name ]
1136+ } else {
1137+ // If the property's schema has type "array" it is means that the form contains a few parts with the same name.
1138+ // Every such part has a type that is defined by an items schema in the property's schema.
1139+ var exists bool
1140+ valueSchema , exists = schema .Value .Properties [name ]
11441141 if ! exists {
1145- return nil , & ParseError {Kind : KindOther , Cause : fmt .Errorf ("part %s: undefined" , name )}
1142+ anyProperties := schema .Value .AdditionalPropertiesAllowed
1143+ if anyProperties != nil {
1144+ switch * anyProperties {
1145+ case true :
1146+ //additionalProperties: true
1147+ continue
1148+ default :
1149+ //additionalProperties: false
1150+ return nil , & ParseError {Kind : KindOther , Cause : fmt .Errorf ("part %s: undefined" , name )}
1151+ }
1152+ }
1153+ if schema .Value .AdditionalProperties == nil {
1154+ return nil , & ParseError {Kind : KindOther , Cause : fmt .Errorf ("part %s: undefined" , name )}
1155+ }
1156+ valueSchema , exists = schema .Value .AdditionalProperties .Value .Properties [name ]
1157+ if ! exists {
1158+ return nil , & ParseError {Kind : KindOther , Cause : fmt .Errorf ("part %s: undefined" , name )}
1159+ }
1160+ }
1161+ if valueSchema .Value .Type == "array" {
1162+ valueSchema = valueSchema .Value .Items
11461163 }
1147- }
1148- if valueSchema .Value .Type == "array" {
1149- valueSchema = valueSchema .Value .Items
11501164 }
11511165
11521166 var value interface {}
@@ -1160,14 +1174,28 @@ func multipartBodyDecoder(body io.Reader, header http.Header, schema *openapi3.S
11601174 }
11611175
11621176 allTheProperties := make (map [string ]* openapi3.SchemaRef )
1163- for k , v := range schema .Value .Properties {
1164- allTheProperties [k ] = v
1165- }
1166- if schema .Value .AdditionalProperties != nil {
1167- for k , v := range schema .Value .AdditionalProperties .Value .Properties {
1177+ if len (schema .Value .AllOf ) > 0 {
1178+ for _ , sr := range schema .Value .AllOf {
1179+ for k , v := range sr .Value .Properties {
1180+ allTheProperties [k ] = v
1181+ }
1182+ if sr .Value .AdditionalProperties != nil {
1183+ for k , v := range sr .Value .AdditionalProperties .Value .Properties {
1184+ allTheProperties [k ] = v
1185+ }
1186+ }
1187+ }
1188+ } else {
1189+ for k , v := range schema .Value .Properties {
11681190 allTheProperties [k ] = v
11691191 }
1192+ if schema .Value .AdditionalProperties != nil {
1193+ for k , v := range schema .Value .AdditionalProperties .Value .Properties {
1194+ allTheProperties [k ] = v
1195+ }
1196+ }
11701197 }
1198+
11711199 // Make an object value from form values.
11721200 obj := make (map [string ]interface {})
11731201 for name , prop := range allTheProperties {
0 commit comments