Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
10 kB
1
Indexable
Never
openapi: 3.0.0
info:
  version: 1.0.0
  title: Raport menagment
  description: This is API for the user on the right side of the schema

tags:
  - name: "Users"
  - name: "Contstraint"

paths:
  /users:
    get:
      summary: Returns a list of users
      operationId: returnAllUsers
      tags:
        - "Users"
      parameters:
        - name: firstname
          in: query
          required: false
          schema:
            type: string
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/UserDto'
        404:
          description: Not found

    post:
      summary: Create new user
      operationId: saveUser
      tags:
        - "Users"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserDto'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserDto'
        404 :
          description: Invalid request

  /users/{userId}:
    parameters:
      - name: userId
        in: path
        required: true
        schema:
          type: number

    get:
      summary: Returns a user with given id
      operationId: returnUser
      tags:
        - "Users"
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserDto'
        404 :
          description: Not found

    put:
      summary: Updates a user with given id
      operationId: updateUser
      tags:
        - "Users"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserDto'
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserDto'
    delete:
      summary: Deletes user with given id
      operationId: deleteUser
      tags:
        - "Users"
      responses:
        200 :
          description: OK
        404 :
          description: Bad request
  /contstraint:
    get:
      summary: Get all contstraint
      operationId: findAllcontstraint
      tags:
        - "Contstraint"
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/ConstrainDto'
    post:
      summary: Create new constrain
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConstrainDto'
      operationId: createConstrain
      tags:
        - "Contstraint"
      responses:
        201 :
          description: Created
  /contstraint/{id}:
    delete:
      summary: Delete single constrain
      operationId: deleteById
      tags:
        - "Contstraint"
      parameters:
        - name: id
          in: path
          description: contstraint ID
          required: true
          schema:
            type: integer
      responses:
        200 :
          description: Constrain deleted
        404 :
          description: Constrain not found
    get:
      summary: Get single constrain
      operationId: findById
      tags:
        - "Contstraint"
      parameters:
        - name: id
          in: path
          description: contstraint ID
          required: true
          schema:
            type: integer
      responses:
        200 :
          description: OK
        404 :
          description: Constrain not found
    patch:
      summary: Edit exist constrain
      operationId: editConstrain
      tags:
        - "Contstraint"
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                name:
                  description: Update contstraint name
                  type: string
                typeToWithApplys:
                  description: update type
                  type: string
                  enum:
                    - [Project,Task,User]
                objectId:
                  type: array
                  items:
                    type: number
      responses:
        200:
          description: OK
        404:
          description: Constrain not found
  /reports/users:
    get:
      tags:

        - "Users"
        - "Report"
      summary: returns all user reports
      operationId: getAllUserReports
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/UserReportDto'
        404 :
          description: Not found.
  /reports/users{id}:
    get:
      tags:
        - "Report"
      summary: returns one user report
      operationId: getOneUserReport
      parameters:
        - name: id
          in: path
          required: true
          description: userId of the requested user
          schema:
            type: integer
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserReportDto'
        404 :
          description: Not found.
  #TASK REPORTS
  /reports/tasks:
    get:
      tags:
        - "Report"
      summary: returns all task reports
      operationId: getAllTaskReports
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskReportDto'
        404 :
          description: Not found.
  /reports/tasks/{id}:
    get:
      tags:
        - "Report"
      summary: returns one task reports
      operationId: getOneTaskReport
      parameters:
        - name: id
          in: path
          required: true
          description: taskId of the requested task
          schema:
            type: integer
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskReportDto'
        404 :
          description: Not found.
  #PROJECT REPORTS
  /reports/projects:
    get:
      tags:
        - "Report"
      summary: returns all project reports
      operationId: getAllProjectsReports
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectReportDto'
        404 :
          description: Not found.
  /reports/projects/{id}:
    get:
      tags:
        - "Report"
      summary: returns one project report
      operationId: getOneProjectReport
      parameters:
        - name: id
          in: path
          required: true
          description: projectId of the requested project
          schema:
            type: integer
      responses:
        200 :
          description: OK
          content:
            application/json:
              schema:
               $ref: '#/components/schemas/ProjectReportDto'
        404 :
          description: Not found.



components:
  schemas:

    UserDto:
      type: object
      properties:
        userName:
          type: string
        surname:
          type: string
        localization:
          type: string
        project:
          type: string
        role:
          $ref: "#/components/schemas/UserRole"
          
    UserRole:
      description: User roles
      type: string
      enum:
        - MENAGER
        - EMPLOYEE
          
    ConstrainDto:
      description: This is contstraint
      type: object
      properties:
        id:
          description: contstraintId
          type: integer
        name:
          description: contstraint name
          type: string
        typeToWithApplys:
          $ref: "#/components/schemas/ContstraintTypeEnum"
        objectId:
          type: integer
            
    UserReportDto:
      description: This is the user report
      type: object
      properties:
        ReportName:
          type: string
        UserId:
          description: ID of the user
          type: number
        Dates:
          type: array
          items:
            $ref: '#/components/schemas/ProjectReportDto'

    ProjectReportDto:
      description: This is the project report
      type: object
      properties:
        ReportName:
          type: string
        TaskId:
          description: ID of the Project
          type: number
        Dates:
          type: array
          items:
            $ref: '#/components/schemas/TaskReportDto'

    TaskReportDto:
      description: This is the task report
      type: object
      properties:
        ReportName:
          type: string
        TaskId:
          description: ID of the Task
          type: number
        Dates:
          type: array
          items:
            $ref: '#/components/schemas/Entry'
            
    ContstraintTypeEnum:
      description: this is contstraint id
      enum:
        - PROJECT
        - USER
        - TASK
      
    Entry:
      description: This is stub mimicing data expected from the other service
      type: object
      properties:
        id:
          type: integer
        workerId:
          type: integer
        taskId:
          type: integer
        hours:
          type: integer
        date:
          type: string
          example: 21.02.2021