In OpenAPI 3.0, a schema is used to define the data structure of an API's request or response payload. It is a way to describe the expected format and data types of the information being transmitted.
A schema is defined using JSON Schema, which is a standard for describing the structure and validation rules for JSON data. The OpenAPI 3.0 specification includes an extended subset of JSON Schema that provides additional features specific to API documentation, such as the ability to describe response codes and headers.
The schema definition can be included in an OpenAPI document in the components section, where it can be referenced by other parts of the document. A schema can be defined for a request or response body, a request or response header, or a parameter.
Some of the properties that can be defined in a schema include:
type: The data type of the property, such as string, integer, boolean, or array.
format: A format for the data type, such as date-time for a timestamp or email for an email address.
properties: A list of properties and their corresponding schemas for an object.
items: The schema for each item in an array.
required: A list of required properties for an object.
enum: A list of possible values for a property.
By defining schemas in OpenAPI 3.0, API developers can ensure that their APIs are well-documented and that clients can easily understand the expected format and data types of the information being transmitted.
APIGit has no built-in AI: the assistant in this post is an external one, such as ChatGPT, and APIGit is where you bring the result.
Navigate to your repository and choose one spec file, in the default view mode, click on the ✏️ icon located in the bottom left-hand corner. In the editor, you can switch between the Form view and the Code view. A schema such as User, with its six fields, is simple but still takes time to write by hand. An external AI assistant can help simplify the process even further.

You only need to generate a sample data for your object.
{
"id": 10,
"username": "theUser",
"firstName": "John",
"lastName": "James",
"email": "john@email.com",
"password": "12345",
"phone": "12345",
"userStatus": 1
}
And then ask ChatGPT to give you the schema data.
Schemas generated by ChatGPT
What you will get is as below.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "User",
"type": "object",
"properties": {
"id": {
"type": "integer",
"description": "The ID of the user",
"example": 10
},
"username": {
"type": "string",
"description": "The username of the user",
"example": "theUser"
},
"firstName": {
"type": "string",
"description": "The first name of the user",
"example": "John"
},
"lastName": {
"type": "string",
"description": "The last name of the user",
"example": "James"
},
"email": {
"type": "string",
"format": "email",
"description": "The email address of the user",
"example": "john@email.com"
},
"password": {
"type": "string",
"description": "The password of the user",
"example": "12345"
},
"phone": {
"type": "string",
"description": "The phone number of the user",
"example": "12345"
},
"userStatus": {
"type": "integer",
"description": "The status of the user",
"example": 1
}
},
"required": ["id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"]
}
There are two ways to bring the result into your repository.
To keep it as a JSON Schema file of its own:
.json file on your computer.+ sign above the file list.Json Schema Spec, then import Json Schema spec.To add it to an OpenAPI spec file:
Code view.type, properties and required parts under components > schemas > User, leaving out the $schema line.Form view to check the result.An AI assistant can make mistakes, so check its work before you commit it.
This article explains the different components of a REST API by following a request from end to end. An API client is responsible for assembling and directing an API request to the API server. An API request to a REST API consists of an endpoint, method, parameters, request headers, and a request body. The API server handles authentication, validates input data, retrieves or manipulates data from a database, and returns the appropriate response to the client. An API response typically includes a status code, response headers, and a body. API status codes are used to provide information to the client about the outcome of the request and to help the client understand how to proceed. Response headers and bodies provide additional information and data about the response.
OpenAPI component reuse promotes consistency, reduces duplication, and simplifies maintenance by allowing developers to define schemas, parameters, and responses once and reference them throughout API specifications.
OpenAPI's oneOf, allOf, and anyOf keywords provide powerful schema composition capabilities, allowing for flexible API design through inheritance, polymorphism, and conditional validation.
Create a free workspace, add an OpenAPI file and publish your first API document and mock server in minutes.