Overview
Handle YAML requests with FastAPI.
The package will do the best effort to convert the YAML request to JSON.
All files that are uploaded as multipart/form-data will be concatenated and converted to JSON if the header handle-as-yaml is set to true.
Installation
pip install fastapi-yaml
Usage
FastAPI Code:
from fastapi import FastAPI
from fastapi_yaml import YamlRoute
from pydantic import BaseModel
app = FastAPI()
app.router.route_class = YamlRoute
class Person(BaseModel, extra='forbid'):
name: str
age: int
@app.post("/person")
def person(person: Person):
return f"{person.name} is {person.age} years old"
HTTP Request:
curl --request POST \
--url http://localhost:8000/person \
--header "content-type: application/x-yaml" \
--data "name: John Doe\nage: 42"
Tests
poetry run pytest --cov fastapi_yaml tests/
Coverage
---------- coverage: platform darwin, python 3.11.2-final-0 ----------
Name Stmts Miss Cover
----------------------------------------------
fastapi_yaml/__init__.py 1 0 100%
fastapi_yaml/main.py 20 0 100%
----------------------------------------------
TOTAL 21 0 100%
Metadata
Release files for fastapi-yaml 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fastapi_yaml-0.2.0.tar.gz | 2.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_yaml-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.7 kB
Release files / fastapi_yaml-0.2.0.tar.gz
| Download URL | fastapi_yaml-0.2.0.tar.gz |
|---|---|
| Size | 2.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13fd157f0617f8d19245138740d7620569a8051940babba943d69cb5f5a2ac5c
|
|
BLAKE2b-256 checksum How to use checksums |
db5bef43a4b87278e03059fb6b3f5bcf8d5db713479e0485defc10c418171551
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.2 Darwin/23.0.0
|
Release files / fastapi_yaml-0.2.0-py3-none-any.whl
| Download URL | fastapi_yaml-0.2.0-py3-none-any.whl |
|---|---|
| Size | 2.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
343505a2055d34ab39b64e058760a8adfe8f1ae2110ae0f08e16988506e5c4ee
|
|
BLAKE2b-256 checksum How to use checksums |
55206ee4da0a7c1567fbfd2a2a8cfa6d8f530f18dcdd48e3896380f41917cb72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.2 Darwin/23.0.0
|
Security for fastapi-yaml 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.