Swagger documentation progress

This commit is contained in:
Thastertyn committed 2024-03-13 21:40:55 +01:00
1 parent f259aa3993
commit b1fb6ee099
4 files changed
+96 -25

No files matched your search

+64 -22
View File
@@ -1,25 +1,19 @@
show_cart_swagger = {
"tags": ["Cart"],
"security":
[
"security": [
{"JWT": []}
],
"responses":
{
"200":
{
"responses": {
"200": {
"description": "Current content of user's shopping cart",
"schema":
{
"items":
{
"schema": {
"items": {
"count": {"type": "int"},
"date_added": {"type": "string"},
"name": {"type": "string"},
"price_subtotal": {"type": "string"}
},
"example":
[
"example": [
{
"count": 5,
"date_added": "Fri, 08 Mar 2024 08:43:09 GMT",
@@ -40,12 +34,10 @@ show_cart_swagger = {
add_to_cart_swagger ={
"tags": ["Cart"],
"security":
[
"security": [
{"JWT": []}
],
"parameters":
[
"parameters": [
{
"name": "product_id",
"description": "ID of product to add to cart.",
@@ -62,15 +54,65 @@ add_to_cart_swagger ={
"required": False
}
],
"responses":
{
"200":
"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": [
{
"description": "Successfully added a product to cart"
"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
},
"400":
{
"description": "Causes:\n- Count is < 1"
"name": "count",
"in": "query",
"type": "integer",
"description": "New count of the product in the cart",
"required": True
}
],
"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"}
}
}
+26 -1
View File
@@ -18,4 +18,29 @@ get_products_swagger = {
}
}
}
}
}
get_product_info_swagger = {
"tags": ["Products"],
"parameters": [
{
"name": "id",
"in": "path",
"type": "integer",
"description": "ID of the product to fetch information for",
"required": True
},
{
"name": "fields",
"in": "query",
"type": "string",
"description": "Comma-separated list of fields to include in the response",
"required": False
}
],
"responses": {
"200": {"description": "Successfully fetched product information"},
"400": {"description": "Bad Request - Invalid input or product doesn't exist"},
"500": {"description": "Internal Server Error"}
}
}