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.
The actual status code is not listed explicitly in the spec, but the spec defines a default response that was used as the fallback contract. Atrahasis flags this so you notice when a code you expected to be explicit is silently falling through to the catch-all.
The actual status code is not in the spec's expected responses, and the spec does not define a default response either. Atrahasis cannot validate the body against anything in this case and surfaces a warning instead of an error — the response might still be valid, you just have no contract to check it against.
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 | On Mismatch |
|---|---|---|
| Status Code | Response status matches one of the defined expected responses (or the default response as a fallback). | Warning |
| Content-Type | Actual response Content-Type is one of the media types declared for the matched status code. | Error — the entire contract check fails with an error state, body schema validation is not attempted. |
| Body Schema | Response body structure matches the JSON Schema (for JSON responses). Only runs after the Status Code and Content-Type checks pass. | Error |
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.