CSCI-GA-2820-FA24-003 / products

NYU DevOps Products Service Fall 2024
Apache License 2.0
0 stars 1 forks source link

Add Sorting by Price to Read/List Products API #16

Open niveditashankaranarayanan opened 3 weeks ago

niveditashankaranarayanan commented 3 weeks ago

Description: Allow users to sort products by price in ascending or descending order using the sort=price and order=asc|desc query parameters.

As a user, I want to sort products by price, so that I can view the cheapest or most expensive items first.

Acceptance Criteria:
The API supports sorting of products by price in both ascending (asc) and descending (desc) order using the sort=price and order query parameters.
If no order parameter is provided, default to sorting by price in ascending order.
If the sort=price parameter is not provided, return products in their default order (e.g., based on their natural insertion into the list).
The sort functionality should work in conjunction with other query parameters (e.g., search by name or filtering by price range).

**Example:**
Request (Ascending order by price):
GET /products?sort=price&order=asc

Response (200 OK):

[ { "id": 1, "name": "Product A", "price": 50 }, { "id": 2, "name": "Product B", "price": 100 }, { "id": 3, "name": "Product C", "price": 200 } ]

savarchaturvedi commented 2 weeks ago

Updated the story with the correct format and added examples to it.