<PackageReference Include="NJsonSchema" Version="9.13.23" />

JsonReferenceExtensions

public static class JsonReferenceExtensions
Extensions to work with IJsonReference.
namespace NJsonSchema.References { public static class JsonReferenceExtensions { public static object FindParentDocument(this IJsonReference obj) { if (obj.DocumentPath != null) return obj; object possibleRoot = obj.PossibleRoot; if (possibleRoot == null) return obj; while ((possibleRoot as IJsonReference)?.PossibleRoot != null) { possibleRoot = ((IJsonReference)possibleRoot).PossibleRoot; IDocumentPathProvider documentPathProvider; if ((documentPathProvider = (possibleRoot as IDocumentPathProvider)) != null && documentPathProvider.DocumentPath != null) return possibleRoot; } return possibleRoot; } } }