🗜️API Schema Validation
Overview
API schema validation in scriptless automation enables automated testing of API responses against predefined schema templates. It ensures that both the structure and types of values in the response body match expected patterns, helping to maintain robust API behavior.
API Request

Test Template Example
Here’s an example of an API test template:
This test template outlines the steps for performing a POST API call, setting headers, body, and verifying the response against a schema file named putSchema.json
.
Schema Validation
The schema validation works by comparing the actual API response with a predefined schema file located in the automation's test data directory. The schema provides the expected structure and data types for dynamic validation.
Schema Example (putSchema.json)
Column 1
: Maps to a dynamic variable, i.e.,ApiGlobalVariables:name
.id
: Expected to be an integer, indicated by the placeholder@Integer
.
The test will validate the structure and data types against the API response. If the response body matches the expected schema, the test passes.
Validation Flow
Compare JSON Paths: The automation tool will take each key from the expected schema and compare it with the actual response from the API. It validates both the structure and the value types of the fields to ensure consistency between the schema and the response.
Dynamic Value Validation: If the schema contains placeholders such as
@integer
or@string
, the automation validates the data types of the response fields instead of exact values. For example, if the schema specifies"id": "@Integer"
, the test will check that the value forid
in the response is an integer.Direct Value Validation: If the schema contains a static value (e.g.,
"status": "active"
), the automation will directly validate the actual value from the response against the expected value in the schema. This ensures that predefined static values are correct in the API response.Global Variable Validation: If the schema contains dynamic values using
ApiGlobalVariables:<Key>
, the automation will fetch the value from the global variables stored in the automation framework. The value associated with the specified<Key>
will then be validated against the corresponding value in the API response. For example:Schema:
"Column 1": "ApiGlobalVariables:name"
The automation retrieves the value of
name
from the global variables and validates it against theColumn 1
field in the response.
Report Validation: The results of schema validation, whether they pass or fail, are logged and added to the test report. If a schema mismatch is detected (such as a data type error or incorrect value), the report will include detailed information on the differences, helping to identify the source of the error. This information ensures that discrepancies are easily traceable for debugging and fixing.

Handling Missing Schema
If no schema is provided for validation, the automation will log a message to indicate that schema validation was skipped:
Supported Data Types
The following dynamic data types are supported for schema validation:
INTEGER
STRING
FLOAT
BOOLEAN
DATE
ARRAY
JSON_OBJECT
UUID
These types can be used in schema files to indicate the expected format of the API response fields.
Best Practices
Dynamic Variables: Use dynamic variables like
ApiGlobalVariables
to manage state across test cases and ensure flexible validation.Data Type Placeholders: Ensure you replace static values with dynamic placeholders (
@integer
,@string
, etc.) when validating non-static data in API responses.Error Logging: Always ensure that errors during schema validation are captured in the test report for easier debugging.
Conclusion
This schema validation approach streamlines API testing by allowing dynamic type validation and comparison against predefined structures. By incorporating flexible schema rules, you can maintain robust test automation for APIs with varying data responses.
Last updated
Was this helpful?