openapi: 3.0.2
info:
  title: Answers Collector
  description: This is an Answers Collector Server. It can receive and provide answers that students create during bootcamps/workshops.
  version: v1
  contact:
    name: Ivan
  license:
    name: MIT
servers:
  - url: 'http://35.228.56.251:8000'
    description: Fake for now
tags:
  - name: answer
    description: For adding answers
  - name: answers
    description: Getting or updating answers
paths:
  /answer:
    post:
      tags:
        - answer
      summary: Add a new answer to the collection
      operationId: addAnswer
      requestBody:
        description: Answer object that needs to be added to the DB
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Answer'
        required: true
      responses:
        '200':
          description: Success response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    example: xdvwwJduoAfaXnhUXKDx
        '400':
          description: 'Invalid input, or some fields are missing'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: exerciseId is required
        '405':
          description: Unsupported method
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Bad request. Only POST method is supported
      x-codegen-request-body-name: body
      description: Add answer to DB
  /answers:
    get:
      tags:
        - answers
      summary: 'get all answers, or specific answer from the DB'
      description: "If fetching for 1 answer by id - will return object. In all other scenarios will return array of object(s). 'userId' & 'exerciseId' queries can be combined to get all answers for specific exercise submitted by specific user."
      parameters:
        - name: id
          in: query
          description: "Get answer by it's id. Example: /answers?id=fgdfg345dfdfs"
          schema:
            type: string
        - name: userId
          in: query
          description: 'Get ALL answers submitted by user. Example: /answers?userId=fgdfg3ghvghv'
          schema:
            type: string
        - name: exerciseId
          in: query
          description: 'Get ALL answers submitted for exercise. Example: /answers?exerciseId=fgdfsfg3gghv'
          schema:
            type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/DBAnswer'
        '404':
          description: Document not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Unable to find the document
        '405':
          description: Unsupported method
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Bad request. Only GET/PATCH are supported
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Error getting requested document(s)
                  err:
                    type: object
                    properties: {}
                    example: {}
      operationId: receiveAnswers
  '/answers/{id}':
    get:
      summary: Your GET endpoint
      tags: []
      parameters:
        - schema:
            type: string
          name: id
          in: path
          required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties: {}
      operationId: 'get-answers-id'
      description: "Catch specific answer from id bro"
components:
  schemas:
    Answer:
      required:
        - answer
        - exerciseId
        - userId
      type: object
      properties:
        answer:
          type: string
        userId:
          type: string
        exerciseId:
          type: string
    DBAnswer:
      type: object
      properties:
        answer:
          type: string
        normalizedAnswer:
          type: string
        userId:
          type: string
        exerciseId:
          type: string
        id:
          type: string
        created:
          type: integer
        hash:
          type: string
