0
0
Rest APIprogramming~10 mins

OpenAPI Specification (Swagger) 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 specify the OpenAPI version in the specification.

Rest API
{
  "openapi": "[1]",
  "info": {
    "title": "Sample API",
    "version": "1.0.0"
  }
}
Drag options to blanks, or click blank then click option'
A1.0.0
B3.0.0
C2.0.0
D4.0.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using Swagger 2.0 version number instead of OpenAPI 3.0.0
Putting the version number in the wrong field
2fill in blank
medium

Complete the code to define the HTTP method for the API path.

Rest API
"paths": {
  "/users": {
    "[1]": {
      "summary": "Get list of users",
      "responses": {
        "200": {
          "description": "A JSON array of user names"
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aget
Bpost
Cput
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET for retrieving data
Capitalizing the HTTP method (should be lowercase)
3fill in blank
hard

Fix the error in the response content type definition.

Rest API
"responses": {
  "200": {
    "description": "Successful response",
    "content": {
      "[1]": {
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aapplication/json
Bapplication/xml
Ctext/plain
Dimage/png
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text/plain' instead of 'application/json'
Using image content types for JSON data
4fill in blank
hard

Fill both blanks to define a parameter for a path variable named 'userId' of type string.

Rest API
"parameters": [
  {
    "name": "[1]",
    "in": "[2]",
    "required": true,
    "schema": {
      "type": "string"
    }
  }
]
Drag options to blanks, or click blank then click option'
AuserId
Bquery
Cpath
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'query' instead of 'path' for path parameters
Using a different name than the path variable
5fill in blank
hard

Fill all three blanks to define a schema property named 'age' of type integer with a minimum value of 0.

Rest API
"properties": {
  "[1]": {
    "type": "[2]",
    "minimum": [3]
  }
}
Drag options to blanks, or click blank then click option'
Aage
Bstring
C0
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'string' type for age
Not setting minimum value or setting it as a string