Skip to content

Commit 06d499a

Browse files
committed
Check whether the $ref pointer is a locator or identifier and assign the external resource
1 parent 4fdd0e8 commit 06d499a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Microsoft.OpenApi/Reader/V31/OpenApiV31Deserializer.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,14 @@ private static (string, string) GetReferenceIdAndExternalResource(string pointer
157157
string refId = !pointer.Contains('#') ? pointer : refSegments.Last();
158158

159159
var isExternalResource = !refSegments.First().StartsWith("#");
160-
string externalResource = isExternalResource
161-
? $"{refSegments.First()}/{refSegments[1].TrimEnd('#')}"
162-
: null;
160+
string externalResource = null;
161+
if (isExternalResource)
162+
{
163+
if (pointer.Contains('#'))
164+
{
165+
externalResource = $"{refSegments.First()}/{refSegments[1].TrimEnd('#')}";
166+
}
167+
}
163168

164169
return (refId, externalResource);
165170
}

0 commit comments

Comments
 (0)