跳到主要内容

Create Schema

提示

In data models, interface input parameter definitions, or interface response expectation definitions, data structures are often used to visually define jsonschema for designing interfaces.

Create Data Model

New Model Entry

image.png

提示
  • Model Name: Required and must be unique, usually composed of letters, numbers, and underscores.
  • Alias: Usually a name for easier searching and viewing.
  • Directory: Models can be categorized for management.
  • Remarks: Used to describe the purpose of the model.

image.png

Edit Data Model

You can visually edit the schema with the following options:

  • Add or remove nodes
  • You can modify field types
  • Set whether a field is required or can be left empty
  • Define the mock type of a field
  • Rearrange the order of the fields

image.png

Intelligent Import

For existing structure files, you can quickly generate the structure of the JSON Schema through intelligent import, avoiding tedious manual input. Supported formats include JSON, XML, JSON Schema, and MySQL DDL.

image.png

Json Example

{
"userInfo_get_response": {
"result": {
"model": {
"open_id": "qwertyuiuduiasd",
"avatar": "avatar url",
"nick": "snsNick"
},
"err_message": "err_message",
"err_code": "err_code",
"success": false
}
}
}

image.png

Xml Example

<error_response>
<code>50</code>
<msg>Remote service error</msg>
<sub_code>isv.invalid-parameter</sub_code>
<sub_msg>Illegal parameter</sub_msg>
</error_response>

image.png

Jsonschema Example

{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Person Schema",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the person.",
"minLength": 2
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
},
"email": {
"type": "string",
"description": "The email address of the person.",
"format": "email"
}
},
"required": ["name", "age", "email"]
}

image.png

Mysql DDL Example

CREATE TABLE orders (
order_id INT AUTO_INCREMENT PRIMARY KEY,
customer_id INT NOT NULL,
order_date DATE NOT NULL,
total_amount DECIMAL(10, 2) NOT NULL,
status VARCHAR(50) NOT NULL,
FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);

image.png

Advanced Field Settings

In addition to basic settings, such as whether a field is required or allows null values, certain field types support advanced options. You can also set field properties directly through source code editing. For example, for arrays, you can specify the number of items and other properties.

image.png

String

image.png

Number

image.png

Array

image.png

Object

image.png

Boolean

image.png

Integer

image.png

Oneof, Anyof, Allof

image.png

Reference Data Model

When adding child nodes, you can quickly reference existing data models.

image.png

Select an existing schema. image.png

The schema will automatically follow changes in the original data source. If you do not want this synchronization, you can disassociate the reference.

image.png

Preview

Preview the json content generated by the data structure.

image.png

Raw Editing

Design data structures by editing jsonschema source code.

image.png