> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Shared Data Model

> You can create shared schema models that define data types in message content. You can use reusable schema definitions, model inheritance, and shared components with JSON Schema references. You can import and use the models you create within the Spec Design Editor.

## Shared Data Model Concept

Shared Data Model enables you to create reusable schema definitions in API Designer's spec first approach. By creating shared schema models that define data types in message content, you can use model inheritance and shared components with JSON Schema references. Created models can be imported and used within the Spec Design Editor.

<CardGroup cols={2}>
  <Card title="Reusable Schemas" icon="repeat">
    Shared schema models are created

    The same data structure can be used in multiple APIs.
  </Card>

  <Card title="Model Inheritance" icon="sitemap">
    Model inheritance and references

    Model relationships with JSON Schema references.
  </Card>

  <Card title="Shared Components" icon="share-nodes">
    Shared components are used

    Common data types are managed centrally.
  </Card>

  <Card title="Spec Design Editor Integration" icon="pencil">
    Usage in Spec Design Editor

    Created models can be imported into API Specs.
  </Card>
</CardGroup>

## Shared Data Model Features

### Schema Design

Schema design and property management in shared data models:

<AccordionGroup>
  <Accordion title="Data Type Definitions">
    * Basic data types (string, integer, number, boolean)
    * Complex data types (object, array)
    * Enum values
    * Format definitions
  </Accordion>

  <Accordion title="Schema Properties">
    * Property definitions
    * Required fields
    * Read-only and write-only behaviors
    * Validation rules
  </Accordion>

  <Accordion title="Model References">
    * Model references with \$ref
    * Model inheritance
    * Shared components
    * JSON Schema references
  </Accordion>
</AccordionGroup>

### Data Model Management

Creation and management of shared data models:

<CardGroup cols={2}>
  <Card title="Model Creation" icon="plus-circle">
    New shared data models are created

    * Defining name and description
    * Creating schema structure
    * Adding example values
  </Card>

  <Card title="Schema Properties" icon="list">
    Properties are defined within the schema

    * Adding and editing properties
    * Determining type and format
    * Validation rules
  </Card>

  <Card title="Model Import" icon="download">
    Models are used in Spec Design Editor

    * Model reference within Spec
    * Shared component usage
    * Reusability
  </Card>
</CardGroup>

## Creating Shared Data Model

A new Data Model can be created by clicking the **New (Create)** button in the upper right of the list interface.

<img src="https://mintcdn.com/apinizer/Ku5drz7BLIhaC8K7/images/develop/data-models/data-model-1.png?fit=max&auto=format&n=Ku5drz7BLIhaC8K7&q=85&s=fe439408f0aedfdb371dd9bff2b4866b" alt="List interface" style={{maxWidth: '1000px', width: '100%', height: 'auto'}} width="1335" height="241" data-path="images/develop/data-models/data-model-1.png" />

The Shared Data Model creation settings are shown in the following image:

<img src="https://mintcdn.com/apinizer/Ku5drz7BLIhaC8K7/images/develop/data-models/data-model-2.png?fit=max&auto=format&n=Ku5drz7BLIhaC8K7&q=85&s=30e6b824790796ff6de32dc36ba8a74a" alt="Shared Data Model creation settings" style={{maxWidth: '1000px', width: '100%', height: 'auto'}} width="1332" height="882" data-path="images/develop/data-models/data-model-2.png" />

The fields used for shared data model creation configuration are shown in the table below.

| Field                          | Description                                                                                                 |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| **Name**                       | The name information of the data model.                                                                     |
| **Description**                | Description related to the data model.                                                                      |
| **Schema** <em>(Schema)</em>   | Properties and fields to be included in the data and properties such as type, pattern, min-max are managed. |
| **Example** <em>(Example)</em> | An example of the data type can be created.                                                                 |

## Adding Schema Property

You can define the structure of your data model by adding properties within the schema.

The Schema Property addition settings are shown in the following image:

<img src="https://mintcdn.com/apinizer/Ku5drz7BLIhaC8K7/images/develop/data-models/data-model-3.png?fit=max&auto=format&n=Ku5drz7BLIhaC8K7&q=85&s=e0d5d91cc06aa902995bceb58afd3023" alt="Schema Property addition settings" style={{maxWidth: '755px', width: '100%', height: 'auto'}} width="755" height="522" data-path="images/develop/data-models/data-model-3.png" />

The fields used for Schema Property creation configuration are shown in the table below.

| Field                                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**                                             | The name information of the schema.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| **Description**                                      | Description can be made about the schema.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Type**                                             | Field where the type of the schema is specified.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **Format** <em>(Format)</em>                         | A field that is active according to the selected type. There are formats that can be selected for some types:<br /><br />**integer**<br />- int32: Signed 32-bit integers (commonly used integer type).<br />- int64: Signed 64-bit integers (long type).<br /><br />**number**<br />- float: Decimal numbers (6 digits).<br />- double: Decimal numbers (14 digits).<br /><br />**string**<br />- byte: Base64 encoded characters. For example, **U3dhZ2dlciByb2Nrcw==**<br />- binary: Binary data used to define files<br />- date: Full date representation. For example, **2017-07-21**<br />- date-time: Date-time representation. For example, **2017-07-21T17:32:28Z**<br />- password: Used to mask input. |
| **\$Ref Target**                                     | If \$ref is selected from the type field, this field becomes active.<br /><br />A reference to another data model can be given.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| **Property is** <em>(Property is)</em>               | Specifies whether the model's usage is required.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| **Behaviour** <em>(Behaviour)</em>                   | Determines the read-only/write-only information of the schema.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| **Integer Properties** <em>(Integer Properties)</em> | If Integer is selected as type, these fields become active:<br />- Minimum: To determine the smallest of the values that can be entered.<br />- Maximum: To determine the largest of the values that can be entered.<br />- MultipleOf: To determine this if the values to be entered are desired to be multiples of a number.                                                                                                                                                                                                                                                                                                                                                                                      |
| **String Properties** <em>(String Properties)</em>   | If String is selected as type, these fields become active:<br />- Pattern <em>(Pattern)</em>: Allows you to define a regular expression template for the string value. Only values matching this template will be accepted.<br />- Min Length <em>(Min Length)</em>: To determine the minimum length of values that can be entered.<br />- Max Length <em>(Max Length)</em>: To determine the maximum length of values that can be entered.                                                                                                                                                                                                                                                                         |
| **Enum Values** <em>(Enum Values)</em>               | If Enum is selected as type, this field becomes active.<br /><br />Field where possible values of the model are entered.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| **Example** <em>(Example)</em>                       | An example describing the schema can be given.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

## Shared Data Model Usage Scenarios

Usage scenarios of shared data models in spec first approach:

<CardGroup cols={2}>
  <Card title="Creating Reusable Schema" icon="repeat">
    1. Creating shared data model
    2. Defining schema properties
    3. Importing model in Spec Design Editor
    4. Using in multiple API Specs
    5. Central update and management
  </Card>

  <Card title="Model Inheritance and References" icon="sitemap">
    1. Creating basic data models
    2. Establishing relationships with model references
    3. Model inheritance with \$ref
    4. Using shared components
    5. Consistent data structures
  </Card>
</CardGroup>

## Relationship Between Shared Data Model and Spec Design Editor

Shared Data Models work integrated with the Spec Design Editor. Workflow:

```
Shared Data Models
   │
   │ Schema Definitions
   │ Model References
   │
   ▼
Spec Design Editor
   │
   │ Model Import
   │ $ref References
   │
   ▼
API Spec
   │
   │ Shared Components
   │
   ▼
API Proxy
```

<CardGroup cols={4}>
  <Card title="1. Model Creation" icon="plus-circle">
    Model is created on Shared Data Models page

    Schema properties and structure are defined.
  </Card>

  <Card title="2. Model Definition" icon="pencil">
    Schema properties and validation rules are determined

    Properties, types, and formats are defined.
  </Card>

  <Card title="3. Usage in Spec" icon="file-code">
    Model is imported in Spec Design Editor

    Model is used with \$ref references.
  </Card>

  <Card title="4. Reuse" icon="repeat">
    Model can be used in multiple API Specs

    Central management and consistency are ensured.
  </Card>
</CardGroup>

<Info>
  This integration between Shared Data Models and Spec Design Editor enables you to create consistent and centrally managed data structures with reusable schema definitions in spec first approach. Models are created once and can be used in multiple API Specs.
</Info>

## Shared Data Model Advantages

Advantages provided by reusable schema definitions:

<CardGroup cols={2}>
  <Card title="Reusability" icon="repeat">
    * Same schema is used in multiple APIs
    * Central schema management
    * Consistent data structures
  </Card>

  <Card title="Model Inheritance" icon="sitemap">
    * Model references with \$ref
    * Model relationships and inheritance
    * Shared components
  </Card>

  <Card title="Central Management" icon="database">
    * Schema update from a single place
    * Changes reflected to all APIs
    * Version control
  </Card>

  <Card title="Standard Compliance" icon="check-circle">
    * Compliance with JSON Schema standards
    * OpenAPI/Swagger compatibility
    * Tool support
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Spec Design Editor" icon="pencil" href="/en/develop/api-design/spec-designer">
    Spec Design Editor details
  </Card>

  <Card title="API Proxy Creation" icon="network-wired" href="/en/develop/api-proxy-creation/api-creator-db-api-creation">
    API Proxy creation
  </Card>

  <Card title="JSON Schema Validation" icon="shield-check" href="/en/develop/policies/json-schema-validation">
    JSON schema validation policy
  </Card>

  <Card title="API Designer" icon="wand-magic-sparkles" href="/en/concepts/core-components/api-designer">
    Learn about the API Designer component
  </Card>
</CardGroup>
