Documentation
¶
Overview ¶
Package fragment is the one place the compiler reads a $ref fragment as a JSON pointer and spells one for the resolver (GitHub #911).
A fragment is percent-decoded and nothing else (RFC 3986 section 3.5, RFC 6901 section 6), so '+' names itself. The resolver query-unescapes it, which reads '+' as a space. Every reader of a fragment as a pointer goes through Pointer, and load hands the resolver ForResolver's spelling, so the two agree by construction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForResolver ¶
ForResolver returns ref spelled so the resolver reads Pointer(ref) from it.
The resolver query-unescapes a fragment (references.Reference.GetJSONPointer), reading '+' as a space, so each '+' in the part it decodes is written "%2B". A fragment it cannot decode it keeps raw, '+' included, so ref is returned unchanged, as it is when that part holds no '+'. The document part, and anything from a second '#' on, are left as written.
func Of ¶
Of spells pointer as a fragment Pointer and the resolver both read back as exactly pointer: every byte outside a plain set is percent-encoded, '+' and '%' and '#' and whitespace included.
func Pointer ¶
Pointer returns the JSON pointer ref's fragment spells, read as RFC 3986 and RFC 6901 read it: percent escapes decoded and nothing else, so '+' names itself. It is the resolver's reading of ForResolver(ref), so it parts from the resolver's reading of ref on '+' alone. It returns "" for a ref with no fragment.
Types ¶
This section is empty.