Additional swagger
This commit is contained in:
parent
aef6dd2761
commit
4f86361ee8
@ -1,7 +1,7 @@
|
|||||||
from flask import jsonify, abort, request
|
from flask import jsonify, abort, request
|
||||||
from flask_jwt_extended import jwt_required, get_jwt_identity
|
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
|
from flasgger import swag_from
|
||||||
|
|
||||||
@ -39,6 +39,7 @@ def get_product_info(id: int):
|
|||||||
|
|
||||||
|
|
||||||
@bp_product.route('/create', methods=['POST'])
|
@bp_product.route('/create', methods=['POST'])
|
||||||
|
@swag_from(create_product_swagger)
|
||||||
@jwt_required()
|
@jwt_required()
|
||||||
def create_product_listing():
|
def create_product_listing():
|
||||||
user_id = get_jwt_identity()
|
user_id = get_jwt_identity()
|
||||||
|
@ -4,7 +4,7 @@ from flask import request, abort
|
|||||||
|
|
||||||
from flasgger import swag_from
|
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
|
from app.services.user_service import UserService
|
||||||
|
|
||||||
@ -36,6 +36,7 @@ def login():
|
|||||||
return result, status_code
|
return result, status_code
|
||||||
|
|
||||||
@bp_user.route('/logout', methods=['DELETE'])
|
@bp_user.route('/logout', methods=['DELETE'])
|
||||||
|
@swag_from(logout_swagger)
|
||||||
@jwt_required()
|
@jwt_required()
|
||||||
def logout():
|
def logout():
|
||||||
jwt = get_jwt()
|
jwt = get_jwt()
|
||||||
@ -124,6 +125,7 @@ def update_password():
|
|||||||
return result, status_code
|
return result, status_code
|
||||||
|
|
||||||
@bp_user.route('/delete', methods=['DELETE'])
|
@bp_user.route('/delete', methods=['DELETE'])
|
||||||
|
@swag_from(delete_swagger)
|
||||||
@jwt_required()
|
@jwt_required()
|
||||||
def delete_user():
|
def delete_user():
|
||||||
user_id = get_jwt_identity()
|
user_id = get_jwt_identity()
|
||||||
|
@ -44,3 +44,30 @@ get_product_info_swagger = {
|
|||||||
"500": {"description": "Internal Server Error"}
|
"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"}
|
||||||
|
}
|
||||||
|
}
|
@ -42,4 +42,34 @@ login_swagger = {
|
|||||||
"description": "Password is incorrect"
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user