Closed natebrunette closed 3 months ago
I've tried escaping the slashses, but still doesn't work. Currently, I'm grabbing
@document
directly and traversing through the structure directly, but I'd rather use.ref
.
How did you escape them? If you replace them with ~1
, ref
should be able to find them correctly. For example:
schemer = JSONSchemer.schema({
"$defs": {
"x": {
"$defs": {
"y/o": {
"$defs": {
"z": {
"type": "string"
}
}
}
}
}
}
})
subschemer = schemer.ref("#/$defs/x/$defs/y~1o/$defs/z")
subschemer.valid?(1)
>> false
Ah, I didn't know about ~1
. It's working now! Is that a ruby, json schema, or json_schemer thing?
Ah, I didn't know about
~1
. It's working now! Is that a ruby, json schema, or json_schemer thing?
Haha none of the above! It's from JSON pointer (which JSON schema uses): https://datatracker.ietf.org/doc/html/rfc6901#section-3
Glad it's working.
I'm trying to use an openapi document and I'm having trouble parsing a path directly using
document.ref("#/paths//my/path/...")
, I believe because it contains forward slashes. I've tried escaping the slashses, but still doesn't work. Currently, I'm grabbing@document
directly and traversing through the structure directly, but I'd rather use.ref
.