Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed broken endpoint & swagger #659

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions docs/category/category.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ paths:
status: 404
code: DOCUMENT_NOT_FOUND
message: Category with the specified id was not found.
/categories/{categoryId}/subject/{subjectId}/price-range:
/categories/{categoryId}/subjects/{subjectId}/price-range:
get:
security:
- cookieAuth: []
Expand All @@ -249,12 +249,22 @@ paths:
parameters:
- name: query
in: path
required: true
description: The query with the role "?authorRole=tutor" or "?authorRole=student"
required: false
description: The query with the role "?authorRole=tutor" or "?authorRole=student" (tutor selected by default if query is not provided)
type: string
enum:
- student
- tutor
- name: categoryId
in: path
required: false
description: ID of the offers category
type: string
- name: subjectId
in: path
required: false
description: ID of the category subject
type: string
responses:
200:
description: OK
Expand Down
9 changes: 9 additions & 0 deletions docs/user/user-schema.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
definitions:
userStatsResponse:
type: array
items:
type: object
properties:
rating:
type: number
count:
type: number
users:
type: array
items:
Expand Down
20 changes: 19 additions & 1 deletion docs/user/user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,19 @@ paths:
description: Finds and returns a review statistics for a user with the specified ID and role.
produces:
- application/json
parameters:
- name: id
in: path
required: true
description: ID of the user for which we are looking for review statistics
type: string
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/definitions/reviewResponse'
$ref: '#/definitions/userStatsResponse'
example:
stats: [{ rating: 5, count: 1 }, { rating: 3, count: 1 }]
400:
Expand Down Expand Up @@ -604,6 +610,12 @@ paths:
description: Finds and returns all cooperations for a user with the specified ID.
produces:
- application/json
parameters:
- name: id
in: path
required: true
description: ID of the user for whom we trying to find cooperations
type: string
responses:
200:
description: OK
Expand Down Expand Up @@ -668,6 +680,12 @@ paths:
description: Finds and returns all offers for a user with the specified ID.
produces:
- application/json
parameters:
- name: id
in: path
required: true
description: ID of the user for whom we trying to find offers
type: string
responses:
200:
description: OK
Expand Down
8 changes: 4 additions & 4 deletions utils/categories/conditionCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const mongoose = require('mongoose')
const condition = (data) => {
const condition = {}

if (data.catid) {
condition.categoryId = mongoose.Types.ObjectId(data.catid)
if (data.categoryId) {
condition.category = mongoose.Types.ObjectId(data.categoryId)
}

if (data.subid) {
condition.subjectId = mongoose.Types.ObjectId(data.subid)
if (data.subjectId) {
condition.subject = mongoose.Types.ObjectId(data.subjectId)
}

if (data.authorRole) {
Expand Down
Loading