Skip to content

Commit

Permalink
Updated getQuestionById service and added docs for it in Swagger (#663)
Browse files Browse the repository at this point in the history
Co-authored-by: Анна-Марія <[email protected]>
  • Loading branch information
Marichka0406 and Анна-Марія authored Dec 19, 2023
1 parent f8b9144 commit 1888eff
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
76 changes: 76 additions & 0 deletions docs/questions/question.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,82 @@ paths:
code: FORBIDDEN
message: You do not have permission to perform this action.
/questions/{id}:
get:
security:
- cookieAuth: []
tags:
- Questions
summary: Find and return question by ID
description: Finds and returns a question with the specified ID.
produces:
- application/json
parameters:
- name: id
in: path
required: true
description: ID of the question that needs to be fetched
type: string
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#definitions/question'
example:
_id: 63ec1cd51e9d781cdb6f4b14
title: WebAssembly
text: What is the chemical symbol for water?
answers:
- text: First answer
isCorrect: true
- text: Second answer
isCorrect: false
type: multipleChoice
category: 6477007a6fa4d05e1a800ce1
author: 63da8767c9ad4c9a0b0eacd3
createdAt: 2023-02-14T23:44:21.334Z
updatedAt: 2023-02-14T23:44:21.334Z
400:
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/Error'
example:
status: 400
code: INVALID_ID
message: ID is invalid.
401:
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/Error'
example:
status: 401
code: UNAUTHORIZED
message: The requested URL requires user authorization.
403:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/Error'
example:
status: 403
code: FORBIDDEN
message: You do not have permission to perform this action.
404:
description: Not Found
content:
application/json:
schema:
$ref: '#/components/Error'
example:
status: 404
code: DOCUMENT_NOT_FOUND
message: Question with the specified id was not found.
patch:
security:
- cookieAuth: []
Expand Down
2 changes: 1 addition & 1 deletion services/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const questionService = {
},

getQuestionById: async (id) => {
return await Question.findById(id).populate({ path: 'category', select: 'name' }).lean().exec()
return await Question.findById(id).lean().exec()
},

createQuestion: async (author, data) => {
Expand Down

0 comments on commit 1888eff

Please sign in to comment.