Skip to content

Commit 71de0e0

Browse files
committed
Add a check to ascertain that the referenceType and the referencedObject matches; if not, throw an exception
1 parent b26bd6e commit 71de0e0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ private void ResolveTags(IList<OpenApiTag> tags)
259259
{
260260
try
261261
{
262+
var referencedObject = typeof(T).Name;
263+
var referenceType = reference?.Type.ToString();
264+
if (referenceType is not null && !referencedObject.Contains(referenceType))
265+
{
266+
throw new OpenApiException(string.Format(Properties.SRResource.InvalidReferenceType, referenceType));
267+
}
268+
262269
return _currentDocument.ResolveReference(reference, false) as T;
263270
}
264271
catch (OpenApiException ex)

0 commit comments

Comments
 (0)