Given this Postman test script validating a JSON response schema, what will be the test result?
pm.test('Validate user schema', function () { const schema = { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, email: { type: 'string', format: 'email' } }, required: ['id', 'name', 'email'] }; pm.response.to.have.jsonSchema(schema); });
Check what the required array means and how jsonSchema validates types.
The schema requires id, name, and email properties with specified types. The test passes only if all are present and valid. Extra properties do not cause failure by default.
You want to validate that the response is an array of objects, each with a required id (integer) and optional name (string). Which assertion is correct?
Remember the difference between type: 'array' and type: 'object' and where items is used.
Option B correctly defines a schema for an array where each item is an object with required integer id and optional string name. Option B is for a single object, not an array. Option B misuses properties at array level. Option B wrongly expects id as string.
Examine the test script below. The response JSON is {"id": 5, "name": "Alice"}. Why does the test fail?
pm.test('Validate user schema', function () { const schema = { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, email: { type: 'string', format: 'email' } }, required: ['id', 'name', 'email'] }; pm.response.to.have.jsonSchema(schema); });
Check the required properties and compare with the response JSON.
The schema requires 'email' property, but the response JSON does not have it. This causes the validation to fail.
In a Postman JSON schema, what is the effect of setting additionalProperties: false inside an object schema?
Think about how strict the schema is about unexpected properties.
Setting additionalProperties: false means the JSON must not have any properties other than those explicitly defined in properties. Extra properties cause validation failure.
You receive a JSON response with this structure:
{
"user": {
"id": 10,
"roles": ["admin", "editor"]
}
}Which Postman test script correctly validates that user is an object with integer id and an array roles of strings?
Focus on the nested user object and the types inside it.
Option A correctly defines user as an object with required integer id and array of strings roles. Option A wrongly treats user as an array. Option A misses the user nesting. Option A has wrong types for id and roles.