Commit ea728345 authored by rlacko's avatar rlacko 💬
Browse files

Solution documentation

parent c5689c84
Pipeline #4727 passed with stages
in 2 minutes and 5 seconds
openapi: '3.0.2'
info:
title: 'Solution Endpoint'
version: '1.0'
paths:
/solution:
get:
tags:
- 'Solution'
summary: 'Get a List of solution'
description: 'Have to be accepted or mentor.
As an accepted only own solutions can be seen.'
operationId: 'getAllSolution'
responses:
'200':
description: OK
content:
application/json:
schema:
type: 'array'
items:
$ref: '#/components/schemas/Solution'
post:
tags:
- 'Solution'
summary: 'Create a solution'
description: 'Have to be accepted or mentor.
As an accepted only own own solution can be made.'
operationId: 'createSolution'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Solution'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Solution'
/solution/id/{id}:
get:
tags:
- 'Solution'
summary: 'Get a solution by ID'
description: 'Have to be accepted or mentor.
As an accepted only own solutions can be get.'
operationId: 'getSolution'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Solution'
put:
tags:
- 'Solution'
summary: 'Update a solution by ID'
description: 'Have to be accepted or mentor.
As an accepted only own solutions can be get.
After deadline cant make new solution as accepted.'
operationId: 'updateOneSolution'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Solution'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Solution'
delete:
tags:
- 'Solution'
summary: 'Delete a solution by ID'
description: 'Have to be accepted or mentor.
As an accepted only own solutions can be delted.
After deadline cant make new solution as accepted.'
operationId: 'deleteSolution'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Solution'
components:
schemas:
Solution:
type: object
properties:
task:
type: string
description: cuid of the task
title:
type: string
description:
type: string
file:
type: string
creator:
type: string
description: schacc of the user
comments:
type: array
items:
type: string
description: cuid of each comment
isAccepted:
type: boolean
default: false
required:
- task
- title
- description
- creator
- isAccepted
......@@ -17,7 +17,6 @@ const SolutionSchema = new mongoose.Schema(
},
file: {
type: String,
required: true,
},
creator: {
type: String,
......@@ -27,7 +26,6 @@ const SolutionSchema = new mongoose.Schema(
{
type: mongoose.Schema.Types.ObjectId,
ref: 'comment',
required: true,
},
],
isAccepted: {
......
......@@ -4,17 +4,17 @@ const { isLoggedIn, isAcceptedOrMentor } = require('../../middlewares/auth')
const router = Router()
// /api/item
// /api/v1/solution
router
.route('/')
.get(isLoggedIn, isAcceptedOrMentor, controllers.default.getMany)
.post(isLoggedIn, isAcceptedOrMentor, controllers.default.createOne)
// /api/item/:id
// /api/v1/solution/id/:id
router
.route('/:id')
.route('/id/:id')
.get(isLoggedIn, isAcceptedOrMentor, controllers.default.getOne)
.delete(isLoggedIn, isAcceptedOrMentor, controllers.default.notSupported)
.put(isLoggedIn, isAcceptedOrMentor, controllers.default.notSupported)
.delete(isLoggedIn, isAcceptedOrMentor, controllers.default.notSupported)
exports.default = router
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment