The 'Ensure JSON Schema' assertion is not throwing any error when mandatory fields are missing in the JSON request.
This assertion is failing only when request structure is incorrect.
Release : 10.4, 10.5
Component : CA Service Virtualization
Entries in the schema that are mandatory can be configured with the required keyword.
Here is an example schema configuration and a payload that fails:
schema:
{ "type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "number" }
},
"required": ["name", "age"]
}
payload:
{ "name": "john"
}
Assertion result:
Assertion name: Ensure JSON Schema checks for: true is of type: Ensure JSON Schema.
Test Summary
JSON schema validation failed. Found 1 issue.
Issue: object has missing required properties (["age"])
level: error
schema: {"loadingURI":"#","pointer":""}
instance: {"pointer":""}
domain: validation
keyword: required
required: ["age","name"]
missing: ["age"]
For more detail regarding JSON schema's, review:
https://json-schema.org/understanding-json-schema/