CodeBattles
Github
RU_v3
RU_v3
  • О системе V3
  • Обзор
    • Интерфейс участника
    • Интерфейс администратора
      • Задачи
      • Чекеры
      • Соревнования
  • Настройка и установка системы
    • Установка
      • Локальная установка
      • Production установка
  • Первое соревнование
    • Создать соревнование
  • Инструкции
    • Соревнование
      • Создание соревнования
      • Редактирование чекеров соревнования
      • Редактирование пользователей соревнования
      • Редактирование задач соревнования
    • Задачи
      • Добавить задачу
      • Изменить задачу
      • Удалить задачу
    • Пользователи
      • Регистрация пользователей
    • Чекеры
      • Создание чекера
      • Изменение чекера
      • Удаление чекера
  • Как работает система
    • Архитектура
    • Безопасность
  • API
    • Введение в API
    • Backend
      • Checkers
      • Competition Problems
      • Users
      • Answer
      • Competitions
      • Ping Pong
      • Problems
      • Auth
      • Checker system API
      • Models
    • Checker API
      • HealthCheck
      • Test
Powered by GitBook
On this page

Was this helpful?

  1. API
  2. Backend

Problems

PreviousPing PongNextAuth

Was this helpful?

Endpoints for managing problems

[ADMIN] Get problem by ID

get

Retrieves a problem by its ID. Required admin role

Authorizations
Path parameters
idinteger · int64Required
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/problems/{id} HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
{
  "id": 1,
  "name": "Sum of Two Numbers",
  "description": "Calculate the sum of two integers.",
  "inData": 1,
  "outData": 3,
  "examples": "Input: 1 2, Output: 3",
  "public": true
}

[ADMIN] Get problem by ID (extra fields)

get

Retrieves a problem by its ID with admin-level access. Required admin role

Authorizations
Path parameters
idinteger · int64Required
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/problems/{id}/admin HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
{
  "id": 1,
  "name": "text",
  "description": "text",
  "inData": "text",
  "outData": "text",
  "tests": "text",
  "examples": "text"
}
  • GET[ADMIN] Get all problems
  • POST[ADMIN] Create a new problem
  • GET[ADMIN] Get problem by ID
  • PATCH[ADMIN] Update a problem
  • GET[ADMIN] Get problem by ID (extra fields)

[ADMIN] Get all problems

get

Retrieves a list of all problems.

Authorizations
Responses
200
OK
*/*
Responseobject
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
get
GET /api/problems HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Accept: */*
{}

[ADMIN] Create a new problem

post

Creates a new problem using the provided data.

Authorizations
Body
namestringRequired

Name of the problem

Example: Sum of Two Numbers
descriptionstringRequired

Description of the problem

Example: Calculate the sum of two integers.
inDatastringRequired

Input data for the problem

Example: 1
outDatastringRequired

Expected output data for the problem

Example: 3
testsstringRequired

Test cases for the problem (JSON)

Example: {"in":"1","out":"3"}
examplesstringRequired

Example cases for the problem (JSON)

Example: {"in":"1","out":"3"}
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
post
POST /api/problems HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 164

{
  "name": "Sum of Two Numbers",
  "description": "Calculate the sum of two integers.",
  "inData": 1,
  "outData": 3,
  "tests": {
    "in": "1",
    "out": "3"
  },
  "examples": {
    "in": "1",
    "out": "3"
  }
}
{
  "id": 1,
  "name": "Sum of Two Numbers",
  "description": "Calculate the sum of two integers.",
  "inData": 1,
  "outData": 3,
  "examples": "Input: 1 2, Output: 3",
  "public": true
}

[ADMIN] Update a problem

patch

Applies partial updates to a problem by its ID.

Authorizations
Path parameters
idinteger · int64Required
Body
anyOptional
Responses
200
OK
*/*
401
Unauthorized
*/*
403
Forbidden
*/*
500
Internal Server Error
*/*
patch
PATCH /api/problems/{id} HTTP/1.1
Host: localhost:8080
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
{
  "id": 1,
  "name": "text",
  "description": "text",
  "inData": "text",
  "outData": "text",
  "tests": "text",
  "examples": "text"
}