Additional swagger

This commit is contained in:
Thastertyn 2024-05-02 20:44:26 +02:00
parent aef6dd2761
commit 4f86361ee8
4 changed files with 62 additions and 2 deletions

View File

@ -1,7 +1,7 @@
from flask import jsonify, abort, request
from flask_jwt_extended import jwt_required, get_jwt_identity
from app.doc.product_swag import get_products_swagger, get_product_info_swagger
from app.doc.product_swag import get_products_swagger, get_product_info_swagger, create_product_swagger
from flasgger import swag_from
@ -39,6 +39,7 @@ def get_product_info(id: int):
@bp_product.route('/create', methods=['POST'])
@swag_from(create_product_swagger)
@jwt_required()
def create_product_listing():
user_id = get_jwt_identity()

View File

@ -4,7 +4,7 @@ from flask import request, abort
from flasgger import swag_from
from app.doc.user_swag import login_swagger
from app.doc.user_swag import login_swagger, logout_swagger, delete_swagger
from app.services.user_service import UserService
@ -36,6 +36,7 @@ def login():
return result, status_code
@bp_user.route('/logout', methods=['DELETE'])
@swag_from(logout_swagger)
@jwt_required()
def logout():
jwt = get_jwt()
@ -124,6 +125,7 @@ def update_password():
return result, status_code
@bp_user.route('/delete', methods=['DELETE'])
@swag_from(delete_swagger)
@jwt_required()
def delete_user():
user_id = get_jwt_identity()

View File

@ -44,3 +44,30 @@ get_product_info_swagger = {
"500": {"description": "Internal Server Error"}
}
}
create_product_swagger = {
"methods": ["POST"],
"tags": ["Products"],
"security": [{"JWT": []}],
"parameters": [
{
"name": "name",
"in": "body",
"type": "string",
"description": "Name for the new product",
"required": True
},
{
"name": "price",
"in": "body",
"type": "float",
"description": "Price of the product",
"required": True
}
],
"responses": {
"200": {"description": "Successfully fetched product information"},
"400": {"description": "Bad Request - Invalid input or missing input"},
"500": {"description": "Internal Server Error"}
}
}

View File

@ -42,4 +42,34 @@ login_swagger = {
"description": "Password is incorrect"
}
}
}
logout_swagger = {
"methods": ["DELETE"],
"tags": ["User"],
"security": [{"JWT": []}],
"description": "Logs out the user via provided JWT token",
"parameters": [],
"responses":
{
"200":
{
"description": "User successfully logged out"
}
}
}
delete_swagger = {
"methods": ["DELETE"],
"tags": ["User"],
"security": [{"JWT": []}],
"description": "Deletes a user via JWT token",
"parameters": [],
"responses":
{
"200":
{
"description": "User successfully deleted out"
}
}
}