flask-restful-swagger icon indicating copy to clipboard operation
flask-restful-swagger copied to clipboard

Swagger doesn't play well with restful prefix

Open topless opened this issue 10 years ago • 2 comments

If I define a prefix in my restful initialization restful.Api(app, prefix='/api') the prefix doesn't pass along to swagger. Consider something like this where I want everything that is Rest related to be exposed under the api.

api = swagger.docs(
    restful.Api(app, prefix='/api'),
    basePath='http://localhost:8080',
    apiVersion='0.1',
    api_spec_url='/spec',
)

topless avatar Dec 02 '14 12:12 topless

Hi, Got same issue few days ago while testing without a blueprint. just sent a pull request about this and few other points: i got it ok by adding this line: https://github.com/lounagen/flask-restful-swagger/commit/6c30034f1183ed95772dc004a7e8a935ee15f2da

To get it functional without any change, you can check the /examples/blueprints.py sample file: if you use a blueprint instead of a flask app directly, api_prefix is taken into account well already:

app = Flask(name, static_folder='../static')

my_blueprint1 = Blueprint('my_blueprint1', name)

api1 = swagger.docs(Api(my_blueprint1), apiVersion='0.1', basePath='http://localhost:5000', resourcePath='/', produces=["application/json", "text/html"], api_spec_url='/api/spec', description='Blueprint1 Description')

app.register_blueprint(my_blueprint1, url_prefix='/api1')

regards

lounagen avatar Dec 06 '14 14:12 lounagen

just sent a pull request about this and few other points: i got it ok by adding this line: lounagen@6c30034

This is really help! Thx!

yurtaiev avatar Feb 19 '16 16:02 yurtaiev