World Conquest Chronicles

World Conquest Chronicles

go-exercises-backend, v1.5.2

Back-end of the service for solving programming exercises.

Describe the RabbitMQ API and the web API.

Change Log

  • describe the RabbitMQ API in the AsyncAPI format;
  • describe the web API in the Swagger format.

API Description

RabbitMQ API description in the AsyncAPI format:

asyncapi: 2.1.0
info:
  title: go-exercises-backend API
  version: 1.5.2
  license:
    name: MIT
channels:
  solution_queue:
    subscribe:
      message:
        $ref: "#/components/messages/Solution"
  solution_result_queue:
    publish:
      message:
        $ref: "#/components/messages/SolutionResult"
components:
  messages:
    Solution:
      contentType: application/json
      payload:
        $ref: "#/components/schemas/entities.Solution"
    SolutionResult:
      contentType: application/json
      payload:
        $ref: "#/components/schemas/entities.SolutionResult"
  schemas:
    entities.Solution:
      type: object
      properties:
        ID:
          type: integer
        Task:
          $ref: "#/components/schemas/entities.Task"
        Code:
          type: string
    entities.Task:
      type: object
      properties:
        TestCases:
          type: array
          items:
            $ref: "#/components/schemas/testrunner.TestCase"
    testrunner.TestCase:
      type: object
      properties:
        Input:
          type: string
        ExpectedOutput:
          type: string
    entities.SolutionResult:
      type: object
      properties:
        ID:
          type: integer
        IsCorrect:
          type: boolean
        Result:
          oneOf:
            - type: object
            - $ref: "#/components/schemas/runners.ErrFailedCompiling"
            - $ref: "#/components/schemas/testrunner.ErrFailedRunning"
            - $ref: "#/components/schemas/testrunner.ErrUnexpectedOutput"
    runners.ErrFailedCompiling:
      type: object
      properties:
        ErrMessage:
          type: string
    testrunner.ErrFailedRunning:
      type: object
      properties:
        Input:
          type: string
        ExpectedOutput:
          type: string
        ErrMessage:
          type: string
    testrunner.ErrUnexpectedOutput:
      type: object
      properties:
        Input:
          type: string
        ExpectedOutput:
          type: string
        ActualOutput:
          type: string

Web API description in the Swagger format:

swagger: "2.0"
info:
  title: go-exercises-backend API
  version: 1.5.2
  license:
    name: MIT
host: localhost:8080
basePath: /api/v1
paths:
  /solutions/{id}:
    get:
      parameters:
        - description: solution ID
          in: path
          minimum: 1
          name: id
          required: true
          type: integer
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/entities.Solution"
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Solution
  /solutions/format:
    post:
      consumes:
        - application/json
      parameters:
        - description: solution data
          in: body
          name: data
          required: true
          schema:
            $ref: "#/definitions/entities.Solution"
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/entities.Solution"
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Solution
  /tasks/:
    get:
      parameters:
        - description: page size
          in: query
          minimum: 1
          name: pageSize
          required: true
          type: integer
        - description: page
          in: query
          minimum: 1
          name: page
          required: true
          type: integer
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/entities.TaskGroup"
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Task
    post:
      consumes:
        - application/json
      parameters:
        - description: task data
          in: body
          name: data
          required: true
          schema:
            $ref: "#/definitions/entities.Task"
      produces:
        - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: "#/definitions/entities.Task"
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Task
  /tasks/{id}:
    delete:
      parameters:
        - description: task ID
          in: path
          minimum: 1
          name: id
          required: true
          type: integer
      produces:
        - text/plain
      responses:
        "204":
          description: No Content
          schema:
            type: string
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Task
    get:
      parameters:
        - description: task ID
          in: path
          minimum: 1
          name: id
          required: true
          type: integer
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/entities.Task"
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Task
    put:
      consumes:
        - application/json
      parameters:
        - description: task ID
          in: path
          minimum: 1
          name: id
          required: true
          type: integer
        - description: task data
          in: body
          name: data
          required: true
          schema:
            $ref: "#/definitions/entities.Task"
      produces:
        - text/plain
      responses:
        "204":
          description: No Content
          schema:
            type: string
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Task
  /tasks/{taskID}/solutions/:
    get:
      parameters:
        - description: task ID
          in: path
          minimum: 1
          name: taskID
          required: true
          type: integer
        - description: page size
          in: query
          minimum: 1
          name: pageSize
          required: true
          type: integer
        - description: page
          in: query
          minimum: 1
          name: page
          required: true
          type: integer
      produces:
        - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: "#/definitions/entities.SolutionGroup"
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Solution
    post:
      consumes:
        - application/json
      parameters:
        - description: task ID
          in: path
          minimum: 1
          name: taskID
          required: true
          type: integer
        - description: solution data
          in: body
          name: data
          required: true
          schema:
            $ref: "#/definitions/entities.Solution"
      produces:
        - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: "#/definitions/entities.Solution"
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      security:
        - JWTAuthorization: []
      tags:
        - Solution
  /tokens/:
    post:
      consumes:
        - application/json
      parameters:
        - description: user data
          in: body
          name: data
          required: true
          schema:
            $ref: "#/definitions/entities.User"
      produces:
        - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: "#/definitions/entities.Credentials"
        "400":
          description: Bad Request
          schema:
            type: string
        "401":
          description: Unauthorized
          schema:
            type: string
        "403":
          description: Forbidden
          schema:
            type: string
        "404":
          description: Not Found
          schema:
            type: string
        "500":
          description: Internal Server Error
          schema:
            type: string
      tags:
        - Token
definitions:
  gorm.DeletedAt:
    type: object
    properties:
      Time:
        type: string
      Valid:
        type: boolean
        description: Valid is true if Time is not NULL
  entities.Task:
    type: object
    properties:
      ID:
        type: integer
      CreatedAt:
        type: string
      UpdatedAt:
        type: string
      DeletedAt:
        $ref: "#/definitions/gorm.DeletedAt"
      UserID:
        type: integer
        minimum: 1
      User:
        $ref: "#/definitions/entities.User"
      Title:
        type: string
      Description:
        type: string
      BoilerplateCode:
        type: string
      TestCases:
        type: object
      Status:
        type: integer
        enum:
          - 0
          - 1
          - 2
  entities.TaskGroup:
    type: object
    properties:
      Tasks:
        type: array
        items:
          $ref: "#/definitions/entities.Task"
      TotalCount:
        type: integer
        minimum: 0
  entities.Solution:
    type: object
    properties:
      ID:
        type: integer
      CreatedAt:
        type: string
      UpdatedAt:
        type: string
      DeletedAt:
        $ref: "#/definitions/gorm.DeletedAt"
      UserID:
        type: integer
        minimum: 1
      User:
        $ref: "#/definitions/entities.User"
      TaskID:
        type: integer
        minimum: 1
      Task:
        $ref: "#/definitions/entities.Task"
      Code:
        type: string
      IsCorrect:
        type: boolean
      Result:
        type: object
  entities.SolutionGroup:
    type: object
    properties:
      Solutions:
        type: array
        items:
          $ref: "#/definitions/entities.Solution"
      TotalCount:
        type: integer
        minimum: 0
  entities.User:
    type: object
    properties:
      ID:
        type: integer
      CreatedAt:
        type: string
      UpdatedAt:
        type: string
      DeletedAt:
        $ref: "#/definitions/gorm.DeletedAt"
      Username:
        type: string
      Password:
        type: string
      PasswordHash:
        type: string
  entities.Credentials:
    type: object
    properties:
      AccessToken:
        type: string
securityDefinitions:
  JWTAuthorization:
    type: apiKey
    name: Authorization
    in: header

Repository

Link: https://github.com/thewizardplusplus/go-exercises-backend/tree/v1.5.2.

Content: code.

License: MIT.

Screenshots

Web API description in the Swagger format