From c35b46e177d3c2f0d5b54782dda7bfa387c5055f Mon Sep 17 00:00:00 2001 From: Christoph Petrausch <263448+hikhvar@users.noreply.github.com> Date: Mon, 30 May 2022 18:10:27 +0200 Subject: [PATCH] Internalize parameter references in the path as well (#540) --- openapi3/internalize_refs.go | 4 ++++ openapi3/testdata/recursiveRef/parameters/number.yml | 4 ++++ openapi3/testdata/recursiveRef/paths/foo.yml | 2 ++ 3 files changed, 10 insertions(+) create mode 100644 openapi3/testdata/recursiveRef/parameters/number.yml diff --git a/openapi3/internalize_refs.go b/openapi3/internalize_refs.go index 3a993bfb4..3a6cabb1a 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 { diff --git a/openapi3/testdata/recursiveRef/parameters/number.yml b/openapi3/testdata/recursiveRef/parameters/number.yml new file mode 100644 index 000000000..29f0f2640 --- /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 1653c7ac7..43e03b7ab 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":