core/openapi.yaml
2024-03-13 21:23:46 +03:00

1211 lines
41 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

openapi: 3.0.3
info:
title: QUIZ service api
description: Title
version: 1.0.0
components:
requestBodies:
GetQuizResultsReq:
content:
'application/json':
schema:
type: object
properties:
to:
description: таймштамп времени, до которого выбирать статистику. если 0 или не передано - этого ограничения нет. верхняя граница времени
type: integer
from:
description: таймштамп времени, после которого выбирать статистику. если 0 или не передано - этого ограничения нет. нижняя граница времени
new:
description: флаг, по которому вернутся только новые результаты, ещё не просмотренные пользователем
type: boolean
page:
description: номер страницы для пагинации
type: integer
require: true
limit:
description: размер страницы для пагинации
type: integer
require: true
QuizCreateReq:
content:
'application/json':
schema:
type: object
properties:
fingerprinting:
description: set true for save deviceId
type: boolean
repeatable:
description: set true for allow user to repeat quiz
type: boolean
note_prevented:
description: set true for save statistic of incomplete quiz passing
type: boolean
mail_notifications:
description: set true for mail notification for each quiz passing
type: boolean
unique_answers:
description: set true for save statistics only for unique quiz passing
type: boolean
name:
description: name of quiz. max 280 length
type: string
description:
description: description of quiz
type: string
config:
description: config of quiz. serialized json for rules of quiz flow
type: string
status:
description: status of quiz. allow only '', 'draft', 'template', 'stop', 'start'
type: string
limit:
description: limit is count of max quiz passing
type: integer
due_to:
description: last time when quiz is valid. timestamp in seconds
type: integer
time_of_passing:
description: seconds to pass quiz
type: integer
pausable:
description: true if it is allowed for pause quiz
type: boolean
question_cnt:
description: count of questions
type: integer
super:
description: set true if squiz realize group functionality
type: boolean
group_id:
description: group of new quiz
type: integer
QuizGetListReq:
content:
'application/json':
schema:
type: object
properties:
limit:
description: max items on page
type: integer
offset:
description: page number
type: integer
from:
description: start time of time period. timestamp in seconds
type: integer
to:
description: end time of time period. timestamp in seconds
type: integer
search:
description: string for fulltext search in titles of quizes
type: string
status:
description: allow only - draft, template, timeout, stop, start, offlimit
type: string
deleted:
description: get deleted quizes
type: boolean
archived:
description: get archived quizes
type: boolean
super:
description: set true if squiz realize group functionality
type: boolean
group_id:
description: group of new quiz
type: integer
QuestionCreateReq:
content:
'application/json':
schema:
type: object
properties:
quiz_id:
description: id of quiz for what question is creating
type: integer
title:
description: title of question. max length 512
type: string
description:
description: description of question. html/text
type: string
type:
description: type of question. allow only text, select, file, variant, images, varimg, emoji, date, number, page, rating
type: string
required:
description: set true if user MUST answer this question
type: boolean
page:
description: page of question
type: integer
content:
description: json serialized of question content settings
type: string
QuestionGetListReq:
content:
'application/json':
schema:
type: object
properties:
limit:
description: max items on page
type: integer
offset:
description: page number
type: integer
from:
description: start time of time period. timestamp in seconds
type: integer
to:
description: end time of time period. timestamp in seconds
type: integer
search:
description: string for fulltext search in titles of questions
type: string
type:
description: allow only - text, select, file, variant, images, varimg, emoji, date, number, page, rating or empty string
type: string
deleted:
description: get deleted quizes
type: boolean
required:
description: get only require questions
type: boolean
quiz_id:
description: relation to quiz
type: integer
GetQuizReq:
content:
'application/json':
schema:
type: object
properties:
quiz_id:
type: string
description: secret string id for customer activity
limit:
type: integer
description: page size
page:
type: integer
description: page of questions
need_config:
type: boolean
description: make true if you need all quiz settings with questions page
UpdateQuestionReq:
content:
'application/json':
schema:
type: object
properties:
id:
type: integer
description: id of question for update
required: true
title:
type: string
description: new title of question
desc:
type: string
description: new fulltext plain/html description
type:
type: string
description: new type of question
content:
type: string
description: new content of question
required:
type: boolean
description: set true if this question must be answered
page:
type: integer
description: page of question
UpdateQuizReq:
content:
'application/json':
schema:
type: object
properties:
id:
type: integer
description: id of question for update
required: true
fp:
type: boolean
description: set true for storing fingerprints
required: true
rep:
type: boolean
description: set true for allow to repeat quiz after passing
required: true
note_prevented:
type: boolean
description: set true for store unfinished passing
required: true
mailing:
type: boolean
description: set true if we should send passing result on every passing
required: true
uniq:
type: boolean
description: set true if we allow only one user quiz passing
required: true
name:
type: string
description: new name of the quiz
desc:
type: string
description: new descriptions of the quiz
conf:
type: string
description: new config of the quiz
status:
type: string
description: new status. only draft,template,stop,start allowed
limit:
type: integer
description: max amount of quiz passing
required: true
due_to:
type: integer
description: max time of quiz passing
required: true
time_of_passing:
type: integer
description: max time to pass quiz
required: true
pausable:
type: boolean
description: allow to pause quiz to user
required: true
question_cnt:
description: count of questions
type: integer
super:
description: set true if squiz realize group functionality
type: boolean
group_id:
description: group of new quiz
type: integer
CopyQuestionReq:
content:
'application/json':
schema:
type: object
properties:
id:
type: integer
description: id of copying question
required: true
quiz_id:
type: integer
description: quiz id for copy question to another quiz
CopyQuizReq:
content:
'application/json':
schema:
type: object
properties:
id:
type: integer
description: id of copied quiz
required: true
GetQuizHistoryReq:
content:
'application/json':
schema:
type: object
properties:
id:
type: integer
description: id of quiz for history
required: true
l:
type: integer
description: naumber of quiz due page
p:
type: integer
description: number of page
DeactivateReq:
content:
'application/json':
schema:
type: object
properties:
id:
type: integer
description: id of deactivating struct
required: true
responses:
GetQuizResultsResp:
description: список результатов, уместившийся на запрошенной странице
content:
'application/json':
schema:
type: object
properties:
total_count:
description: общее количество элементов удволетворяющее фильтру. нужно для формирования логики пагинации
type: integer
results:
description: список результатов
type: array
items:
type: object
properties:
content:
description: содержимое ответа
type: string
id:
description: айдишник ответа
type: integer
new:
description: статус, был ли просмотрен ответ
type: boolean
created_at:
description: время создания этого результата
type: string
QuizModel:
description: object of created quiz
content:
'application/json':
schema:
type: object
properties:
id:
description: Id of created quiz
type: integer
qid:
description: string id for customers
type: string
deleted:
description: true if quiz deleted
type: boolean
archived:
description: true if quiz archived
type: boolean
fingerprinting:
description: set true for save deviceId
type: boolean
repeatable:
description: set true for allow user to repeat quiz
type: boolean
note_prevented:
description: set true for save statistic of incomplete quiz passing
type: boolean
mail_notifications:
description: set true for mail notification for each quiz passing
type: boolean
unique_answers:
description: set true for save statistics only for unique quiz passing
type: boolean
name:
description: name of quiz. max 280 length
type: string
description:
description: description of quiz
type: string
config:
description: config of quiz. serialized json for rules of quiz flow
type: string
status:
description: status of quiz. allow only '', 'draft', 'template', 'stop', 'start'
type: string
limit:
description: limit is count of max quiz passing
type: integer
due_to:
description: last time when quiz is valid. timestamp in seconds
type: integer
time_of_passing:
description: seconds to pass quiz
type: integer
pausable:
description: true if it is allowed for pause quiz
type: boolean
version:
description: version of quiz
type: integer
version_comment:
description: version comment to version of quiz
type: string
parent_ids:
description: array of previous versions of quiz
type: array
items:
type: integer
created_at:
description: time of creating
type: string
updated_at:
description: time of last updating
type: string
question_cnt:
description: count of questions
type: integer
passed_count:
description: count passings
type: integer
average_time:
description: average time of passing
type: integer
super:
description: set true if squiz realize group functionality
type: boolean
group_id:
description: group of new quiz
type: integer
QuizListGetResp:
description: list of quizes with all filtered quizes count
content:
'application/json':
schema:
type: object
properties:
count:
description: count of all filtered items
type: integer
items:
description: count of all filtered items
type: array
items:
$ref: '#/components/responses/QuizModel'
QuestionModel:
description: object of created question
content:
'application/json':
schema:
type: object
properties:
id:
description: Id of created question
type: integer
quiz_id:
description: relation to quiz
type: integer
title:
description: title of question. max 512 length
type: string
description:
description: description of question
type: string
type:
description: status of question. allow only text, select, file, variant, images, varimg, emoji, date, number, page, rating
type: string
required:
description: user must pass this question
type: boolean
deleted:
description: true if question is deleted
type: boolean
page:
description: page if question
type: integer
content:
description: serialized json of created question
type: string
version:
description: version of quiz
type: integer
parent_ids:
description: array of previous versions of quiz
type: array
items:
type: integer
created_at:
description: time of creating
type: string
updated_at:
description: time of last updating
type: string
QuestionListGetResp:
description: list of quizes with all filtered quizes count
content:
'application/json':
schema:
type: object
properties:
count:
description: count of all filtered items
type: integer
items:
description: count of all filtered items
type: array
items:
$ref: '#/components/responses/QuizModel'
QuizGetResp:
description: short response for customer
content:
'application/json':
schema:
type: object
properties:
cnt:
type: integer
description: count of all questions in quiz
settings:
type: object
properties:
fp:
type: boolean
description: store fingerprint if true
rep:
type: boolean
description: allow repeat after end of quiz passing
name:
type: string
description: title of quiz
cfg:
type: string
description: serialized json of quiz graph
lim:
type: integer
description: max amount of passing
due:
type: integer
description: last time of new ansvers are valid
delay:
type: integer
description: time that given to customer for pass quiz
pausable:
type: boolean
description: allow user to pause quiz passing
items:
type: array
description: array of xhort items of quiestions for quiz
items:
type: object
properties:
id:
type: integer
description: identificator of question
title:
type: string
description: title of question
desc:
type: string
description: description of question html plaintext
typ:
type: string
description: type of question such as text, select, file, variant, images, varimg, emoji, date, number, page, rating
req:
type: boolean
description: mark question as required
p:
type: integer
description: page of quiz
c:
type: string
description: config of question. such as variants for select
UpdateResp:
description: id of new version of question
content:
'application/json':
schema:
type: object
properties:
updated:
type: integer
DeactivateResp:
description: id of deleted structure
content:
'application/json':
schema:
type: object
properties:
deactivated:
type: integer
schemas:
Answer:
type: object
properties:
Id:
type: integer
description: id ответа
Content:
type: string
description: контент ответа
QuestionId:
type: integer
description: id вопроса к которому ответ
QuizId:
type: integer
description: id опроса к которому ответ
Fingerprint:
type: string
description: fingerprint
Session:
type: string
description: сессия
Result:
type: boolean
description: true or false?
CreatedAt:
type: string
format: date-time
description: таймшап когда ответ создан
New:
type: boolean
description: новый ответ?
Deleted:
type: boolean
description: удален?
paths:
/liveness:
get:
description: Check that service is running
responses:
'200':
description: healthcheck. if it non 200, that service is not running
/readiness:
get:
description: Check that service is ready for handle requests
responses:
'200':
description: healthcheck. if it non 200, that service is not running
/quiz/create:
post:
description: Create quiz
requestBody:
$ref: '#/components/requestBodies/QuizCreateReq'
responses:
'201':
$ref: '#/components/responses/QuizModel'
'422':
description: name field should have less then 280 chars
content:
'application/json':
schema:
type: string
default: name field should have less then 280 chars
'406':
description: not acceptable input data
content:
'application/json':
schema:
type: string
default: status on creating must be only draft,template,stop,start or due to time must be lesser then now
'409':
description: not logical entry
content:
'application/json':
schema:
type: string
default: you can pause quiz only if it has deadline for passing
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/quiz/getList:
post:
description: method for obtain page of quiz list for paginated list
requestBody:
$ref: '#/components/requestBodies/QuizGetListReq'
responses:
'200':
$ref: '#/components/responses/QuizListGetResp'
'406':
description: inappropriate status, allowed only '', 'stop','start','draft', 'template','timeout','offlimit'
content:
'application/json':
schema:
type: string
default: inappropriate status
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/question/create:
post:
description: method for creating question for quiz
requestBody:
$ref: '#/components/requestBodies/QuestionCreateReq'
responses:
'200':
$ref: '#/components/responses/QuestionModel'
'422':
description: not valid data
content:
'application/json':
schema:
type: string
default: title field should have less then 512 chars
'406':
description: not acceptable data
content:
'application/json':
schema:
type: string
default: type must be only test,button,file,checkbox,select, none
'424':
description: failed relation to quiz
content:
'application/json':
schema:
type: string
default: failed relation to quiz
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/question/getList:
post:
description: method for obtain page of question list for paginated list
requestBody:
$ref: '#/components/requestBodies/QuestionGetListReq'
responses:
'200':
$ref: '#/components/responses/QuestionListGetResp'
'406':
description: inappropriate type, allowed only '','test','none','file', 'button','select','checkbox'
content:
'application/json':
schema:
type: string
default: inappropriate status
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/quiz/get:
post:
description: method for obtaining settings of quiz and question page
requestBody:
$ref: '#/components/requestBodies/GetQuizReq'
responses:
'200':
$ref: '#/components/responses/QuizGetResp'
'206':
$ref: '#/components/responses/QuizGetResp'
'400':
description: you cat get quiz only if you know it's uuid
content:
'application/json':
schema:
type: string
default: no quiz id provided
'411':
description: limit should not be 0 when no aettings is need
content:
'application/json':
schema:
type: string
default: no data requested
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
'423':
description: you can not get data for inactive quiz
content:
'application/json':
schema:
type: string
default: quiz is inactive
'410':
description: you can not get timeouted quiz
content:
'application/json':
schema:
type: string
default: quiz timeouted
/question/edit:
patch:
description: method for update question. delete old question and create new with increment version
requestBody:
$ref: '#/components/requestBodies/UpdateQuestionReq'
responses:
'200':
$ref: '#/components/responses/UpdateResp'
'424':
description: return when no question id was send
content:
'application/json':
schema:
type: string
default: need id of question for update
'422':
description: too large new title
content:
'application/json':
schema:
type: string
default: title field should have less then 512 chars
'406':
description: inappropriate status sent
content:
'application/json':
schema:
type: string
default: type must be only test,button,file,checkbox,select, none or empty string
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/quiz/edit:
patch:
description: method for update quiz
requestBody:
$ref: '#/components/requestBodies/UpdateQuizReq'
responses:
'200':
$ref: '#/components/responses/UpdateResp'
'424':
description: return when no quiz id was send
content:
'application/json':
schema:
type: string
default: need id of quiz for update
'422':
description: too large new title
content:
'application/json':
schema:
type: string
default: name field should have less then 280 chars
'406':
description: inappropriate status sent
content:
'application/json':
schema:
type: string
default: status on creating must be only draft,template,stop,start or due to time must be lesser then now
'409':
description: impossible state creating
content:
'application/json':
schema:
type: string
default: you can pause quiz only if it has deadline for passing
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/question/copy:
post:
description: method for copy question to another quiz or to duplicate quiz
requestBody:
$ref: '#/components/requestBodies/CopyQuestionReq'
responses:
'201':
$ref: '#/components/responses/UpdateResp'
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
'424':
description: return when no question id was send
content:
'application/json':
schema:
type: string
default: no id provided
/quiz/copy:
post:
description: method for copy question to another quiz or to duplicate quiz
requestBody:
$ref: '#/components/requestBodies/CopyQuizReq'
responses:
'201':
$ref: '#/components/responses/UpdateResp'
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
'424':
description: return when no quiz id was send
content:
'application/json':
schema:
type: string
default: no id provided
/quiz/history:
post:
description: method for obtain page of quiz history for paginated list
requestBody:
$ref: '#/components/requestBodies/GetQuizHistoryReq'
responses:
'200':
description: page of history quiz changes
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/responses/QuizModel'
'424':
description: no id provided
content:
'application/json':
schema:
type: string
default: no id provided
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/question/history:
post:
description: method for obtain page of question history for paginated list
requestBody:
$ref: '#/components/requestBodies/GetQuizHistoryReq'
responses:
'200':
description: page of history question changes
content:
'application/json':
schema:
type: array
items:
$ref: '#/components/responses/QuestionModel'
'424':
description: no id provided
content:
'application/json':
schema:
type: string
default: no id provided
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/quiz/delete:
delete:
description: method for mark quiz as deleted
requestBody:
$ref: '#/components/requestBodies/DeactivateReq'
responses:
'200':
$ref: '#/components/responses/DeactivateResp'
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
'424':
description: return when no quiz id was send
content:
'application/json':
schema:
type: string
default: no id provided
/quiz/archive:
patch:
description: method for mark quiz as archived
requestBody:
$ref: '#/components/requestBodies/DeactivateReq'
responses:
'200':
$ref: '#/components/responses/DeactivateResp'
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
'424':
description: return when no quiz id was send
content:
'application/json':
schema:
type: string
default: no id provided
/question/delete:
delete:
description: method for mark question as deleted
requestBody:
$ref: '#/components/requestBodies/DeactivateReq'
responses:
'200':
$ref: '#/components/responses/DeactivateResp'
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
'424':
description: return when no question id was send
content:
'application/json':
schema:
type: string
default: no id provided
/results/getResults/{quizId}:
post:
description: получение списка результатов респондентов проходивших опрос
requestBody:
$ref: '#/components/requestBodies/GetQuizResultsReq'
responses:
'200':
$ref: '#/components/responses/GetQuizResultsResp'
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/results/delete/{resultId}:
delete:
description: мягкое удаление результата. не удаляет, но помечает удаленным
responses:
'200':
description: если все хорошо,то и отправлять нечего
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/results/seen:
patch:
description: устаревает результаты, т.е. делает их new = false
requestBody:
content:
'application/json':
schema:
type: object
properties:
answers:
description: список айдишников результатов, которые надо устареть
type: array
items:
type: integer
responses:
'200':
description: если все хорошо,то и отправлять нечего
'500':
description: not mentioned error
content:
'application/json':
schema:
type: string
default: if you get any content string send it to developer
/results/{quizID}/export:
post:
summary: экспорт результатов quiz в csv
description: экспорт результатов quiz в csv
parameters:
- in: path
name: quizID
description: id quiz, из которого нужно экспортировать результаты
required: true
schema:
type: integer
format: uint64
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
to:
type: string
format: date
description: Дата окончания диапазона времени для экспорта результатов
from:
type: string
format: date
description: Дата начала временного диапазона для экспорта результатов
new:
type: boolean
description: Экспортировать ли только новые результаты?
responses:
"200":
description: CSV-файл, содержащий результаты теста
content:
text/csv:
schema:
type: string
format: binary
"400":
description: Bad request. Invalid quiz ID or request body.
"500":
description: Internal server error. Failed to export quiz results.
/result/{resultID}:
get:
summary: возвращает все ответы по resultID (answerID) в рамках сессии resultID
description: возвращает все ответы по resultID (answerID) в рамках сессии resultID
parameters:
- in: path
name: resultID
required: true
description: resultID (answerID), в рамках сессии которого нужно вернуть все ответы
schema:
type: string
responses:
'200':
description: Successful
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Answer'
'400':
description: Invalid result ID provided
content:
application/json:
schema:
type: object
properties:
message:
type: string
'500':
description: Failed to retrieve result answers
content:
application/json:
schema:
type: object
properties:
message:
type: string