Skip to content

swagger

Amantaev-Artur edited this page Nov 19, 2023 · 15 revisions

Для быстрого и удобного просмотра схемы советую воспользоваться swagger online

Необходжимо копировать yml код ниже, и вставить его в swagger online

openapi: 3.0.3
info:
  title: attendance
  version: 1.0.0
  description: 'Все запросы отправляются с хэдером `Authorization: Bearer *access_token*`, кромер блока auth '
tags:
  - name: Users/Пользователь
    description: Действия с пользователями
  - name: Groups/Группы
    description: Действия с группами
  - name: Meetings/Встреча(пара)
    description: Действия с встречами
  - name: Attendings/Посещаемость(отметка о посещении)
    description: Действия с посещаемостью
  - name: Auth/Аутентификация
    description: Авторизация и регистрация пользователя
servers:
  - url: localhost:3002
  - url: http://sirius.inno-js.ru:3002
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
paths:
  /users:
    get:
      tags:
        - Users/Пользователь
      summary: Получение всех пользователей
      responses:
        '200':
          description: Успешное выполнение
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    firstname:
                      type: string
                      example: 'Иван'
                    lastname:
                      type: string
                      example: 'Иванович'
                    middlename:
                      type: string
                      example: 'Иванов'
                    email:
                      type: string
                      example: 'myemail'
                    password:
                      type: string
                      example: 'mypassword'
                    refreshToken:
                      type: string
                      example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIyOWFkNzQ4My1lNmI2LTRlMTktYTVkOS04ZmZiMmQ3MzJjMDkiLCJpYXQiOjE2OTcxOTY2ODR9.D0U9plOSSCuHdvW33mfxjE8AHnn5gI-_e77L8vUmOTo'
                    userId:
                      type: string
                      format: uuid
                      example: '29ad7483-e6b6-4e19-a5d9-8ffb2d732c09'
                    password_hash:
                      type: string
                      example: '$2b$10$vFjpSPap1VnV/6JaorTAjuhl59LgSWaJhIIiCyFSZ8kpK2MFmbJCK'
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен

  /user:
    post:
      tags:
        - Users/Пользователь
      summary: 'Создание пользователя'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                firstname:
                  type: string
                  example: 'Иван'
                lastname:
                  type: string
                  example: 'Иванович'
                middlename:
                  type: string
                  example: 'Иванов'
                email:
                  type: string
                  example: 'myemail'
                password:
                  type: string
                  example: '123'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                properties:
                  message:
                    type: string
                    example: 'Created'
        '400':
          description: Плохой запрос
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid Data
                  details:
                    type: object
                    properties:
                      propertie:
                        type: string
                        example: propertie is required
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '409':
          description: Name is already in use
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Email is already in use
                    

  /user/{userID}:
    get:
      tags:
        - Users/Пользователь
      summary: Получение пользователя по идентификатору
      parameters:
        - name: userID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  first_name:
                    type: string
                    example: 'Иван'
                  last_name:
                    type: string
                    example: 'Иванович'
                  middle_name:
                    type: string
                    example: 'Иванов'
                  email:
                    type: string
                    example: 'myemail'
                  role:
                    type: string
                    example: 'Студент'
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: User not found
    put:
      tags:
        - Users/Пользователь
      summary: Изменение пользователя
      parameters:
        - name: userID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: отправляются только те поля которые были изменены
        content:
          application/json:
            schema:
              type: object
              properties:
                first_name:
                  type: string
                  example: 'Иван'
                last_name:
                  type: string
                  example: 'Иванович'
                middle_name:
                  type: string
                  example: 'Иванов'
                email:
                  type: string
                  example: 'myemail'
                role:
                  type: string
                  example: 'Студент'
      responses:
        '200':
          description: successful operation
        '400':
          description: Плохой запрос
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid Data
                  details:
                    type: object
                    properties:
                      propertie:
                        type: string
                        example: propertie is required
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: User not found
        '409':
          description: Name is already in use
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Email is already in use
    delete:
      tags:
        - Users/Пользователь
      summary: Удаление пользователя
      parameters:
        - name: userID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '204':
          description: successful operation
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: User not found

  /groups:
    get:
      tags:
        - Groups/Группы
      summary: Получение всех групп
      responses:
        '200':
          description: Успешное выполнение
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    groupId:
                      type: string
                      format: uuid
                    name:
                      type: string
                      example: 'K0711-21/2'
                    users:
                      type: array
                      items:
                        type: string
                        format: uuid
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен

  /group:
    post:
      tags:
        - Groups/Группы
      summary: 'Создание группы'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                title:
                  type: string
                  example: 'K0711-21/2'
        required: true
      responses:
        '201':
          description: Created
        '400':
          description: Плохой запрос
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid Data
                  details:
                    type: object
                    properties:
                      propertie:
                        type: string
                        example: propertie is required
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '409':
          description: Name is already in use
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Name is already in use

  /group/{groupID}:
    get:
      tags:
        - Groups/Группы
      summary: Получение группы по идентификатору
      parameters:
        - name: groupID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  groupId:
                    type: string
                    format: uuid
                  name:
                    type: string
                    example: 'K0711-21/2'
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Group not found
    put:
      tags:
        - Groups/Группы
      summary: Изменение группы
      parameters:
        - name: groupID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: отправляются только те поля которые были изменены
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                  example: 'K0711-21/2'
      responses:
        '200':
          description: successful operation
        '400':
          description: Плохой запрос
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid Data
                  details:
                    type: object
                    properties:
                      propertie:
                        type: string
                        example: propertie is required
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '409':
          description: Name is already in use
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Name is already in use
    delete:
      tags:
        - Groups/Группы
      summary: Удаление группы
      parameters:
        - name: groupID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '204':
          description: successful operation
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Group not found

  /meetings:
    get:
      tags:
        - Meetings/Встреча(пара)
      summary: Получение всех сессий
      responses:
        '200':
          description: Успешное выполнение
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    meetingId:
                      type: string
                      format: uuid
                    title:
                      type: string
                      example: 'Программирование'
                    timeFrom:
                      type: string
                      format: date-time
                    timeTo:
                      type: string
                      format: date-time
                    teachers:
                      type: array
                      items:
                        type: string
                        format: uuid
                    groups:
                      type: array
                      items:
                        type: string
                        format: uuid

        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен

  /meeting:
    post:
      tags:
        - Meetings/Встреча(пара)
      summary: 'Создание сессии'
      requestBody:
        content:
            application/json:
              schema:
                type: object
                properties:
                  meetingId:
                    type: string
                    format: uuid
        required: true
      responses:
        '201':
          description: Created
        '400':
          description: Плохой запрос
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid Data
                  details:
                    type: object
                    properties:
                      propertie:
                        type: string
                        example: propertie is required
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '409':
          description: Name is already in use
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Title is already in use

  /meeting/QRCode:
    get:
      tags:
        - Meetings/Встреча(пара)
      summary: Получение qr для сессии
      parameters:
        - name: url
          in: header
          description: ссылка для генерации
          schema:
            type: string
          required: true

      responses:
        '200':
          description: OK
          content:
            multipart/mixed:
              schema:
                type: string
                format: binary
                example: <binary-data>
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: url not loyal
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен

  /meeting/{meetingID}:
    get:
      tags:
        - Meetings/Встреча(пара)
      summary: Получение сессии по идентификатору
      parameters:
        - name: meetingID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  meetingId:
                    type: string
                    format: uuid
                  title:
                    type: string
                    example: 'Программирование'
                  timeFrom:
                    type: string
                    format: date-time
                  timeTo:
                    type: string
                    format: date-time
                  teachers:
                    type: array
                    items:
                      type: string
                      format: uuid
                  groups:
                    type: array
                    items:
                      type: string
                      format: uuid
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Meeting not found
    put:
      tags:
        - Meetings/Встреча(пара)
      summary: Изменение сессии
      parameters:
        - name: meetingID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: отправляются только те поля которые были изменены
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                  example: 'Программирование'
                timeFrom:
                  type: string
                  format: date-time
                timeTo:
                  type: string
                  format: date-time
                author:
                  type: string
                  format: uuid
                groupsID:
                  type: array
                  items:
                    type: string
                    format: uuid
      responses:
        '200':
          description: successful operation
        '400':
          description: Плохой запрос
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid Data
                  details:
                    type: object
                    properties:
                      propertie:
                        type: string
                        example: propertie is required
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Meeting not found
        '409':
          description: Name is already in use
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Title is already in use
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
    delete:
      tags:
        - Meetings/Встреча(пара)
      summary: Удаление сессии
      parameters:
        - name: meetingID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '204':
          description: successful operation
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Meeting not found

  /attendings:
    get:
      tags:
        - Attendings/Посещаемость(отметка о посещении)
      summary: Получение всех сессий
      responses:
        '200':
          description: Успешное выполнение
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    attendingId:
                      type: string
                      format: uuid
                    meeting:
                      type: string
                      format: uuid
                    user:
                      type: string
                      format: uuid
                    joined_at:
                      type: string
                      format: date-time
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен

  /attending:
    post:
      tags:
        - Attendings/Посещаемость(отметка о посещении)
      summary: 'Создание сессии'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                meetingID:
                  type: string
                  format: uuid
                studentID:
                  type: string
                  format: uuid
        required: true
      responses:
        '201':
          description: Created
        '400':
          description: Плохой запрос
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid Data
                  details:
                    type: object
                    properties:
                      propertie:
                        type: string
                        example: propertie is required
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '409':
          description: Name is already in use
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: User is already in use

  /attending/{attendingID}:
    get:
      tags:
        - Attendings/Посещаемость(отметка о посещении)
      summary: Получение сессии по идентификатору
      parameters:
        - name: attendingID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  attendingId:
                    type: string
                    format: uuid
                  meeting:
                    type: string
                    format: uuid
                  user:
                    type: string
                    format: uuid
                  joined_at:
                    type: string
                    format: date-time
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Attending not found
    put:
      tags:
        - Attendings/Посещаемость(отметка о посещении)
      summary: Изменение сессии
      parameters:
        - name: attendingID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: отправляются только те поля которые были изменены
        content:
          application/json:
            schema:
              type: object
              properties:
                meetingID:
                  type: string
                  format: uuid
                studentID:
                  type: string
                  format: uuid
      responses:
        '200':
          description: successful operation
        '400':
          description: Плохой запрос
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Invalid Data
                  details:
                    type: object
                    properties:
                      propertie:
                        type: string
                        example: propertie is required
        '409':
          description: Name is already in use
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Name is already in use
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
    delete:
      tags:
        - Attendings/Посещаемость(отметка о посещении)
      summary: Удаление сессии
      parameters:
        - name: attendingID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '204':
          description: successful operation
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен
        '404':
          description: Не найдено
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Attending not found

  /auth/login:
    post:
      tags:
        - Auth/Аутентификация
      summary: log in
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  example: my email
                password:
                  type: string
                  example: my password
      responses:
        '200':
          description: Успешное выполнение, iat указывается в днях
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    newAccessToken:
                      type: string
                      example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
                    newRefreshToken:
                      type: string
                      example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
                    accessExpiresIn:
                      type: string
                      example: '1d'
                    refreshExpiresIn:
                      type: string
                      example: '7d'
        '401':
          description: Неавторизованный доступ
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Неверный или истекший access-токен

  /auth/registration:
    post:
      tags:
        - Auth/Аутентификация
      summary: sign in
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  example: my email
                lastname:
                  type: string
                  example: Амантаев
                firstname:
                  type: string
                  example: Артур
                middlename:
                  type: string
                  example: Махмудович
                password:
                  type: string
                  example: my password
      responses:
        '200':
          description: Успешное выполнение, iat указывается в днях
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    newAccessToken:
                      type: string
                      example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
                    newRefreshToken:
                      type: string
                      example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
                    accessExpiresIn:
                      type: string
                      example: '1d'
                    refreshExpiresIn:
                      type: string
                      example: '7d'
        '409':
          description: Пользователь с таким email уже зарегистрирован
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Conflict

  /auth/refresh:
    post:
      tags:
        - Auth/Аутентификация
      summary: Обновление токена
      parameters:
        - name: refreshToken
          in: header
          description: refreshToken
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Успешное выполнение
          content:
            application/json:
              schema:
                type: object
                properties:
                  newAccessToken:
                    type: string
                    example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c'
        '400':
          description: невалидные данные