-
Notifications
You must be signed in to change notification settings - Fork 328
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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 allowedWithout 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())- Run the code above
- Open http://127.0.0.1:8000/docs/asyncapi in browser
- 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 allowedWithout such handler AsyncAPI documentaion renders without errors.
Environment
Running FastStream 0.6.6 with CPython 3.12.4 on Darwin
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
