Bird
0
0

What is wrong with this schema fragment?

medium📝 Debug Q7 of 15
Rest API - API Documentation
What is wrong with this schema fragment?
{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "id": { "type": "integer" }
    }
  },
  "required": ["id"]
}
A"type" cannot be "array" here
B"required" should be inside "items", not outside
C"items" must be an array, not an object
D"id" type should be "string"
Step-by-Step Solution
Solution:
  1. Step 1: Understand placement of "required" keyword

    "required" applies to object properties, so it must be inside the object schema.
  2. Step 2: Identify the error location

    Here, "required" is outside "items", which is incorrect.
  3. Final Answer:

    "required" should be inside "items", not outside -> Option B
  4. Quick Check:

    Required properties belong inside object schema [OK]
Quick Trick: "required" must be inside object schema, not array schema [OK]
Common Mistakes:
MISTAKES
  • Placing "required" at wrong schema level
  • Confusing array and object schema keywords
  • Assuming "required" applies to arrays

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes