Contract
The Contract tab validates API responses against a JSON Schema. This ensures the server returns data in the expected format, catching breaking changes and bugs early. You can either define a custom schema for standalone requests or use schemas from your OpenAPI project definitions.
Validation Modes
The Contract tab operates in two modes depending on the request source:
Custom Schema Mode
For standalone requests (not from a project). You manually define a JSON Schema to validate responses.
Project Mode
For requests from an OpenAPI project. Uses expected responses defined in your project's endpoint specification.
Custom Schema Mode
When working with standalone requests (not from a project), you can add a custom JSON Schema to validate responses:
Initial State
Contract Validation
Add a custom JSON Schema to validate responses, or save this request to a project for full contract validation.
Add SchemaSchema Editor
Click "Add Schema" to open the schema editor. You can paste JSON Schema directly or upload a .json file:
Example Schema
{
"type": "object",
"required": ["id", "name", "email"],
"properties": {
"id": {
"type": "integer",
"minimum": 1
},
"name": {
"type": "string",
"minLength": 1
},
"email": {
"type": "string",
"format": "email"
},
"createdAt": {
"type": "string",
"format": "date-time"
}
}
}.json file containing your schema. Maximum file size is 1 MB.Project Mode
When a request is opened from an OpenAPI project, the Contract tab uses the expected responses defined in your endpoint specification:
Expected Responses
Shows all responses defined in the OpenAPI spec for this endpoint:
Actual Response
Shows the current response summary for comparison:
Validation Results
The validation result shows whether the response matches the expected schema:
Response status code, content type, and body all match the expected schema.
Status code wasn't explicitly defined but matched the "default" response in the spec.
Response body doesn't match the expected schema structure.
Schema Validation Errors
When validation fails, detailed errors are shown to help identify the mismatch:
Validation Errors
/users/0/emailmust match format "email"email format"not-an-email"/users/0/agemust be integerintegerstring... and 1 more error
/users/0/email) shows exactly where in the response the error occurred. Use this to quickly locate the problematic data.Content Type Validation
In addition to schema validation, the Contract tab also checks:
| Check | What's Validated |
|---|---|
| Status Code | Response status matches one of the defined expected responses |
| Content-Type | Response content type matches the expected media types |
| Body Schema | Response body structure matches the JSON Schema (for JSON responses) |
Schema References
In Project Mode, schemas can be defined in two ways:
Schema is defined directly in the endpoint's response specification.
Schema references a shared component defined in the project's components/schemas section.
$ref references to their full schema definitions, including nested references within schemas.