No project description provided
Project description
Overview
Handle YAML requests with FastAPI.
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%
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fastapi_yaml-0.1.1.tar.gz
(1.7 kB
view details)
Built Distribution
File details
Details for the file fastapi_yaml-0.1.1.tar.gz
.
File metadata
- Download URL: fastapi_yaml-0.1.1.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c58e7b5eeba555ba70bb92ed7d7e222a043a6f4c2d488947368a8e9000f18a9 |
|
MD5 | e07b7c34ec56e126fcb763bee45e327e |
|
BLAKE2b-256 | 44e751182e37a3adc198de286c2b36ceaef1fe4dc51072508700e87faae9e366 |
File details
Details for the file fastapi_yaml-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: fastapi_yaml-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c29a9ba351a7800ad7be7e322b3d13fc3e8f1db8b9836b1f6b17d49022d09ed7 |
|
MD5 | 67d41b835b5a5d88e2eda6a1a954c7ba |
|
BLAKE2b-256 | 8fdbf134c6b3e20c3b99e2deb1417ccc4b5cf5e4c3adb7e19ce74a859ee549ff |