Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Title tag including "/" breaks asyncapi schema generation/hosting #1780

Closed
oyste opened this issue Sep 11, 2024 · 1 comment · Fixed by #1786
Closed

Bug: Title tag including "/" breaks asyncapi schema generation/hosting #1780

oyste opened this issue Sep 11, 2024 · 1 comment · Fixed by #1786
Labels
bug Something isn't working

Comments

@oyste
Copy link

oyste commented Sep 11, 2024

Describe the bug
When using publisher/subscriber decorators with a title prop on redis fastapi plugin routers the asyncapi schema generation can fail. This happens specifically when I use "/" in a title name and leads to a blank asyncapi webpage.

How to reproduce
This code fails:

from fastapi.responses import HTMLResponse
from faststream.asyncapi import get_app_schema, get_asyncapi_html
from faststream.redis.fastapi import RedisRouter

router = RedisRouter(url=REDIS_URL, prefix="/websocket", tags=["websocket"])

@router.publisher("datastream", title="websocket/datastream", schema=WsMessageDatastreamResponse)
@router.subscriber("datastream", title="websocket/datastream")
async def datastream_func(auth: WsMessageDatastream):
    pass

@router.get("/new_docs")
async def asyncapi_ui_new() -> HTMLResponse:
    return HTMLResponse(get_asyncapi_html(get_app_schema(router), expand_message_examples=False))

however swapping "/" to ":" makes everything work:

@router.publisher("datastream", title="websocket:datastream", schema=WsMessageDatastreamResponse)
@router.subscriber("datastream", title="websocket:datastream")
async def datastream_func(auth: WsMessageDatastream):
    pass

Expected behavior
No blank webpage when using "/" in a pubsub decorator title.

Observed behavior
Blank Webpage

Screenshots
If applicable, attach screenshots to help illustrate the problem.

Environment
Running FastStream 0.5.23 with CPython 3.12.5 on Linux

Additional context
Could probably be fixed with a regex check somewhere.

@oyste oyste added the bug Something isn't working label Sep 11, 2024
github-merge-queue bot pushed a commit that referenced this issue Sep 12, 2024
@KrySeyt KrySeyt mentioned this issue Sep 14, 2024
13 tasks
@KrySeyt
Copy link
Contributor

KrySeyt commented Sep 20, 2024

It will be nice if there is not an empty page, but a description of the error - asyncapi/asyncapi-react#1048

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants