Writing a Layout
Until now we have generated a JSON Schema and JSON-LD context for the BlogPost
type. We could use the same command to generate a JSON Schema and JSON-LD context for the User
type. For instance, the generated JSON Schema would look like this:
However what if we want to avoid disclosing the birthdate of a user to the client? Or want to use a different name for the email
property in the JSON Schema? We can do that with TreeLDR by defining a different layout for our User
type.
Go back to the schema.tldr
file and append the following layout definition at the end:
This defines a new layout for the User
type, called ClientUser
that will be used to communicate with the client applications. This layout contains all the properties of a user, except for the birth date, and the email
property is renamed into id
.
Use the tldrc
compiler in your command line to generate a JSON Schema for this layout:
Last updated