The Typesync schema for a project is defined in a collection of YAML/JSON files. Your definition can contain as many model definition files as you need and you can organize them any way you want. Each top-level field in a definition file must refer to a model name and the corresponding value must be the model definition. There are two types of models that you can define in a model definition file: document models and alias models.Documentation Index
Fetch the complete documentation index at: https://docs.typesync.org/llms.txt
Use this file to discover all available pages before exploring further.
Document models
A document model represents the shape of a document in a particular Firestore collection.A literal field that specifies that this is a
document model.An exact or generic path to the document. Must be a string consisting of path segments separated by a
/ (slash). Each segment can either be a literal ID or a generic ID of the collection or document. A literal ID is a plain string, such as users, while a generic ID must be enclosed in curly braces (e.g. {userId}).Example values:projects/{projectId}: A document in a top-levelprojectscollection.users/{userId}/posts/{postId}: A document in apostssub-collection.static/data/authors/{authorId}: A document in a staticauthorssub-collection.{rootColId}/{docId}/cities/london: A document with a specific ID in acitiessub-collection.
Optional documentation explaining the model in more detail. Typesync will add this to the doc comments for the
generated models.
The type representing the shape of the document. A document can be represented only by an
object type.
Swift-specific overrides for this document model.
Example
user.yml
Alias models
An alias model is used for convenience purposes to define reusable type aliases. You can use the same alias model in multiple document models. You can also use alias models when composing other aliases.A literal field that specifies that this is an
alias model.Optional documentation explaining the model in more detail. Typesync will add this to the doc comments for the
generated models.
Example
user.yml
Autcomplete/Intellisense
- YAML definition
- JSON definition
When writing your schema definition in YAML, always include the following line at the top
of each definition file.This indicates to your IDE that the file is not just any YAML file but a part of a Typesync definition by linking it to the relevant JSON Schema.. This will allow your IDE to provide Intellisense/autocomplete for definition fields.
v0.4. Patch version is always excluded.
Validating with CLI
While utilizing a JSON schema can help identify syntax errors within your schema definition, the Typesync CLI provides the most reliable method to check if a definition is syntactically valid. To validate a schema definition, use thevalidate command as shown below:
Typesync automatically validates your definition before running any generators. The manual validation command is needed when you just want to check if your schema definition is valid without generating any artifacts.

