0
0
Rest APIprogramming~20 mins

OpenAPI Specification (Swagger) in Rest API - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
OpenAPI Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this OpenAPI snippet?
Given this OpenAPI YAML snippet describing a GET endpoint, what is the value of the summary field for the /pets path?
Rest API
paths:
  /pets:
    get:
      summary: List all pets
      responses:
        '200':
          description: A paged array of pets
AFetch all animals
BRetrieve pets list
CList all pets
DGet pets data
Attempts:
2 left
💡 Hint
Look for the summary field under the get method.
🧠 Conceptual
intermediate
1:00remaining
Which HTTP status code is used for a successful resource creation in OpenAPI?
In OpenAPI specifications, which HTTP status code should be used to indicate that a resource was successfully created?
A201
B200
C204
D400
Attempts:
2 left
💡 Hint
Think about the standard HTTP codes for resource creation.
🔧 Debug
advanced
2:00remaining
Identify the error in this OpenAPI parameter definition
What error will this OpenAPI parameter definition cause when validating the spec?
Rest API
parameters:
  - name: userId
    in: query
    required: true
    schema:
      type: integer
      format: uuid
AParameter 'in' must be 'path' for required parameters
BFormat 'uuid' is invalid for type 'integer'
CMissing 'description' field
DSchema type must be 'string' for query parameters
Attempts:
2 left
💡 Hint
Check if the format matches the type.
📝 Syntax
advanced
2:30remaining
Which option correctly defines a request body in OpenAPI 3.0?
Select the correct YAML snippet that defines a JSON request body with a required 'name' string property.
A
requestBody:
  schema:
    type: object
    properties:
      name:
        type: string
    required: [name]
B
requestBody:
  content:
    application/json:
      schema:
        properties:
          name:
            type: string
        required: name
C
requestBody:
  content:
    application/json:
      properties:
        name:
          type: string
      required: [name]
D
requestBody:
  content:
    application/json:
      schema:
        type: object
        properties:
          name:
            type: string
        required: [name]
Attempts:
2 left
💡 Hint
Remember the correct nesting of 'content' and 'schema' in requestBody.
🚀 Application
expert
2:00remaining
How many endpoints are defined in this OpenAPI snippet?
Count the total number of unique HTTP methods defined under the 'paths' object.
Rest API
paths:
  /users:
    get:
      summary: Get users
    post:
      summary: Create user
  /users/{id}:
    get:
      summary: Get user by ID
    put:
      summary: Update user
    delete:
      summary: Delete user
  /status:
    get:
      summary: Get status
A6
B7
C5
D8
Attempts:
2 left
💡 Hint
Count each HTTP method under each path separately.