Skip to content

Commit

Permalink
Merge pull request #1491 from dldl-cmd/openapiwalker_references
Browse files Browse the repository at this point in the history
Fix unresolved references in OpenApiWalker
  • Loading branch information
MaggieKimani1 authored Dec 5, 2023
2 parents f6777e4 + 5b40826 commit 2b1d082
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Microsoft.OpenApi/Services/OpenApiWalker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,8 @@ private void Walk(string context, Action walk)
/// </summary>
private bool ProcessAsReference(IOpenApiReferenceable referenceable, bool isComponent = false)
{
var isReference = referenceable.Reference != null && !isComponent;
var isReference = referenceable.Reference != null &&
(!isComponent || referenceable.UnresolvedReference);
if (isReference)
{
Walk(referenceable);
Expand Down
13 changes: 13 additions & 0 deletions test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ public void LocateReferences()
Headers = new Dictionary<string, OpenApiHeader>
{
["test-header"] = testHeader
},
SecuritySchemes = new Dictionary<string, OpenApiSecurityScheme>
{
["test-secScheme"] = new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Id = "reference-to-scheme",
Type = ReferenceType.SecurityScheme
},
UnresolvedReference = true
}
}
}
};
Expand All @@ -245,6 +257,7 @@ public void LocateReferences()
"referenceAt: #/paths/~1/get/responses/200/content/application~1json/schema",
"referenceAt: #/paths/~1/get/responses/200/headers/test-header",
"referenceAt: #/components/schemas/derived/anyOf/0",
"referenceAt: #/components/securitySchemes/test-secScheme",
"referenceAt: #/components/headers/test-header/schema"
});
}
Expand Down

0 comments on commit 2b1d082

Please sign in to comment.