Replies: 1 comment
-
@nrydanov I think, you tried to send a string, but your annotation expects So, the following example works fine import json
from pydantic import BaseModel
from faststream import FastStream, Logger
from faststream.kafka import KafkaBroker
broker = KafkaBroker()
app = FastStream(broker)
class Input(BaseModel):
body: str
@broker.subscriber("in")
async def scrape(request: Input, logger: Logger):
logger.info(request)
@app.after_startup
async def _():
await broker._producer._producer.send(
"in",
json.dumps({"body": "Hello World!"}).encode(),
) To consume string body just use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sorry, but currently there's not so much docs in web and I need help.
I'm trying to use Faststream with Pydantic and accept model for request handler like this:
however, when I send a message with kcat (even with -J flag) I see Pydantic validation error saying input type is bytes which is not acceptable one.
What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions