Swagger

 30 Minutes
 10 Questions


This test is designed to assess an individual's expertise in utilizing and understanding Swagger, now known as the OpenAPI Specification, a framework used for API description and development. The test will cover topics such as the structure of OpenAPI documents, syntax and semantics of the OpenAPI Specification, and best practices in API design. It will also include questions on how to use OpenAPI to document and define various API endpoints, parameters, responses, and security schemes effectively. Additionally, the assessment will explore the candidate?s ability to identify potential issues and improvements within API documentation to enhance its usability, security, and compliance with modern API standards.


Example Question:

Multiple-Choice
Consider the following Swagger/OpenAPI snippet that defines a new API endpoint:

paths:
 /users/{userId}:
  get:
   summary: Gets a user's details
   parameters:
    - in: path
     name: userId
     required: true
     schema:
      type: string
   responses:
    '200':
     description: Successful response
     content:
      application/json:
       schema:
        $ref: '#/components/schemas/User'
components:
 schemas:
  User:
   type: object
   properties:
    name:
     type: string
    age:
     type: integer



What is incorrect or potentially problematic about this API definition?


Answers
1. The userId should be an integer type instead of a string.
2. The API does not handle responses other than a 200 OK.
3. There is no issue; the API definition is perfectly fine.
4. The User schema incorrectly includes the age as an integer.