sanic-org / sanic-openapi

Easily document your Sanic API with a UI
https://sanic-openapi.readthedocs.io/
MIT License
505 stars 108 forks source link

[Bug] /swagger returns 404 #173

Closed kershnerd closed 4 years ago

kershnerd commented 4 years ago

Describe the bug When I hit /swagger or /swagger/, I get 404. I stripped down my entire app to be just this:

from sanic import Sanic, response
from sanic_openapi import swagger_blueprint

app = Sanic()
app.blueprint(swagger_blueprint)

@app.route("/", methods=["GET"])
async def index(request):
    return response.json(
        {'message': 'Backend Service !'},
        headers={'X-Served-By': 'sanic'},
        status=200
    )

@app.route("/backend", methods=["GET"])
async def index(request):
    return response.html('<p>Backend</p>')

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5004)

I can't tell if this is because I am running on docker behind nginx or because I have installed sanic_openapi incorrectly.

All request from nginx to: http://localhost/backend should be routing to: http://backend:5004 so hitting http://localhost/backend/swagger should be all I need.

I keep getting 404. All requests to http://localhost/backend correctly response backend.

Environment (please complete the following information):

kershnerd commented 4 years ago

I am pretty sure this is a docker issue so I will close.