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

Add missed fields in chat schema & update examples in Swagger docs #1068

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
26 changes: 24 additions & 2 deletions docs/chat/chat-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ definitions:
type: object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Members is not an object, its an array, check src\models\chat.js

properties:
user:
type: string
type: object
$ref: '#/components/user'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ref: '#/components/user'
$ref: '#/definitions/user'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it is not just user, check populate method in service. Probably you will have to create new object-schema for it (inside chats).
image

role:
type: string
Expand All @@ -20,6 +20,17 @@ definitions:
updatedAt:
type: string
format: date-time
deletedFor:
type: array
items:
type: object
properties:
user:
type: object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably its just a string, check real API, please

$ref: '#/components/user'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ref: '#/components/user'
$ref: '#/definitions/user'

latestMessage:
type: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not a string, its an object. Check population in getChats method in src\models\chat.js file

$ref: '#/definitions/message'
chatBody:
type: object
properties:
Expand All @@ -36,7 +47,7 @@ definitions:
type: object
properties:
user:
type: string
type: object
ref: '#/components/user'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ref: '#/components/user'
ref: '#/definitions/user'

role:
type: string
Expand All @@ -46,3 +57,14 @@ definitions:
updatedAt:
type: string
format: date-time
deletedFor:
type: array
items:
type: object
properties:
user:
type: object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, check the chat service, probably there are only ids, so it would be a string

$ref: '#/components/user'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ref: '#/components/user'
$ref: '#/definitions/user'

latestMessage:
type: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're assigning an object to a string, it's not correct

$ref: '#/definitions/message'
79 changes: 62 additions & 17 deletions docs/chat/chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,62 @@ paths:
schema:
$ref: '#/definitions/chat'
example:
- _id: 64a54c6c7bca605aaf2da66c
- _id: 67604def753afa7bbd3bd98a
members:
- user: 6491d003a634c3c427b69daa
- user:
_id: 67519181170a70623366d30c
firstName: Diana
lastName: Test
role: tutor
- user: 6421d9833cdf38b706756dff
- user:
_id: 673f342709e56a9071f5308c
firstName: valya
lastName: dudchak
professionalSummary: ""
photo: 1733337385040-photofordemo.jpg
Comment on lines +67 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why user have different fields in each example?

role: student
createdAt: 2024-08-01T13:25:36.292Z
updatedAt: 2024-08-01T13:25:36.292Z
- _id: 64a54c6c7bca605aaf2da6df
createdAt: 2024-12-16T15:57:35.632Z
updatedAt: 2024-12-16T15:57:35.949Z
deletedFor: []
latestMessage:
_id: 67604def753afa7bbd3bd98c
author:
_id: 67519181170a70623366d30c
firstName: Diana
lastName: Test
authorRole: tutor
text: hi test message
chat: 67604def753afa7bbd3bd98a
clearedFor: []
createdAt: 2024-12-16T15:57:35.862Z
updatedAt: 2024-12-16T15:57:35.862Z
- _id: 67604eca753afa7bbd3bd9c1
members:
- user: 6491d003a634c3c427b69dda
role: student
- user: 6421d9833cdf38b706756d22
- user:
_id: 67519181170a70623366d30c
firstName: Diana
lastName: Test
role: tutor
createdAt: 2024-08-01T13:25:36.292Z
updatedAt: 2024-08-01T13:25:36.292Z
- user:
_id: 6735ff2cc8f5e44cc3de002d
firstName: Pavlo
lastName: Butynets
role: student
Comment on lines +96 to +105
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each member should contain those fields:
image

createdAt: 2024-12-16T16:01:14.667Z
updatedAt: 2024-12-16T16:01:14.991Z
deletedFor: []
latestMessage:
_id: 67604eca753afa7bbd3bd9c3
author:
_id: 67519181170a70623366d30c
firstName: Diana
lastName: Test
authorRole: tutor
text: hi test
chat: 67604eca753afa7bbd3bd9c1
clearedFor: []
createdAt: 2024-12-16T16:01:14.916Z
updatedAt: 2024-12-16T16:01:14.916Z
/chats/{id}/messages:
get:
security:
Expand Down Expand Up @@ -328,12 +368,17 @@ paths:
schema:
$ref: '#/definitions/chat'
example:
- _id: 64a54c6c7bca605aaf2da66c
members:
[{ user: 6491d003a634c3c427b69daa, role: tutor }, { user: 6421d9833cdf38b706756dff, role: student }]
deletedFor: [{ user: 6491d003a634c3c427b69daa }]
createdAt: 2023-20-01T13:25:36.292Z
updatedAt: 2023-20-01T13:25:36.292Z
_id: 67604eca753afa7bbd3bd9c1
members:
- user: 67519181170a70623366d30c
role: tutor
- user: 6735ff2cc8f5e44cc3de002d
role: student
deletedFor:
- user: 67519181170a70623366d30c
createdAt: 2024-12-16T16:01:14.667Z
updatedAt: 2024-12-16T16:20:01.463Z
latestMessage: 67604eca753afa7bbd3bd9c3
400:
description: Bad Request
content:
Expand Down
Loading