sanic-openapi icon indicating copy to clipboard operation
sanic-openapi copied to clipboard

Duplicate route names error

Open m-aliansari opened this issue 2 years ago • 3 comments

Describe the bug The getting started example in the sanic-openapi docs does not appear to be working with the latest sanic version. It's giving duplicate route names error. I used the code in this URL https://sanic-openapi.readthedocs.io/en/stable/sanic_openapi2/index.html. Also there is a simple error that sanic doesn't allow spaces in the app name, so the line app = Sanic("Hello world") should be changed to app = Sanic("HelloWorld"). I am attaching the error below.

Screenshots image

To Reproduce

from sanic import Sanic
from sanic.response import json
from sanic_openapi import openapi2_blueprint

app = Sanic("HelloWorld")
app.blueprint(openapi2_blueprint)


@app.route("/")
async def test(request):
    return json({"hello": "world"})


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

Environment:

  • OS: Windows 10

m-aliansari avatar May 11 '23 17:05 m-aliansari

This error occurs here, because sanic of name conflict:

oas3_blueprint.static("/", dir_path + "/index.html", strict_slashes=True)
 oas3_blueprint.static("", dir_path)

Pass names throw params not very good idea, I think. Maybe just add names like swagger_index and swagger and possibility to set it throw env variables. What do you think? I can do pull request?

adonskoi avatar May 28 '23 06:05 adonskoi

Yeah, adding a name should solve it. TBH, this project is not supported any longer since all of the OAS3 stuff is in Sanic Extensions now. It is still here for anyone still using OAS2. But, we will not continue to support and/or maintain it indefinitely into the future.

If you would like to make a PR, I am happy to accept it. But, I'd suggest moving to Sanic Extensions where full support will be guaranteed by the core team.

ahopkins avatar May 28 '23 11:05 ahopkins

Yeah I saw that it's deprecated now, and I migrated to use sanic extensions, so, I don't have that problem now. It's up to you guys if you want to solve this bug or not. Thanks anyway.

m-aliansari avatar May 28 '23 17:05 m-aliansari