diff --git a/docker-compose.yml b/docker-compose.yml
index e101d36528c09d9dc566b316291869e4ab112fcc..ee7e7d14dad7295702bd9e0144d61266566b97d1 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -20,24 +20,40 @@ services:
ports:
- "5432:5432"
networks:
- - db-network
+ - db-network
+
server:
image: raiden454/cpp-app:latest
networks:
- db-network
+ - nginx-network
env_file:
- .env
volumes:
- .:/project
command: bash -c "make build-project && make server-run"
ports:
- - "8080:8080"
+ - "8081:8080"
depends_on:
- db
links:
- - db:db
+ - db:db
+
+ docs:
+ image: nginx
+ container_name: docs
+ volumes:
+ - ./docs/index.html:/usr/share/nginx/html/index.html
+ - ./docs/openapi.yml:/usr/share/nginx/html/openapi.yml
+ ports:
+ - 8080:80
+ networks:
+ - nginx-network
networks:
db-network:
driver: bridge
name: db_network
+ nginx-network:
+ driver: bridge
+ name: nginx_network
diff --git a/docs/.spectral.yml b/docs/.spectral.yml
new file mode 100644
index 0000000000000000000000000000000000000000..2b7eadffbda6597c5b048c20ffe4069811420ed5
--- /dev/null
+++ b/docs/.spectral.yml
@@ -0,0 +1 @@
+extends: [[spectral:oas, all]]
\ No newline at end of file
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..530a08add7ca1e73bce5e559bd8ad4b70353afb0
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,5 @@
+all: lint
+
+.PHONY: lint
+lint:
+ @docker run --rm -t -v "$(PWD)":/tmp stoplight/spectral lint -v --ruleset "/tmp/.spectral.yml" "/tmp/openapi.yaml"
\ No newline at end of file
diff --git a/docs/index.html b/docs/index.html
new file mode 100755
index 0000000000000000000000000000000000000000..6b39db1fb1ed9d3c40cceb097e5e66ee72b4e5b9
--- /dev/null
+++ b/docs/index.html
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+ Sourced Out API v1
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/openapi.yml b/docs/openapi.yml
new file mode 100755
index 0000000000000000000000000000000000000000..c4e7a47064fa18f225104c06f74e953ccd2664ed
--- /dev/null
+++ b/docs/openapi.yml
@@ -0,0 +1,336 @@
+openapi: '3.0.2'
+info:
+ title: Sourced Out API
+ description: Anti-plagiarism system API.
+ version: '0.1.0'
+ contact:
+ name: Denis Okutin
+ url: https://t.me/raiden4545
+
+
+servers:
+ - url: http://localhost:8081
+tags:
+ - name: User
+ - name: Task
+ - name: Solution
+
+paths:
+ /user/register:
+ post:
+ summary: Create new user
+ description: >
+ Creates a new user. Login - email should be unique.
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ allOf:
+ - properties:
+ login:
+ $ref: '#/components/schemas/User/properties/login'
+ - properties:
+ username:
+ $ref: '#/components/schemas/User/properties/username'
+ - properties:
+ password:
+ $ref: '#/components/schemas/Password'
+ tags:
+ - User
+ responses:
+ '200':
+ description: OK
+ content:
+ text/plain:
+ schema:
+ $ref: '#/components/schemas/User'
+ '400':
+ description: Bad request
+ content:
+ text/plain:
+ schema:
+ type: string
+ '403':
+ description: Forbidden
+ content:
+ text/plain:
+ schema:
+ type: string
+ default:
+ description: Internal server error
+ content:
+ text/plain:
+ schema:
+ type: string
+ /user/login:
+ post:
+ summary: Login user
+ description: >
+ Logins an existing user.
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ allOf:
+ - properties:
+ login:
+ $ref: '#/components/schemas/User/properties/login'
+ - properties:
+ username:
+ $ref: '#/components/schemas/User/properties/username'
+ - properties:
+ password:
+ $ref: '#/components/schemas/Password'
+ tags:
+ - User
+ responses:
+ '200':
+ description: OK
+ content:
+ text/plain:
+ schema:
+ $ref: '#/components/schemas/User'
+ '400':
+ description: Bad request
+ content:
+ text/plain:
+ schema:
+ type: string
+ '404':
+ description: Not found
+ content:
+ text/plain:
+ schema:
+ type: string
+ default:
+ description: Internal server error
+ content:
+ text/plain:
+ schema:
+ type: string
+ /task/create:
+ post:
+ summary: Create new task
+ description: >
+ Creates a new task.
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ allOf:
+ - properties:
+ description:
+ type: string
+ name:
+ type: string
+ treshold:
+ type: number
+ format: float
+ tags:
+ - Task
+ responses:
+ '200':
+ description: OK
+ content:
+ text/plain:
+ schema:
+ $ref: '#/components/schemas/Task'
+ '400':
+ description: Bad request
+ content:
+ text/plain:
+ schema:
+ type: string
+ default:
+ description: Internal server error
+ content:
+ text/plain:
+ schema:
+ type: string
+ /task/all:
+ get:
+ summary: Get all tasks
+ description: >
+ Get all tasks from db.
+ tags:
+ - Task
+ responses:
+ '200':
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ count:
+ type: integer
+ tasks:
+ type: array
+ items:
+ $ref: '#/components/schemas/Task'
+ '400':
+ description: Bad request
+ content:
+ text/plain:
+ schema:
+ type: string
+ default:
+ description: Internal server error
+ content:
+ text/plain:
+ schema:
+ type: string
+ /solution/submit:
+ post:
+ summary: Create new solution
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ allOf:
+ - properties:
+ user_id:
+ type: integer
+ task_id:
+ type: integer
+ filename:
+ type: string
+ filedata:
+ type: string
+ tags:
+ - Solution
+ responses:
+ '200':
+ description: OK
+ content:
+ application/json:
+ schema:
+ allOf:
+ - properties:
+ sol_id:
+ type: integer
+ source:
+ type: string
+ result:
+ type: string
+ '400':
+ description: Bad request
+ content:
+ text/plain:
+ schema:
+ type: string
+ default:
+ description: Internal server error
+ content:
+ text/plain:
+ schema:
+ type: string
+ /solution/all:
+ post:
+ summary: Get all solutions
+ description: >
+ Get all solutions by user ans task id
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ allOf:
+ - properties:
+ user_id:
+ type: integer
+ task_id:
+ type: integer
+ tags:
+ - Solution
+ responses:
+ '200':
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ count:
+ type: integer
+ tasks:
+ type: array
+ items:
+ $ref: '#/components/schemas/Solution'
+ '400':
+ description: Bad request
+ content:
+ text/plain:
+ schema:
+ type: string
+ default:
+ description: Internal server error
+ content:
+ text/plain:
+ schema:
+ type: string
+components:
+ schemas:
+ Login:
+ type: string
+ format: email
+ pattern: '(\\w+)@(\\w+)(\\.(\\w+))+'
+ minLength: 3
+ maxLength: 30
+ Username:
+ type: string
+ minLength: 3
+ maxLength: 20
+ Password:
+ type: string
+ format: password
+ minLength: 8
+ maxLength: 30
+ User:
+ type: object
+ properties:
+ id:
+ type: integer
+ login:
+ $ref: '#/components/schemas/Login'
+ username:
+ $ref: '#/components/schemas/Username'
+ Task:
+ type: object
+ properties:
+ id:
+ type: integer
+ description:
+ type: string
+ treshold:
+ type: number
+ format: float
+ name:
+ type: string
+ Solution:
+ type: object
+ properties:
+ id:
+ type: integer
+ send_date:
+ type: string
+ sender_id:
+ type: integer
+ source:
+ type: string
+ tokens:
+ type: array
+ astTree:
+ type: string
+ task_id:
+ type: integer
+ result:
+ type: string
+ orig_solution:
+ type: integer
+ language:
+ type: string
\ No newline at end of file