Skip to content
Snippets Groups Projects
Commit ea728345 authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

Solution documentation

parent c5689c84
No related tags found
2 merge requests!20working endpoints and documentation,!18Resolve "Átfaktorálás"
Pipeline #4727 passed
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( ...@@ -17,7 +17,6 @@ const SolutionSchema = new mongoose.Schema(
}, },
file: { file: {
type: String, type: String,
required: true,
}, },
creator: { creator: {
type: String, type: String,
...@@ -27,7 +26,6 @@ const SolutionSchema = new mongoose.Schema( ...@@ -27,7 +26,6 @@ const SolutionSchema = new mongoose.Schema(
{ {
type: mongoose.Schema.Types.ObjectId, type: mongoose.Schema.Types.ObjectId,
ref: 'comment', ref: 'comment',
required: true,
}, },
], ],
isAccepted: { isAccepted: {
......
...@@ -4,17 +4,17 @@ const { isLoggedIn, isAcceptedOrMentor } = require('../../middlewares/auth') ...@@ -4,17 +4,17 @@ const { isLoggedIn, isAcceptedOrMentor } = require('../../middlewares/auth')
const router = Router() const router = Router()
// /api/item // /api/v1/solution
router router
.route('/') .route('/')
.get(isLoggedIn, isAcceptedOrMentor, controllers.default.getMany) .get(isLoggedIn, isAcceptedOrMentor, controllers.default.getMany)
.post(isLoggedIn, isAcceptedOrMentor, controllers.default.createOne) .post(isLoggedIn, isAcceptedOrMentor, controllers.default.createOne)
// /api/item/:id // /api/v1/solution/id/:id
router router
.route('/:id') .route('/id/:id')
.get(isLoggedIn, isAcceptedOrMentor, controllers.default.getOne) .get(isLoggedIn, isAcceptedOrMentor, controllers.default.getOne)
.delete(isLoggedIn, isAcceptedOrMentor, controllers.default.notSupported)
.put(isLoggedIn, isAcceptedOrMentor, controllers.default.notSupported) .put(isLoggedIn, isAcceptedOrMentor, controllers.default.notSupported)
.delete(isLoggedIn, isAcceptedOrMentor, controllers.default.notSupported)
exports.default = router exports.default = router
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment