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

Implemented: code to define success response schema(#85zrhhcgr) #47

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ymaheshwari1
Copy link
Contributor

@ymaheshwari1 ymaheshwari1 commented Jan 9, 2023

Related Issues

Closes #38

Short Description and Why It's Useful

Added two different approaches for defining schema

  1. ) Using Generics:

Defined an interface using generics, so as the same can be directly used for different type of success responses. Also added another property as object count that contains indexable types to contains different types of count like total (for total number of products), matches (in case when we are fetching resps as groups).

2.) By extending interface

Screenshots of Visual Changes before/after (If There Are Any)

Contribution and Currently Important Rules Acceptance

interface SuccessResponse<Type> {
list: Type[];
count: {
[x: string]: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have attributes in count

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added total and groups attributes at root of schema.

src/types/index.ts Outdated Show resolved Hide resolved
@ymaheshwari1 ymaheshwari1 changed the title Implemented: code to define success response schema Implemented: code to define success response schema(#85zrhhcgr) Jan 9, 2023
…ndexable types from the schema, also added the total, groups property at root(#85zrhhcgr)
@@ -39,6 +39,12 @@ interface Response {
serverResponse?: any;
}

interface SuccessResponse<Type> {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should define practices for list and object responses, and name accordingly

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

Successfully merging this pull request may close these issues.

Define success response type
2 participants