fastapi
fastapi copied to clipboard
Can I use fastapi when the input is in AVRO format and how can I then use it?
First Check
- [X] I added a very descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I searched the FastAPI documentation, with the integrated search.
- [X] I already searched in Google "How to X in FastAPI" and didn't find any information.
- [X] I already read and followed all the tutorial in the docs and didn't find an answer.
- [X] I already checked if it is not related to FastAPI but to Pydantic.
- [X] I already checked if it is not related to FastAPI but to Swagger UI.
- [X] I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- [X] I commit to help with one of those options 👆
Example Code
n/a
Description
For the project I am working the data is formatted as describe for the AVRO project (see https://avro.apache.org/docs/1.10.2/gettingstartedpython.html ). After doing some searching on google, fastapi doc and github I could not find anything. So reaching out to you.
Operating System
Linux
Operating System Details
SLES 15 SP3
FastAPI Version
0.63.0
Python Version
Python 3.6.15
Additional Context
No response
Hi @mbrookhuis, please provide an example on your attempt to use avro schema. I know you could use it with pydantic with pydantic-avro, but I am not sure how that would behave with FastAPI. You could try and share results/issues.
Perhaps the payload being Avro? I don't see why it couldn't be done with a midlewar
Yeah this question is very broad. You basically have two options:
- AVRO as string; since Avro is basically JSON in syntax, you could just provide it as a body like
{"avro_string":"{u'favorite_color': None, u'favorite_number': 256, u'name': u'Alyssa'}"}
and parse it from there. - AVRO as binary file: if you receive it as a binary file, you can use the normal
File
orUploadFile
stuff in FastAPI and parse it with any of the standard libraries dealing with Avro.
I'm assuming the binary and associated mime type is the way to go