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

Conversation

dudchakk
Copy link
Contributor

@dudchakk dudchakk commented Dec 16, 2024

Description: Improved the Chat schema documentation in Swagger by adding missing fields, fixing existing issues, and updating examples to align with the API's actual behavior.

Added missing fields:

  • deletedFor - an array of users for whom the chat is marked as deleted;
  • latestMessage - a reference to the most recent message in the chat.

Updated examples for chats:

  • get /chats, 200 response - getting all chats for a current user;
  • patch /chats/{id}, 200 response - marking a chat as deleted for the current user.

Additionally: changed the type of user field to object, a reference to a user component.

Corrected chat examples:

image

image

@dudchakk dudchakk added documentation Improvements or additions to documentation Backend labels Dec 16, 2024
@dudchakk dudchakk self-assigned this Dec 16, 2024
@dudchakk dudchakk linked an issue Dec 16, 2024 that may be closed by this pull request
2 tasks
@@ -10,7 +10,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'

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

properties:
user:
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'

@@ -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'

@@ -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

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

properties:
user:
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'

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

type: object
$ref: '#/components/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

Comment on lines +67 to +77
- user:
_id: 67519181170a70623366d30c
firstName: Diana
lastName: Test
role: tutor
- user: 6421d9833cdf38b706756dff
- user:
_id: 673f342709e56a9071f5308c
firstName: valya
lastName: dudchak
professionalSummary: ""
photo: 1733337385040-photofordemo.jpg
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?

Comment on lines +96 to +105
- 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
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(SP: 2) Swagger docs: missed fields in Chat schema
2 participants