sanic-org / sanic-openapi

Easily document your Sanic API with a UI

Home Page:https://sanic-openapi.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]can not render all methods with the same url when use routes of Blueprint way

hsz1273327 opened this issue · comments

Describe the bug
can not render all methods with the same url when use routes of Blueprint way

Screenshots
api-1

To Reproduce
Your code snippet or steps to reproduce the bug.

code as blow:

usernamespace_v1.get("/", strict_slashes=True)(UserListSource_GET)
usernamespace_v1.post("/", strict_slashes=True)(UserListSource_POST)

usernamespace_v1.get("/<uid:int>", strict_slashes=True)(UserSource_GET)
usernamespace_v1.put("/<uid:int>", strict_slashes=True)(UserSource_PUT)
usernamespace_v1.delete("/<uid:int>", strict_slashes=True)(UserSource_DELETE)

Expected behavior

there should have all method sections in user part,but there are only 2 with diffrent url

Environment (please complete the following information):

  • OS: windows
  • Browser: chrome
  • Version 21.3.1

Additional context
Add any other context about the problem here. This might be how to fix this bug or some hint to fix it.

from sanic import Blueprint, Sanic, text
from sanic_openapi import openapi3_blueprint

app = Sanic(__name__)
app.config.API_URI_FILTER = "all"
bp = Blueprint(__name__, version=1)


async def handler(request):
    return text(request.ip)


bp.get("/", strict_slashes=True)(handler)
bp.post("/", strict_slashes=True)(handler)

bp.get("/<uid:int>", strict_slashes=True)(handler)
bp.put("/<uid:int>", strict_slashes=True)(handler)
bp.delete("/<uid:int>", strict_slashes=True)(handler)

app.blueprint(bp)
app.blueprint(openapi3_blueprint)
app.run(port=9999, debug=True)

image

Seems to work okay for me. One thing to note, app.config.API_URI_FILTER = "all" forces the inclusion of routes that end with /. Since you have the empty routes with strict_slashes on, they would be removed.


LMK if I am missing something.

thanks