Mixins
Mixins allow you to use the same data structures in multiple places. You define a mixin once and reference it using the $ref
keyword.
IntroductionLink copied!
You can reference any part of any schema by providing a combination of the schema id and a pointer that indicates the path to the structure. In the example below we are referencing the image
structure which is included in the definitions section of https://schema-examples.com/media
.
The content is loaded and displayed inline in the content form.
PartialsLink copied!
Partials are a type of mixin schema that contain just a definitions section. These definitions can be referenced in multiple schemas, particularly useful if you have some complex properties that you want to store and refer to in one place. You can also share definitions within the same schema.
Partials can be created in the schema editor and stored on a hub or stored externally on a hosting service or a source control system such as GitHub. Partials cannot be registered as content types and are included as part of the schema that references them. When you make a change to a partial, you should ensure that each schema that uses it is synced so that the changes are applied.
Example partialLink copied!
The following shows an example partial that just includes a single definition for a person
object. The object contains name, address and city properties.
Including a property defined in a partialLink copied!
To include the person
object in another schema use the following syntax:
A partial can contain multiple definition and you just reference each property by name.
To refer to a property defined in the definitions section of the same schema, you can use the following syntax. The difference from the previous example is just that you don't need to include the full URL because the definition is in the same file.
See the partials example for a more detailed partial.