Skip to content

Bug: AsyncAPI generator produces unrenderable asyncapi.json if subscriber contains filter. #2772

@dmigis

Description

@dmigis

Describe the bug
Faststream 0.6.5/0.6.6 AsyncAPI generator produces unrenderable asyncapi.json if subscriber contains filter.
When I open AsyncAPI doc in browser, I get the following error:

Error: There are errors in your Asyncapi document
0 Referencing in this place is not allowed

Without such handler AsyncAPI documentaion renders without errors.

How to reproduce

import asyncio
from faststream.rabbit import RabbitBroker
from faststream.asgi import AsgiFastStream
from faststream.specification import AsyncAPI

from pydantic import BaseModel


broker = RabbitBroker("amqp://guest:guest@localhost:5672/",)
app = AsgiFastStream(
        broker,
        specification=AsyncAPI(),
        asyncapi_path="/docs/asyncapi",
    )

subscriber = broker.subscriber("test-queue")

class Input(BaseModel):
    name: str

class Inp(BaseModel):
    sname: str

@subscriber(
    filter=lambda msg: msg.content_type == "application/json",
)
async def handle(d: Inp):
    print(d.sname)

@subscriber
async def default_handler(msg: Input):
    print(msg.name)


async def main() -> None:
    await app.run()

if __name__ == "__main__":
    asyncio.run(main())
  1. Run the code above
  2. Open http://127.0.0.1:8000/docs/asyncapi in browser
  3. Get the mentioned error

Expected behavior
I'm expecting to get correctly rendered AsyncAPI documentation in browser

Observed behavior
When I open AsyncAPI doc in browser, I get the following error:

Error: There are errors in your Asyncapi document
0 Referencing in this place is not allowed

Without such handler AsyncAPI documentaion renders without errors.

Screenshots
Image

Environment
Running FastStream 0.6.6 with CPython 3.12.4 on Darwin

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions