0
0
Postmantesting~20 mins

JSON Schema validation in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
JSON Schema Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the result of this JSON Schema validation?
Given this JSON Schema and JSON data, what will Postman report after validation?
Postman
{
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "age": {"type": "integer", "minimum": 18}
  },
  "required": ["name", "age"]
}

Data:
{
  "name": "Alice",
  "age": 17
}
AValidation fails because 'age' is less than the minimum 18.
BValidation fails because 'age' is not an integer.
CValidation passes successfully.
DValidation fails because 'name' is missing.
Attempts:
2 left
💡 Hint
Check the 'minimum' constraint for the 'age' property.
assertion
intermediate
2:00remaining
Which assertion correctly validates the JSON response schema in Postman?
You want to assert that the response JSON has a 'status' string and an 'items' array. Which Postman test script assertion is correct?
Postman
const schema = {
  type: 'object',
  properties: {
    status: { type: 'string' },
    items: { type: 'array' }
  },
  required: ['status', 'items']
};
Apm.test('Schema is valid', () => pm.response.to.have.jsonSchema('schema'));
Bpm.test('Schema is valid', () => pm.response.to.have.jsonSchema(schema));
Cpm.test('Schema is valid', () => pm.response.to.have.jsonSchema({}));
Dpm.test('Schema is valid', () => pm.response.to.have.jsonSchema());
Attempts:
2 left
💡 Hint
The schema variable must be passed as an object, not a string or empty.
🔧 Debug
advanced
2:00remaining
Why does this JSON Schema validation fail unexpectedly?
This schema expects a property 'email' as a string with format 'email'. The data has a valid email string. Why does validation fail?
Postman
{
  "type": "object",
  "properties": {
    "email": {"type": "string", "format": "email"}
  },
  "required": ["email"]
}

Data:
{
  "email": "user@example.com"
}
AThe 'required' array is missing the 'email' property.
BThe 'email' string is invalid because it lacks a domain.
CThe 'format' keyword is not supported by Postman's JSON Schema validator, causing failure.
DThe 'type' of 'email' should be 'email' instead of 'string'.
Attempts:
2 left
💡 Hint
Check Postman's support for JSON Schema format validation.
🧠 Conceptual
advanced
2:00remaining
What is the main purpose of JSON Schema validation in API testing?
Choose the best explanation for why testers use JSON Schema validation in Postman or similar tools.
ATo check that the API response structure and data types match expected definitions.
BTo verify the API response time is within limits.
CTo ensure the API server is running without errors.
DTo test the API authentication mechanism.
Attempts:
2 left
💡 Hint
Think about what JSON Schema describes.
framework
expert
3:00remaining
How to implement JSON Schema validation in a Postman test script for nested objects?
Given this schema with nested objects, which Postman test script correctly validates the response?
Postman
const schema = {
  type: 'object',
  properties: {
    user: {
      type: 'object',
      properties: {
        id: { type: 'integer' },
        profile: {
          type: 'object',
          properties: {
            email: { type: 'string' },
            active: { type: 'boolean' }
          },
          required: ['email', 'active']
        }
      },
      required: ['id', 'profile']
    }
  },
  required: ['user']
};
Apm.test('Nested schema validation', () => pm.response.to.have.jsonSchema(schema.required));
Bpm.test('Nested schema validation', () => pm.response.to.have.jsonSchema(schema.user));
Cpm.test('Nested schema validation', () => pm.response.to.have.jsonSchema(schema.properties.user));
Dpm.test('Nested schema validation', () => pm.response.to.have.jsonSchema(schema));
Attempts:
2 left
💡 Hint
Pass the full schema object to the assertion, not parts of it.