You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class AnimalView(Resource):
@swagger.operation(notes="get an animal by ID", )
def get(self, animal_id):
return build_data_response({}, 200)
And I simply register this view with:
def register_views(api):
from app.views.animal import AnimalView
from flask_restful_swagger import swagger, registry
api = swagger.docs(
api,
apiVersion="0.1",
basePath="http://localhost:5000/api/v1",
resourcePath="/",
produces=["application/json", "text/html"],
api_spec_url="/spec3",
description="A Basic API")
But this doesn't work. It seems like the library cannot find the static files. I debugged the flask-restful-swagger code and found out that the prefix for x-api-prefix needs to be set. So I changed the code to:
def register_views(api):
from app.views.animal import AnimalView
from flask_restful_swagger import swagger, registry
api = swagger.docs(
api,
apiVersion="0.1",
basePath="http://localhost:5000/api/v1",
resourcePath="/",
produces=["application/json", "text/html"],
api_spec_url="/spec",
description="A Basic API")
api.add_resource(AnimalView, "/animals/<animal_id>")
registry["app"]["x-api-prefix"] = "/api/v1"
And now it works. So shouldn't the x-api-prefix become a parameter of docs()? So for example to call it like this:
I have an app with a URL prefix:
api = Api(app, prefix="/api/v1")
And a simple view:
And I simply register this view with:
But this doesn't work. It seems like the library cannot find the static files. I debugged the flask-restful-swagger code and found out that the prefix for
x-api-prefix
needs to be set. So I changed the code to:And now it works. So shouldn't the
x-api-prefix
become a parameter ofdocs()
? So for example to call it like this:Because at the moment it is a ("minor") hack. Or did I overlooked something?
The text was updated successfully, but these errors were encountered: