RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.38k stars 532 forks source link

Fix: Resolve escaped "/" and "~" in JSON references #1725

Open nntzuekai opened 3 weeks ago

nntzuekai commented 3 weeks ago

Fixes #1573 and #1703

In JSON references, the character "~" and "/" should be escaped as "~0" and "~1", respectively (RFC 6901). The current version of JsonReferenceResolver would fail on resolving these references.

This fix adds support to ref paths containing these special chars by substituting them with "/" and "~" for each reference segment. Note that it replaces "~1" first to avoid transforming "~01" to "/" incorrectly (which should be "~1").