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

spec.html only showing first blueprint registered

Open kathychurch opened this issue 9 years ago • 6 comments

Trying to figure out what I have done wrong. I am registering 3 different blueprints into my app, but the spec.html page only ever shows the operations for whichever one I registered first. So in my example snippets here, only the operations from blueprint_1 end up in the spec.

blueprint_1.py

blueprint = Blueprint('blueprint_1', __name__)
api = swagger.docs(Api(blueprint), apiVersion='1.0', api_spec_url="/v1.0/spec", description="API Documentation")

blueprint_2.py

blueprint = Blueprint('blueprint_2', __name__)
api = swagger.docs(Api(blueprint), apiVersion='1.0', api_spec_url="/v1.0/spec", description="API Documentation")

blueprint_3.py

blueprint = Blueprint('blueprint_3', __name__)
api = swagger.docs(Api(blueprint), apiVersion='1.0', api_spec_url="/v1.0/spec", description="API Documentation")

app.py

app.register_blueprint(blueprint_1.blueprint, url_prefix='/api')
app.register_blueprint(blueprint_2.blueprint, url_prefix='/api')
app.register_blueprint(blueprint_3.blueprint, url_prefix='/api')

kathychurch avatar Feb 21 '15 04:02 kathychurch

hi @jonny166 flask seems to register only once a blueprint on a particular url prefix in the examples/blueprints.py file, url_prefix are different for each blueprint, and you put '/api' for each. that's could be the point that

@app.route('/docs')
def docs():
  return redirect('/static/docs.html')


if __name__ == '__main__':
  TodoItemWithResourceFields()
  TodoItem(1, 2, '3')
  app.register_blueprint(my_blueprint1, url_prefix='/api1')
  app.register_blueprint(my_blueprint2, url_prefix='/api2')

lounagen avatar Feb 21 '15 09:02 lounagen

So what is the proper way to get the entire app to render on a single spec.html page? On Feb 21, 2015 4:49 AM, "lounagen" [email protected] wrote:

hi @jonny166 https://github.com/jonny166 flask seems to register only once a blueprint on a particular url prefix in the examples/blueprints.py file, url_prefix are different for each blueprint, and you put '/api' for each. that's could be the point that

@app.route('/docs') def docs(): return redirect('/static/docs.html')

if name == 'main': TodoItemWithResourceFields() TodoItem(1, 2, '3') app.register_blueprint(my_blueprint1, url_prefix='/api1') app.register_blueprint(my_blueprint2, url_prefix='/api2')

— Reply to this email directly or view it on GitHub https://github.com/rantav/flask-restful-swagger/issues/74#issuecomment-75364453 .

kathychurch avatar Feb 21 '15 13:02 kathychurch

I have the same issue. Does anyone know how to organize a moduled API service so api/spec.html will be generated for all modules?

frol avatar Sep 26 '15 18:09 frol

I also have the same problem. Any solution available now?

kamelnebhi avatar Apr 28 '16 16:04 kamelnebhi

I would like to know the same ...

cheizer avatar May 09 '16 20:05 cheizer

Just for your information, since I found this project I have also tried two others that I can recommend now since this one is kind of dead:

frol avatar May 10 '16 10:05 frol