[add]: Swagger Documentation
This commit is contained in:
+16
-4
@@ -1,8 +1,10 @@
|
||||
from flask import Flask
|
||||
import os
|
||||
from flask_swagger_ui import get_swaggerui_blueprint
|
||||
from flask_cors import CORS
|
||||
from app.config import Config
|
||||
from app.routes import api
|
||||
from app.errors import method_not_allowed, unsupported_media_type
|
||||
from app.api.routes import api
|
||||
from app.errors import register_error_handlers
|
||||
|
||||
def create_app():
|
||||
""" Factory function to create a Flask app instance """
|
||||
@@ -14,12 +16,22 @@ def create_app():
|
||||
|
||||
CORS(app)
|
||||
|
||||
# Swagger Doc
|
||||
SWAGGER_URL = app.config.get("SWAGGER_URL")
|
||||
API_URL = app.config.get("API_URL")
|
||||
|
||||
|
||||
# Register blueprints
|
||||
app.register_blueprint(api)
|
||||
|
||||
swagger_ui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL)
|
||||
app.register_blueprint(swagger_ui_blueprint, url_prefix=SWAGGER_URL)
|
||||
|
||||
|
||||
# Error Handlers
|
||||
app.register_error_handler(405, method_not_allowed)
|
||||
app.register_error_handler(415, unsupported_media_type)
|
||||
register_error_handlers(app)
|
||||
|
||||
|
||||
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user