0
0
Rest APIprogramming~10 mins

Schema definitions in Rest API - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a simple JSON schema with a required string property called 'name'.

Rest API
{
  "type": "object",
  "properties": {
    "name": { "type": "[1]" }
  },
  "required": ["name"]
}
Drag options to blanks, or click blank then click option'
Ainteger
Barray
Cboolean
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'integer' or 'boolean' instead of 'string' for text properties.
2fill in blank
medium

Complete the code to add an optional integer property called 'age' to the schema.

Rest API
{
  "type": "object",
  "properties": {
    "age": { "type": "[1]" }
  }
}
Drag options to blanks, or click blank then click option'
Anull
Binteger
Cboolean
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'string' type for numeric properties.
3fill in blank
hard

Fix the error in the schema by completing the type for the 'emails' property which should be an array of strings.

Rest API
{
  "type": "object",
  "properties": {
    "emails": {
      "type": "[1]",
      "items": { "type": "string" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aboolean
Bobject
Carray
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'object' or 'string' instead of 'array' for list properties.
4fill in blank
hard

Fill in the blank to define a property 'status' that can only be one of the specified string values.

Rest API
{
  "type": "object",
  "properties": {
    "status": {
      "type": "[1]",
      "enum": ["active", "inactive", "pending"]
    }
  }
}
Drag options to blanks, or click blank then click option'
Astring
Binteger
Carray
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'array' or 'integer' type for enum string values.
5fill in blank
hard

Fill all three blanks to define a schema with a required 'id' (integer), optional 'tags' (array of strings), and a 'published' boolean.

Rest API
{
  "type": "object",
  "properties": {
    "id": { "type": "[1]" },
    "tags": {
      "type": "[2]",
      "items": { "type": "string" }
    },
    "published": { "type": "[3]" }
  },
  "required": ["id"]
}
Drag options to blanks, or click blank then click option'
Ainteger
Barray
Cboolean
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing types like using 'string' for id or 'integer' for published.