nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: getkin/kin-openapi
Pull request #396 (2021-08-06 17:50:44)

Add support for embedded struct pointers
This PR adds a guard clause so that if an embedded struct is an embedded struct _pointer_, `field_info.AppendFields` will set `t` to the underlying element. 

- Unit test added
- All tests passing


Patch:
diff --git a/jsoninfo/field_info.go b/jsoninfo/field_info.go
index d2ad505..2382b73 100644
--- a/jsoninfo/field_info.go
+++ b/jsoninfo/field_info.go
@@ -21,6 +21,9 @@ type FieldInfo struct {
 }
 
 func AppendFields(fields []FieldInfo, parentIndex []int, t reflect.Type) []FieldInfo {
+	if t.Kind() == reflect.Ptr {
+		t = t.Elem()
+	}
 	// For each field
 	numField := t.NumField()
 iteration:


Test patch:
diff --git a/openapi3gen/openapi3gen_test.go b/openapi3gen/openapi3gen_test.go
index 0062e2e..0b7fde9 100644
--- a/openapi3gen/openapi3gen_test.go
+++ b/openapi3gen/openapi3gen_test.go
@@ -85,6 +85,36 @@ func TestEmbeddedStructs(t *testing.T) {
 	require.Equal(t, true, ok)
 }
 
+func TestEmbeddedPointerStructs(t *testing.T) {
+	type EmbeddedStruct struct {
+		ID string
+	}
+
+	type ContainerStruct struct {
+		Name string
+		*EmbeddedStruct
+	}
+
+	instance := &ContainerStruct{
+		Name: "Container",
+		EmbeddedStruct: &EmbeddedStruct{
+			ID: "Embedded",
+		},
+	}
+
+	generator := NewGenerator(UseAllExportedFields())
+
+	schemaRef, err := generator.GenerateSchemaRef(reflect.TypeOf(instance))
+	require.NoError(t, err)
+
+	var ok bool
+	_, ok = schemaRef.Value.Properties["Name"]
+	require.Equal(t, true, ok)
+
+	_, ok = schemaRef.Value.Properties["ID"]
+	require.Equal(t, true, ok)
+}
+
 func TestCyclicReferences(t *testing.T) {
 	type ObjectDiff struct {
 		FieldCycle *ObjectDiff
Repository: getkin/kin-openapi
Pull request #408 (2021-08-15 17:44:08)

fix issue 407, where if server URL has no path it throws exception
https://github.com/getkin/kin-openapi/issues/407


Patch:
diff --git a/routers/gorillamux/router.go b/routers/gorillamux/router.go
index a47c762..31d8dc8 100644
--- a/routers/gorillamux/router.go
+++ b/routers/gorillamux/router.go
@@ -43,7 +43,7 @@ func NewRouter(doc *openapi3.T) (routers.Router, error) {
 			return nil, err
 		}
 		path := bDecode(u.EscapedPath())
-		if path[len(path)-1] == '/' {
+		if len(path) > 0 && path[len(path)-1] == '/' {
 			path = path[:len(path)-1]
 		}
 		servers = append(servers, srv{


Test patch:
diff --git a/routers/gorillamux/router_test.go b/routers/gorillamux/router_test.go
index c42d7f8..8dc0a2e 100644
--- a/routers/gorillamux/router_test.go
+++ b/routers/gorillamux/router_test.go
@@ -206,3 +206,16 @@ func TestPermuteScheme(t *testing.T) {
 	perms := permutePart(scheme0, server)
 	require.Equal(t, []string{"http", "https"}, perms)
 }
+
+func TestServerPath(t *testing.T) {
+	server := &openapi3.Server{URL: "http://example.com"}
+	err := server.Validate(context.Background())
+	require.NoError(t, err)
+
+	_, err = NewRouter(&openapi3.T{Servers: openapi3.Servers{
+		server,
+		&openapi3.Server{URL: "http://example.com/"},
+		&openapi3.Server{URL: "http://example.com/path"}},
+	})
+	require.NoError(t, err)
+}
Repository: getkin/kin-openapi
Pull request #421 (2021-09-20 10:24:10)

Add support for "application/x-yaml"
Yaml follows the same flow as json, but with a different unmarshaller.

Added both Contet-Types:

- `application/yaml`
- `application/x-yaml`

Unsure if `text/yaml` should also be added

Reused currently yaml.v2 used by the project

fenollp: LGTM. Only requires a go.mod change to pass CI. 


Patch:
diff --git a/go.mod b/go.mod
index f84f470..9da0ae5 100644
--- a/go.mod
+++ b/go.mod
@@ -7,5 +7,5 @@ require (
 	github.com/go-openapi/jsonpointer v0.19.5
 	github.com/gorilla/mux v1.8.0
 	github.com/stretchr/testify v1.5.1
-	gopkg.in/yaml.v2 v2.3.0 // indirect
+	gopkg.in/yaml.v2 v2.3.0
 )
diff --git a/openapi3filter/req_resp_decoder.go b/openapi3filter/req_resp_decoder.go
index 2d2728b..2dc3928 100644
--- a/openapi3filter/req_resp_decoder.go
+++ b/openapi3filter/req_resp_decoder.go
@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+	"gopkg.in/yaml.v2"
 	"io"
 	"io/ioutil"
 	"mime"
@@ -832,6 +833,8 @@ func decodeBody(body io.Reader, header http.Header, schema *openapi3.SchemaRef,
 func init() {
 	RegisterBodyDecoder("text/plain", plainBodyDecoder)
 	RegisterBodyDecoder("application/json", jsonBodyDecoder)
+	RegisterBodyDecoder("application/x-yaml", yamlBodyDecoder)
+	RegisterBodyDecoder("application/yaml", yamlBodyDecoder)
 	RegisterBodyDecoder("application/problem+json", jsonBodyDecoder)
 	RegisterBodyDecoder("application/x-www-form-urlencoded", urlencodedBodyDecoder)
 	RegisterBodyDecoder("multipart/form-data", multipartBodyDecoder)
@@ -854,6 +857,14 @@ func jsonBodyDecoder(body io.Reader, header http.Header, schema *openapi3.Schema
 	return value, nil
 }
 
+func yamlBodyDecoder(body io.Reader, header http.Header, schema *openapi3.SchemaRef, encFn EncodingFn) (interface{}, error) {
+	var value interface{}
+	if err := yaml.NewDecoder(body).Decode(&value); err != nil {
+		return nil, &ParseError{Kind: KindInvalidFormat, Cause: err}
+	}
+	return value, nil
+}
+
 func urlencodedBodyDecoder(body io.Reader, header http.Header, schema *openapi3.SchemaRef, encFn EncodingFn) (interface{}, error) {
 	// Validate schema of request body.
 	// By the OpenAPI 3 specification request body's schema must have type "object".


Test patch:
diff --git a/openapi3filter/req_resp_decoder_test.go b/openapi3filter/req_resp_decoder_test.go
index 7ae863b..34e6371 100644
--- a/openapi3filter/req_resp_decoder_test.go
+++ b/openapi3filter/req_resp_decoder_test.go
@@ -1035,6 +1035,18 @@ func TestDecodeBody(t *testing.T) {
 			body: strings.NewReader("\"foo\""),
 			want: "foo",
 		},
+		{
+			name: "x-yaml",
+			mime: "application/x-yaml",
+			body: strings.NewReader("foo"),
+			want: "foo",
+		},
+		{
+			name: "yaml",
+			mime: "application/yaml",
+			body: strings.NewReader("foo"),
+			want: "foo",
+		},
 		{
 			name: "urlencoded form",
 			mime: "application/x-www-form-urlencoded",
Repository: getkin/kin-openapi
Pull request #449 (2021-11-18 12:22:48)

ClientCredentials conversion to OpenAPI v2
 ClientCredentials was called application in OpenAPI v2 so this needs to be converted.

Specification:
https://swagger.io/specification/#oauth-flows-object

fenollp: Thanks. I understand this is a pretty minor change still could you add a regression test?
Luukvdm: Is this sufficient? I'm new to writing tests in Golang so let me know if I should change or improve something.

Patch:
diff --git a/openapi2conv/openapi2_conv.go b/openapi2conv/openapi2_conv.go
index e9f3164..2457026 100644
--- a/openapi2conv/openapi2_conv.go
+++ b/openapi2conv/openapi2_conv.go
@@ -525,6 +525,8 @@ func ToV3SecurityScheme(securityScheme *openapi2.SecurityScheme) (*openapi3.Secu
 			flows.AuthorizationCode = flow
 		case "password":
 			flows.Password = flow
+		case "application":
+			flows.ClientCredentials = flow
 		default:
 			return nil, fmt.Errorf("unsupported flow %q", securityScheme.Flow)
 		}
@@ -1076,6 +1078,8 @@ func FromV3SecurityScheme(doc3 *openapi3.T, ref *openapi3.SecuritySchemeRef) (*o
 				result.Flow = "accessCode"
 			} else if flow = flows.Password; flow != nil {
 				result.Flow = "password"
+			} else if flow = flows.ClientCredentials; flow != nil {
+				result.Flow = "application"
 			} else {
 				return nil, nil
 			}


Test patch:
diff --git a/openapi2conv/issue187_test.go b/openapi2conv/issue187_test.go
index 7ca85ca..1c113b7 100644
--- a/openapi2conv/issue187_test.go
+++ b/openapi2conv/issue187_test.go
@@ -167,3 +167,27 @@ paths:
 	err = doc3.Validate(context.Background())
 	require.NoError(t, err)
 }
+
+func TestPR449(t *testing.T) {
+	spec := `
+swagger: '2.0'
+info:
+  version: 1.0.0
+  title: title
+
+securityDefinitions:
+  OAuth2Application:
+    type: "oauth2"
+    flow: "application"
+    tokenUrl: "example.com/oauth2/token"
+`
+	doc3, err := v2v3YAML([]byte(spec))
+	require.NoError(t, err)
+	require.NotNil(t, doc3.Components.SecuritySchemes["OAuth2Application"].Value.Flows.ClientCredentials)
+	_, err = yaml.Marshal(doc3)
+	require.NoError(t, err)
+
+	doc2, err := FromV3(doc3)
+	require.NoError(t, err)
+	require.Equal(t, doc2.SecurityDefinitions["OAuth2Application"].Flow, "application")
+}
Repository: getkin/kin-openapi
Pull request #450 (2021-11-22 03:08:52)

Fix issue https://github.com/getkin/kin-openapi/issues/410
Do not specify a scheme for relative paths.


Patch:
diff --git a/routers/gorillamux/router.go b/routers/gorillamux/router.go
index 31d8dc8..eec1f01 100644
--- a/routers/gorillamux/router.go
+++ b/routers/gorillamux/router.go
@@ -35,10 +35,16 @@ func NewRouter(doc *openapi3.T) (routers.Router, error) {
 	servers := make([]srv, 0, len(doc.Servers))
 	for _, server := range doc.Servers {
 		serverURL := server.URL
-		scheme0 := strings.Split(serverURL, "://")[0]
-		schemes := permutePart(scheme0, server)
-
-		u, err := url.Parse(bEncode(strings.Replace(serverURL, scheme0+"://", schemes[0]+"://", 1)))
+		var schemes []string
+		var u *url.URL
+		var err error
+		if strings.Contains(serverURL, "://") {
+			scheme0 := strings.Split(serverURL, "://")[0]
+			schemes = permutePart(scheme0, server)
+			u, err = url.Parse(bEncode(strings.Replace(serverURL, scheme0+"://", schemes[0]+"://", 1)))
+		} else {
+			u, err = url.Parse(bEncode(serverURL))
+		}
 		if err != nil {
 			return nil, err
 		}


Test patch:
diff --git a/routers/gorillamux/router_test.go b/routers/gorillamux/router_test.go
index 8dc0a2e..6c66018 100644
--- a/routers/gorillamux/router_test.go
+++ b/routers/gorillamux/router_test.go
@@ -219,3 +219,26 @@ func TestServerPath(t *testing.T) {
 	})
 	require.NoError(t, err)
 }
+
+func TestRelativeURL(t *testing.T) {
+	helloGET := &openapi3.Operation{Responses: openapi3.NewResponses()}
+	doc := &openapi3.T{
+		Servers: openapi3.Servers{
+			&openapi3.Server{
+				URL: "/api/v1",
+			},
+		},
+		Paths: openapi3.Paths{
+			"/hello": &openapi3.PathItem{
+				Get: helloGET,
+			},
+		},
+	}
+	router, err := NewRouter(doc)
+	require.NoError(t, err)
+	req, err := http.NewRequest(http.MethodGet, "https://example.com/api/v1/hello", nil)
+	require.NoError(t, err)
+	route, _, err := router.FindRoute(req)
+	require.NoError(t, err)
+	require.Equal(t, "/hello", route.Path)
+}
Repository: getkin/kin-openapi
Pull request #463 (2021-12-14 14:02:24)

Update rfc422 regex as per spec: 'case insensitive on input'
From https://datatracker.ietf.org/doc/html/rfc4122 section 3:

>       Each field is treated as an integer and has its value printed as a
>       zero-filled hexadecimal digit string with the most significant
>       digit first.  The hexadecimal values "a" through "f" are output as
>       lower case characters and are **case insensitive on input.**

And the ABNF:

```
hexDigit =
            "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" /
            "a" / "b" / "c" / "d" / "e" / "f" /
            "A" / "B" / "C" / "D" / "E" / "F"
```

This pull request just allows the capitalised A-F.



fenollp: Please add a test showing both casing cases. 
karl-dau: I added some test cases for all caps and mixed case input.

Patch:
diff --git a/openapi3/schema.go b/openapi3/schema.go
index a15677c..c1730b6 100644
--- a/openapi3/schema.go
+++ b/openapi3/schema.go
@@ -1078,7 +1078,7 @@ func (schema *Schema) visitJSONNumber(settings *schemaValidationSettings, value
 			Value:       value,
 			Schema:      schema,
 			SchemaField: "maximum",
-			Reason:      fmt.Sprintf("number must be most %g", *v),
+			Reason:      fmt.Sprintf("number must be at most %g", *v),
 		}
 		if !settings.multiError {
 			return err
diff --git a/openapi3/schema_formats.go b/openapi3/schema_formats.go
index 095bb22..8a8a940 100644
--- a/openapi3/schema_formats.go
+++ b/openapi3/schema_formats.go
@@ -9,7 +9,7 @@ import (
 
 const (
 	// FormatOfStringForUUIDOfRFC4122 is an optional predefined format for UUID v1-v5 as specified by RFC4122
-	FormatOfStringForUUIDOfRFC4122 = `^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$`
+	FormatOfStringForUUIDOfRFC4122 = `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$`
 )
 
 //FormatCallback custom check on exotic formats


Test patch:
diff --git a/openapi3/schema_test.go b/openapi3/schema_test.go
index fdbd5e7..abdfb34 100644
--- a/openapi3/schema_test.go
+++ b/openapi3/schema_test.go
@@ -275,6 +275,12 @@ var schemaExamples = []schemaExample{
 			"dd7d8481-81a3-407f-95f0-a2f1cb382a4b",
 			"dcba3901-2fba-48c1-9db2-00422055804e",
 			"ace8e3be-c254-4c10-8859-1401d9a9d52a",
+			"DD7D8481-81A3-407F-95F0-A2F1CB382A4B",
+			"DCBA3901-2FBA-48C1-9DB2-00422055804E",
+			"ACE8E3BE-C254-4C10-8859-1401D9A9D52A",
+			"dd7D8481-81A3-407f-95F0-A2F1CB382A4B",
+			"DCBA3901-2FBA-48C1-9db2-00422055804e",
+			"ACE8E3BE-c254-4C10-8859-1401D9A9D52A",
 		},
 		AllInvalid: []interface{}{
 			nil,
@@ -282,6 +288,13 @@ var schemaExamples = []schemaExample{
 			"4cf3i040-ea14-4daa-b0b5-ea9329473519",
 			"aaf85740-7e27-4b4f-b4554-a03a43b1f5e3",
 			"56f5bff4-z4b6-48e6-a10d-b6cf66a83b04",
+			"G39840B1-D0EF-446D-E555-48FCCA50A90A",
+			"4CF3I040-EA14-4DAA-B0B5-EA9329473519",
+			"AAF85740-7E27-4B4F-B4554-A03A43B1F5E3",
+			"56F5BFF4-Z4B6-48E6-A10D-B6CF66A83B04",
+			"4CF3I040-EA14-4Daa-B0B5-EA9329473519",
+			"AAf85740-7E27-4B4F-B4554-A03A43b1F5E3",
+			"56F5Bff4-Z4B6-48E6-a10D-B6CF66A83B04",
 		},
 	},
Repository: getkin/kin-openapi
Pull request #498 (2022-02-26 17:08:54)

Fix OpenAPI 3 validation: request body content is required
According to [request body object  spec section](https://spec.openapis.org/oas/v3.0.3#request-body-object) content field is required. Seems like it would be better to validate this.

P.S.: we use this cool library for strict OpenAPI v3 specs validation in one of our project, that's why I dive into this:)

fenollp: Well thank you very much for diving into this, I'm glad!


Patch:
diff --git a/openapi3/request_body.go b/openapi3/request_body.go
index 66b512f..b0ae831 100644
--- a/openapi3/request_body.go
+++ b/openapi3/request_body.go
@@ -29,7 +29,7 @@ type RequestBody struct {
 	ExtensionProps
 	Description string  `json:"description,omitempty" yaml:"description,omitempty"`
 	Required    bool    `json:"required,omitempty" yaml:"required,omitempty"`
-	Content     Content `json:"content,omitempty" yaml:"content,omitempty"`
+	Content     Content `json:"content" yaml:"content"`
 }
 
 func NewRequestBody() *RequestBody {
@@ -98,10 +98,8 @@ func (requestBody *RequestBody) UnmarshalJSON(data []byte) error {
 }
 
 func (value *RequestBody) Validate(ctx context.Context) error {
-	if v := value.Content; v != nil {
-		if err := v.Validate(ctx); err != nil {
-			return err
-		}
+	if value.Content == nil {
+		return fmt.Errorf("content of the request body is required")
 	}
-	return nil
+	return value.Content.Validate(ctx)
 }


Test patch:
diff --git a/openapi3/openapi3_test.go b/openapi3/openapi3_test.go
index 38d488d..b2173f0 100644
--- a/openapi3/openapi3_test.go
+++ b/openapi3/openapi3_test.go
@@ -123,6 +123,7 @@ components:
   requestBodies:
     someRequestBody:
       description: Some request body
+      content: {}
   responses:
     someResponse:
       description: Some response
@@ -194,7 +195,8 @@ var specJSON = []byte(`
     },
     "requestBodies": {
       "someRequestBody": {
-        "description": "Some request body"
+        "description": "Some request body",
+        "content": {}
       }
     },
     "responses": {
@@ -253,6 +255,7 @@ func spec() *T {
 	}
 	requestBody := &RequestBody{
 		Description: "Some request body",
+		Content:     NewContent(),
 	}
 	responseDescription := "Some response"
 	response := &Response{
Repository: getkin/kin-openapi
Pull request #509 (2022-03-13 03:13:44)

discriminator value should verify the type is string to avoid panic
With out this check, the request with body like `{"discriminator": null}` or `{"discriminator": 1}` will simply get panic 
```
interface conversion: interface {} is nil, not string
```

kandaaaaa: Will add some regression tests soon
kandaaaaa: @fenollp PR updated for a new test case, and minor code update. Thanks

Patch:
diff --git a/openapi3/schema.go b/openapi3/schema.go
index 73506f7..6f99d0e 100644
--- a/openapi3/schema.go
+++ b/openapi3/schema.go
@@ -871,7 +871,12 @@ func (schema *Schema) visitSetOperations(settings *schemaValidationSettings, val
 					return errors.New("input does not contain the discriminator property")
 				}
 
-				if discriminatorRef, okcheck = schema.Discriminator.Mapping[discriminatorVal.(string)]; len(schema.Discriminator.Mapping) > 0 && !okcheck {
+				discriminatorValString, okcheck := discriminatorVal.(string)
+				if !okcheck {
+					return errors.New("descriminator value is not a string")
+				}
+
+				if discriminatorRef, okcheck = schema.Discriminator.Mapping[discriminatorValString]; len(schema.Discriminator.Mapping) > 0 && !okcheck {
 					return errors.New("input does not contain a valid discriminator value")
 				}
 			}


Test patch:
diff --git a/openapi3/schema_oneOf_test.go b/openapi3/schema_oneOf_test.go
index 03fb670..7faf268 100644
--- a/openapi3/schema_oneOf_test.go
+++ b/openapi3/schema_oneOf_test.go
@@ -116,3 +116,21 @@ func TestVisitJSON_OneOf_NoDiscriptor_MissingField(t *testing.T) {
 	})
 	require.EqualError(t, err, "doesn't match schema due to: Error at \"/scratches\": property \"scratches\" is missing\nSchema:\n  {\n    \"properties\": {\n      \"name\": {\n        \"type\": \"string\"\n      },\n      \"scratches\": {\n        \"type\": \"boolean\"\n      }\n    },\n    \"required\": [\n      \"name\",\n      \"scratches\"\n    ],\n    \"type\": \"object\"\n  }\n\nValue:\n  {\n    \"name\": \"snoopy\"\n  }\n Or Error at \"/barks\": property \"barks\" is missing\nSchema:\n  {\n    \"properties\": {\n      \"barks\": {\n        \"type\": \"boolean\"\n      },\n      \"name\": {\n        \"type\": \"string\"\n      }\n    },\n    \"required\": [\n      \"name\",\n      \"barks\"\n    ],\n    \"type\": \"object\"\n  }\n\nValue:\n  {\n    \"name\": \"snoopy\"\n  }\n")
 }
+
+func TestVisitJSON_OneOf_BadDescriminatorType(t *testing.T) {
+	s, err := NewLoader().LoadFromData(oneofSpec)
+	require.NoError(t, err)
+	err = s.Components.Schemas["Animal"].Value.VisitJSON(map[string]interface{}{
+		"name":      "snoopy",
+		"scratches": true,
+		"$type":     1,
+	})
+	require.EqualError(t, err, "descriminator value is not a string")
+
+	err = s.Components.Schemas["Animal"].Value.VisitJSON(map[string]interface{}{
+		"name":  "snoopy",
+		"barks": true,
+		"$type": nil,
+	})
+	require.EqualError(t, err, "descriminator value is not a string")
+}
Repository: getkin/kin-openapi
Pull request #517 (2022-03-29 22:05:01)

RequestError Error() does not include reason if it is the same as err
The new error message seems duplicated in this case, which is pretty bad if our customers seeing (looks like immature code)
```
parameter \"xxxx\" in query has an error: value is required but missing: value is required but missing
```

If the `reason` is the same as `Err`, there is no need to specify the reason


Patch:
diff --git a/openapi3filter/errors.go b/openapi3filter/errors.go
index 8454c81..1094bcf 100644
--- a/openapi3filter/errors.go
+++ b/openapi3filter/errors.go
@@ -22,7 +22,7 @@ var _ interface{ Unwrap() error } = RequestError{}
 func (err *RequestError) Error() string {
 	reason := err.Reason
 	if e := err.Err; e != nil {
-		if len(reason) == 0 {
+		if len(reason) == 0 || reason == e.Error() {
 			reason = e.Error()
 		} else {
 			reason += ": " + e.Error()


Test patch:
diff --git a/openapi3filter/validation_error_test.go b/openapi3filter/validation_error_test.go
index 11032c1..aae26e5 100644
--- a/openapi3filter/validation_error_test.go
+++ b/openapi3filter/validation_error_test.go
@@ -181,7 +181,7 @@ func getValidationTests(t *testing.T) []*validationTest {
 			},
 			wantErrParam:   "status",
 			wantErrParamIn: "query",
-			wantErrBody:    `parameter "status" in query has an error: value is required but missing: value is required but missing`,
+			wantErrBody:    `parameter "status" in query has an error: value is required but missing`,
 			wantErrReason:  "value is required but missing",
 			wantErrResponse: &ValidationError{Status: http.StatusBadRequest,
 				Title: `parameter "status" in query is required`},
@@ -214,7 +214,7 @@ func getValidationTests(t *testing.T) []*validationTest {
 			},
 			wantErrParam:   "tags",
 			wantErrParamIn: "query",
-			wantErrBody:    `parameter "tags" in query has an error: empty value is not allowed: empty value is not allowed`,
+			wantErrBody:    `parameter "tags" in query has an error: empty value is not allowed`,
 			wantErrReason:  "empty value is not allowed",
 			wantErrResponse: &ValidationError{Status: http.StatusBadRequest,
 				Title: `parameter "tags" in query is not allowed to be empty`},
@@ -444,7 +444,7 @@ func getValidationTests(t *testing.T) []*validationTest {
 			},
 			wantErrParam:   "petId",
 			wantErrParamIn: "path",
-			wantErrBody:    `parameter "petId" in path has an error: value is required but missing: value is required but missing`,
+			wantErrBody:    `parameter "petId" in path has an error: value is required but missing`,
 			wantErrReason:  "value is required but missing",
 			wantErrResponse: &ValidationError{Status: http.StatusBadRequest,
 				Title: `parameter "petId" in path is required`},
Repository: getkin/kin-openapi
Pull request #540 (2022-05-11 19:31:41)

Internalize parameter references in the path as well
We use externalized parameters in our OpenAPI spec. While running `InternalizeSpec` those were not internalized. This is a fix for that bug.


Patch:
diff --git a/openapi3/internalize_refs.go b/openapi3/internalize_refs.go
index 3a993bf..3a6cabb 100644
--- a/openapi3/internalize_refs.go
+++ b/openapi3/internalize_refs.go
@@ -286,6 +286,10 @@ func (doc *T) derefPaths(paths map[string]*PathItem, refNameResolver RefNameReso
 		// inline full operations
 		ops.Ref = ""
 
+		for _, param := range ops.Parameters {
+			doc.addParameterToSpec(param, refNameResolver)
+		}
+
 		for _, op := range ops.Operations() {
 			doc.addRequestBodyToSpec(op.RequestBody, refNameResolver)
 			if op.RequestBody != nil && op.RequestBody.Value != nil {


Test patch:
diff --git a/openapi3/testdata/recursiveRef/parameters/number.yml b/openapi3/testdata/recursiveRef/parameters/number.yml
new file mode 100644
index 0000000..29f0f26
--- /dev/null
+++ b/openapi3/testdata/recursiveRef/parameters/number.yml
@@ -0,0 +1,4 @@
+name: someNumber
+in: query
+schema:
+  type: string
diff --git a/openapi3/testdata/recursiveRef/paths/foo.yml b/openapi3/testdata/recursiveRef/paths/foo.yml
index 1653c7a..43e03b7 100644
--- a/openapi3/testdata/recursiveRef/paths/foo.yml
+++ b/openapi3/testdata/recursiveRef/paths/foo.yml
@@ -1,3 +1,5 @@
+parameters:
+  - $ref: ../parameters/number.yml
 get:
   responses:
     "200":