Repository: getkin/kin-openapi (go)

Issue:
openapi3filter: deepObjects with the same properties conflict
Before #923 a query with more than one **deepObject** worked just as expected. Now **DecodeObject**  is ignoring the property's name. 

Example:

```YAML
- in: query
  name: obj
  required: false
  schema:
    type: object
    properties:
      prop:
        type: string
    required:
      - prop
  style: deepObject
  explode: true
  
- in: query
  name: obj2
  required: false
  schema:
    type: object
    properties:
      prop:
        type: string
    required:
      - prop
  style: deepObject
  explode: true
```

When parsing this url: **http://localhost?obj[prop]=value** both **obj** and **obj2** receive **value**

Pull request description:
openapi3filter: ensure key matches param name before decoding in `(*urlValuesDecoder) DecodeObject(..)`
Fix #946

Patch:
diff --git a/openapi3filter/req_resp_decoder.go b/openapi3filter/req_resp_decoder.go
index 72e9d86..882d2d3 100644
--- a/openapi3filter/req_resp_decoder.go
+++ b/openapi3filter/req_resp_decoder.go
@@ -650,6 +650,10 @@ func (d *urlValuesDecoder) DecodeObject(param string, sm *openapi3.Serialization
 		propsFn = func(params url.Values) (map[string]string, error) {
 			props := make(map[string]string)
 			for key, values := range params {
+				if !regexp.MustCompile(fmt.Sprintf(`^%s\[`, regexp.QuoteMeta(param))).MatchString(key) {
+					continue
+				}
+
 				matches := regexp.MustCompile(`\[(.*?)\]`).FindAllStringSubmatch(key, -1)
 				switch l := len(matches); {
 				case l == 0:
@@ -1562,7 +1566,7 @@ func zipFileBodyDecoder(body io.Reader, header http.Header, schema *openapi3.Sch
 func csvBodyDecoder(body io.Reader, header http.Header, schema *openapi3.SchemaRef, encFn EncodingFn) (interface{}, error) {
 	r := csv.NewReader(body)
 
-	var content string
+	var sb strings.Builder
 	for {
 		record, err := r.Read()
 		if err == io.EOF {
@@ -1572,8 +1576,9 @@ func csvBodyDecoder(body io.Reader, header http.Header, schema *openapi3.SchemaR
 			return nil, err
 		}
 
-		content += strings.Join(record, ",") + "\n"
+		sb.WriteString(strings.Join(record, ","))
+		sb.WriteString("\n")
 	}
 
-	return content, nil
+	return sb.String(), nil
 }


Test patch:
diff --git a/openapi3filter/req_resp_decoder_test.go b/openapi3filter/req_resp_decoder_test.go
index f24b245..662636b 100644
--- a/openapi3filter/req_resp_decoder_test.go
+++ b/openapi3filter/req_resp_decoder_test.go
@@ -998,6 +998,17 @@ func TestDecodeParameter(t *testing.T) {
 					query: "anotherparam=bar",
 					want:  map[string]interface{}(nil),
 				},
+				{
+					name: "deepObject explode nested object - extraneous deep object param ignored",
+					param: &openapi3.Parameter{
+						Name: "param", In: "query", Style: "deepObject", Explode: explode,
+						Schema: objectOf(
+							"obj", objectOf("nestedObjOne", stringSchema, "nestedObjTwo", stringSchema),
+						),
+					},
+					query: "anotherparam[obj][nestedObjOne]=one&anotherparam[obj][nestedObjTwo]=two",
+					want:  map[string]interface{}(nil),
+				},
 				{
 					name: "deepObject explode nested object - bad array item type",
 					param: &openapi3.Parameter{