An Anchor
object represents a JSON Schema anchor (i.e. $anchor
) in a resource.
TIP: Read Understanding Schema Structure to learn how all the different objects in our object model are related.
You can view the source code for the JsonSchema
object here.
schema
(JsonSchema
object)
This is the JsonSchema
object that contains this anchor.
if (anchor.schema.rootResource === anchor.resource) {
console.log("This anchor is in the root resource of the schema");
}
file
(File
object)
This is the File
object that contains this anchor.
console.log(`This anchor is in ${anchor.file.path}`);
resource
(Resource
object)
This is the Resource
object that contains this anchor.
console.log(`This anchor is in ${anchor.resource.uri.href}`);
There's more to this object, but the rest of this page has not yet been written.