1
0
Fork 0
mirror of https://github.com/dancojocaru2000/foxbank.git synced 2025-02-24 01:19:35 +02:00
foxbank/server/foxbank_server/apis/__init__.py

32 lines
985 B
Python
Raw Normal View History

from flask import Flask
from flask_smorest import Api
from .accounts import bp as acc_bp
from .login import bp as login_bp
from .transactions import bp as transactions_bp
2021-12-29 20:16:58 +02:00
class ApiWithErr(Api):
def handle_http_exception(self, error):
if error.data and error.data['response']:
return error.data['response']
return super().handle_http_exception(error)
def init_apis(app: Flask):
2021-12-29 20:16:58 +02:00
api = ApiWithErr(app, spec_kwargs={
'title': 'FoxBank',
'version': '1',
'openapi_version': '3.0.0',
'components': {
'securitySchemes': {
'Token': {
'type': 'http',
'scheme': 'bearer',
'bearerFormat': 'Token ',
}
}
},
})
api.register_blueprint(login_bp, url_prefix='/login')
api.register_blueprint(acc_bp, url_prefix='/accounts')
api.register_blueprint(transactions_bp, url_prefix='/transactions')