Schema Builder
Schema Builder allows developers to define a Schema based on the W3C Data Model that supports different types of fields, including nested attributes. The schema is defined based on your application’s data structure requirements.
These schemas are used in the Credential Issuance to create and issue Verifiable Credentials for users to claim and store in their Affinidi Vault account.
Below is an example of the schema built using the Schema Builder.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema.affinidi.io/ExampleSchemaV1-0.json",
"$metadata": {
"version": 1,
"revision": 0,
"discoverable": true,
"uris": {
"jsonLdContext": "https://schema.affinidi.io/ExampleSchemaV1-0.jsonld",
"jsonSchema": "https://schema.affinidi.io/ExampleSchemaV1-0.json"
}
},
"title": "ExampleSchema",
"description": "",
"type": "object",
"required": [
"@context",
"type",
"issuer",
"issuanceDate",
"credentialSubject"
],
"properties": {
"@context": {
"type": [
"string",
"array",
"object"
]
},
"id": {
"type": "string",
"format": "uri"
},
"type": {
"type": [
"string",
"array"
],
"items": {
"type": "string"
}
},
"issuer": {
"type": [
"string",
"object"
],
"format": "uri",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"format": "uri"
}
}
},
"issuanceDate": {
"type": "string",
"format": "date-time"
},
"expirationDate": {
"type": "string",
"format": "date-time"
},
"credentialSubject": {
"type": "object",
"properties": {
"first_name": {
"title": "first_name",
"type": "string",
"description": ""
},
"last_name": {
"title": "last_name",
"type": "string",
"description": ""
},
"dob": {
"title": "dob",
"type": "string",
"format": "date",
"description": ""
}
},
"required": []
},
"credentialSchema": {
"type": "object",
"required": [
"id",
"type"
],
"properties": {
"id": {
"type": "string",
"format": "uri"
},
"type": {
"type": "string"
}
}
}
}
}
Benefits of Schema Builder
- Ease of Use: It is an easy-to-use interface for designing the schema structure.
- Validation Check: It provides validation as you design the schema to ensure it follows the W3C standard.
- Reusability: Allows you to re-use and extend the publicly available schemas to save developer time.
How to Use the Schema Builder
To create a schema, go to Schema Builder of the Affinidi Portal under the Tools.
The Schema Builder page will list all available schemas published publicly by other developers by default. You can use the filter to show the unlisted schemas that are private to your project.
You can re-use these schemas to issue Verifiable Credentials based on your requirements.
Once you click on Create new or open an existing schema, you can set up the following sections:
Schema Details
The Schema Details section is used to set basic information about the schema.
- Schema Name: the name of your schema to be created.
- Version: the version of your schema to be created.
- Revision: the revision number of the current version of schema you are creating.
- Description: helpful information about the schema you are creating.
- Make this schema public: if you want to allow other developers to view and use your schema.
![Schema Builder Basic Info](/images/docs/schema-basic-info.png)
Configure Schema
Configure Schema section to define the data structure of your schema.
Attribute Name: name of the field or property in the schema.
Set as required: if the field should not be empty when generating a VC.
Type: the type of field used to store the data.
- Text: for data of type string.
- URI: used to store URI string.
- Date: used to store date value.
- Datetime: used to store date & time value.
- Number: used to store number value.
- Boolean: used to store either true or false.
- DID: used to store Decentralised Identifier (DID) value.
- Object: used to create a JSON object structure for nested attributes.
![Schema Builder Configure](/images/docs/schema-configure.png)
After you have defined the schema structure, click on the Review button. Review the schema structure and click the Publish button to create and publish the schema.
If you have made the schema public, it will also be visible to other users and used to issue verifiable credentials from their projects.
![Schema Builder Details](/images/docs/schema-details.png)
Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.