2024-03-12 20:12:19 +01:00
show_cart_swagger = {
" tags " : [ " Cart " ] ,
2024-03-13 21:40:55 +01:00
" security " : [
2024-03-13 13:43:34 +01:00
{ " JWT " : [ ] }
2024-03-12 20:12:19 +01:00
] ,
2024-03-13 21:40:55 +01:00
" responses " : {
" 200 " : {
2024-03-12 20:12:19 +01:00
" description " : " Current content of user ' s shopping cart " ,
2024-03-13 21:40:55 +01:00
" schema " : {
" items " : {
2024-03-12 20:12:19 +01:00
" count " : { " type " : " int " } ,
" date_added " : { " type " : " string " } ,
" name " : { " type " : " string " } ,
" price_subtotal " : { " type " : " string " }
} ,
2024-03-13 21:40:55 +01:00
" example " : [
2024-03-12 20:12:19 +01:00
{
" count " : 5 ,
" date_added " : " Fri, 08 Mar 2024 08:43:09 GMT " ,
" name " : " Tablet " ,
" price_subtotal " : " 1499.95 "
} ,
{
" count " : 2 ,
" date_added " : " Fri, 08 Mar 2024 06:43:09 GMT " ,
" name " : " Laptop " ,
" price_subtotal " : " 999.95 "
}
]
}
}
}
}
add_to_cart_swagger = {
" tags " : [ " Cart " ] ,
2024-03-13 21:40:55 +01:00
" security " : [
2024-03-13 13:43:34 +01:00
{ " JWT " : [ ] }
] ,
2024-03-13 21:40:55 +01:00
" parameters " : [
2024-03-12 20:12:19 +01:00
{
" name " : " product_id " ,
2024-03-13 13:43:34 +01:00
" description " : " ID of product to add to cart. " ,
2024-03-12 20:12:19 +01:00
" in " : " path " ,
" type " : " int " ,
} ,
{
" name " : " count " ,
2024-03-13 13:43:34 +01:00
" description " : " Count of the products. If not provided, defaults to 1 " ,
2024-03-12 20:12:19 +01:00
" in " : " query " ,
" type " : " int " ,
2024-03-13 13:43:34 +01:00
" default " : 1 ,
" minimum " : 1 ,
2024-03-12 20:12:19 +01:00
" required " : False
}
] ,
2024-03-13 21:40:55 +01:00
" responses " : {
" 200 " : { " description " : " Successfully added a product to cart " } ,
" 400 " : { " description " : " Causes: \n - Count is < 1 " }
}
}
remove_from_cart_swagger = {
" tags " : [ " Cart " ] ,
" security " : [ { " JWT " : [ ] } ] ,
" parameters " : [
2024-03-12 20:12:19 +01:00
{
2024-03-13 21:40:55 +01:00
" name " : " product_id " ,
" in " : " path " ,
" type " : " integer " ,
" description " : " ID of the product to be removed from the cart " ,
" required " : True
}
] ,
" responses " : {
" 200 " : { " description " : " Successfully removed item from the cart " } ,
" 400 " : { " description " : " Bad Request - Invalid input " } ,
" 500 " : { " description " : " Internal Server Error " }
}
}
update_count_in_cart_swagger = {
" tags " : [ " Cart " ] ,
" security " : [ { " JWT " : [ ] } ] ,
" description " : " Updates the count of products in the user ' s cart. If the count is less than or equal to 0, the product will be removed from the cart. " ,
" parameters " : [
{
" name " : " product_id " ,
" in " : " path " ,
" type " : " integer " ,
" description " : " ID of the product to update in the cart " ,
" required " : True
2024-03-12 20:12:19 +01:00
} ,
{
2024-03-13 21:40:55 +01:00
" name " : " count " ,
" in " : " query " ,
" type " : " integer " ,
" description " : " New count of the product in the cart " ,
" required " : True
2024-03-12 20:12:19 +01:00
}
2024-03-13 21:40:55 +01:00
] ,
" responses " : {
" 200 " : { " description " : " Successfully updated item count in the cart " } ,
" 400 " : { " description " : " Bad Request - Invalid input " } ,
" 500 " : { " description " : " Internal Server Error " }
}
}
purchase_swagger = {
" tags " : [ " Cart " ] ,
" security " : [ { " JWT " : [ ] } ] ,
" description " : " Purchases the contents of the user ' s cart. This action creates a new purchase, moves items from the cart to the purchase history, and clears the cart. " ,
" responses " : {
" 200 " : { " description " : " Successfully completed the purchase " } ,
" 400 " : { " description " : " Bad Request - Invalid input or cart is empty " } ,
" 500 " : { " description " : " Internal Server Error " }
2024-03-12 20:12:19 +01:00
}
}