> For the complete documentation index, see [llms.txt](https://mflorin.gitbook.io/revivejs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mflorin.gitbook.io/revivejs/usage/complex-schemas/schema-providers.md).

# Schema Providers

This way of defining schemas is particularly useful when dealing with recursive models (see [Recursive Schemas](/revivejs/usage/recursive-schemas.md) for an example).

To create a schema provider, the class or constructor function  must provide a static `getRevivalSchema` function.

{% hint style="warning" %}
When using a class, the `getRevivalSchema` function must be **static.**

```typescript
class Employee {
    static getRevivalSchema(): RevivalSchema<Employee> {
      return {
            type: Employee,
            properties: {
              job: {
                type: Job,
                properties: {
                  props: JobProperties
                }
              },
              friends: {
                items: Employee
              }
            }
          }
    }
}
```

When using functions, the function must expose a `getRevivalSchema` function.

```javascript
function Employee() {
    this.name = ''
}

Employee.getRevivalSchema = function() {
    return {
            type: Employee,
            properties: {
              job: {
                type: Job,
                properties: {
                  props: JobProperties
                }
              },
              friends: {
                items: Employee
              }
            }
    }
}
```

{% endhint %}

This way, when reviving a model using `revive(json, Employee)` the schema provided by the `Employee` class will be used.
