openapi: 3.1.0
info:
  title: Mock API Service
  version: "1.0"
  description: APIs Spec for an API mocking servce
servers:
  - url: https://reqres.in/api/
paths:
  /users:
    get:
      description: List of users (paginated)
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            examples: 
              - 1
              - 2
        - name: delay
          in: query
          description: for simulating response delay. Do not provide any value for page parameter(0 indicates no delay)
          examples:
            noDelay:
              summary: No Delay
              value: 0
            someDelay:
              summary: little delay
              value: 2
          schema:
            type: integer
            minimum: 0
            maximum: 10
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: object
                description: Description of **User** object
                properties:
                  page:
                    description: Current Page number
                    type: integer
                  per_page:
                    description: Number of records per page
                    type: integer
                  total:
                    description: Total number of records
                    type: integer
                  total_pages:
                    type: integer
                  data:
                    type: array
                    description: List of users
                    items:
                      $ref: '#/components/schemas/user'
                  support:
                    $ref: '#/components/schemas/support'
    post:
      tags:
        - Additions
      description: Create a user
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/userInput"
      responses:
        201:
          description: User creation response
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/userInput'
                  - $ref: '#/components/schemas/createUserResponse'

  /users/{userId}:
    get:
      description: Get a Single User
      parameters:
        - in: path
          name: userId
          schema:
            type: integer
            example: 3
          required: true
          description: Numeric ID of the user to get
      responses:
        200:
          description: Response when a user is found
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/user'
                  support:
                    $ref: '#/components/schemas/support'
        404:
          description: User Not found

components:
  schemas:
    user:
      type: object
      properties:
        id:
          description: User ID
          type: integer
        email:
          description: User Email
          type: string
        first_name:
          description: First Name
          type: string
        last_name:
          description: Last Name
          type: string
        avatar:
          description: Avatar URL
          type: string
    support:
      type: object
      properties:
        url:
          description: Support URL
          type: string
        text:
          description: Support URL - Description
          type: string
    userInput:
      type: object
      description: user object with `name` and `job` properties
      properties:
        name:
          description: User Name
          type: string
        job:
          description: Job
          type: string
    createUserResponse:
      type: object
      properties:
        id:
          type: integer
        createdAt:
          type: string

