Skip to main content

How to use references in forms

A schema can reference another schema using the $ref keyword. It is possible, for example, to reference a complete form from a remote location, reference a sub-schema from a remote location, reference properties within the same schema or use Accurate.Video specific references. The value of $ref is a URI-reference that is resolved when the form is loaded for the first time. Below you will find some examples of how to use the $ref keyword.

Referencing a complete form at a remote location

If you want to reference a complete form at a remote location the $ref should be added to the myForm block.

{
"forms": {
"myForm": {
"$ref": "https://example.com/my-remote-form.json"
}
}
}

Referencing a sub-schema at a remote location

When referencing a sub-schema the $ref should be added to the property that should utilize the referenced sub-schema.

{
"forms": {
"myForm": {
"schema": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"genre": {
"$ref": "https://example.com/genre-field.json"
}
}
}
}
}
}

Using references within the same schema

It is possible to use references within the same schema by referencing an already defined property.

{
"forms": {
"myForm": {
"schema": {
"type": "object",
"properties": {
"genre": {
"type": "string",
"enum": [
"Action",
"Drama",
"Horror",
"Comedy",
"Thriller",
"Western"
]
},
"subGenre": {
"$ref": "#/schema/properties/genre"
}
}
}
}
}
}

Using Accurate.Video specific references

It is possible to reference the available languages in Accurate.Video by using a special reference av://languages.

{
"forms": {
"myForm": {
"schema": {
"type": "object",
"properties": {
"language": {
"$ref": "av://languages"
}
}
}
}
}
}