Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate restx with blueprint based library like openbrokerapi #593

Open
engFelipeMonteiro opened this issue Feb 2, 2024 · 0 comments
Labels
question Further information is requested

Comments

@engFelipeMonteiro
Copy link

How to use flask-restx with a library that export the blueprint already with its paths, like openbrokerapi.

The code that is on my repo is forked from openbrokerapi and served from a restx and gunicorn server. It is a functional exmaple.

With requestly extension or curl I can add a arbitrary 'X-Broker-Api-Version' in the header, but the swagger page doesn't get fully rendered, see the following information 'No operations defined in spec!'.

How can I use flask-restx with this kind of architeture library?

important code:

webserver/web.py

from flask import Flask
from flask_restx import Api
import logging

import openbrokerapi.api as open_api

logger = logging.getLogger(__name__)
app = Flask(__name__)


authorizations = {
    'basic': {
        'type': 'basic',
    }
}



def initialize_app(app):
    app.config['RESTX_VALIDATE'] = True

    app.register_blueprint(get_api(logger, app), url_prefix='/open')

    return app

def get_api(logger, app):
    blueprint = open_api.get_blueprint(None, None, logger)
    api = Api(
                blueprint,
                version='0.1',
                title='title openservicebroker',
                description='',
                doc='/doc/',
                authorizations=authorizations,
                security='basic',
                url_scheme='http'
    )

    ns_exec = api.namespace('open', description='Endpoints')
    api.add_namespace(ns_exec)
    return api

def run():
    return initialize_app(app)

I can run the code with:

 python -m gunicorn webserver.__main__:wsgi

image

@engFelipeMonteiro engFelipeMonteiro added the question Further information is requested label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant