Skip to content

Commit

Permalink
[REM] Delete swagger feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rivo2302 committed Jan 8, 2023
1 parent 6ee45f9 commit 027101e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 37 deletions.
1 change: 0 additions & 1 deletion api/ressources/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pydantic import BaseModel
from typing import Optional, List
from config import ODOO
from flasgger.utils import swag_from
from flask_pydantic import validate

rpc = RPC(ODOO)
Expand Down
14 changes: 2 additions & 12 deletions api/ressources/product_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@
from utils.tools import drop_false
import json
from config import ODOO
from flasgger.utils import swag_from
from docs.category import list_specs, detailed_specs

rpc = RPC(ODOO)
category = Blueprint("category", __name__, url_prefix="/category")


@category.route(
"/",
methods=["GET"],
)
@swag_from(list_specs, methods=["GET"])
@category.route("/", methods=["GET"])
def get_list_category():
"""Get list of product category."""
categories = rpc.execute(
Expand All @@ -33,11 +27,7 @@ def get_list_category():
)


@category.route(
"/<int:id>",
methods=["GET"],
)
@swag_from(detailed_specs, methods=["GET"])
@category.route("/<int:id>", methods=["GET"])
def get_detail_category(id):
category = rpc.execute(
"product.category",
Expand Down
4 changes: 0 additions & 4 deletions api/ressources/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
from utils.tools import drop_false
import json
from config import ODOO
from flasgger.utils import swag_from
from docs.product import list_specs, detailed_specs

rpc = RPC(ODOO)
product = Blueprint("product", __name__, url_prefix="/product")


@product.route("/", methods=["GET"])
@swag_from(list_specs, methods=["GET"])
def get_list_product():
products = rpc.execute(
"product.template",
Expand Down Expand Up @@ -42,7 +39,6 @@ def get_list_product():


@product.route("/<int:id>", methods=["GET"])
@swag_from(detailed_specs, methods=["GET"])
def get_detail_product(id):
product = rpc.execute(
"product.template",
Expand Down
2 changes: 1 addition & 1 deletion api/ressources/res_partner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Blueprint, Response, request
from flask import Blueprint, Response
from utils.rpc import RPC
from utils.tools import drop_false
import json
Expand Down
24 changes: 7 additions & 17 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from flask import Flask, Response,request,jsonify
from flasgger import Swagger
from flask import Flask, Response, request, jsonify
from api.ressources import product, category, partner, sale, account
from docs import template
from os import environ as env


Expand All @@ -15,9 +13,6 @@
app.register_blueprint(account)


# Install swagger
swagger = Swagger(app, template=template)

# Error handler
@app.errorhandler(404)
def not_found(error):
Expand All @@ -28,14 +23,9 @@ def not_found(error):
# Check token befor any request , the token is set in the .env file
@app.before_request
def header_required():
# Allow access to swagger
if request.path == '/apidocs/' or "flasgger" or "apispec" in request.path:
return
if 'access-token' not in request.headers:
return jsonify({'error': 'A valid access-token is missing'}), 403
token = request.headers['access-token']
if token != env.get('TOKEN'):
return jsonify({'error': 'Invalid access-token'}), 403




if "access-token" not in request.headers:
return jsonify({"error": "A valid access-token is missing"}), 403
token = request.headers["access-token"]
if token != env.get("TOKEN"):
return jsonify({"error": "Invalid access-token"}), 403
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
flask
gunicorn
pydantic
flask_pydantic
flasgger
flask_pydantic

0 comments on commit 027101e

Please sign in to comment.