Skip to main content

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"

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


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.0.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

fastapi_yaml-0.1.0-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_yaml-0.1.0.tar.gz.

File metadata

  • Download URL: fastapi_yaml-0.1.0.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

Hashes for fastapi_yaml-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a49958111c355068209be8f817f9053a8e6323603a3ac5259cf33ac255e0c7a0
MD5 f25f3ac2ba5229b650ce87c9f9cf8868
BLAKE2b-256 03abad2a8efb8329bddc0cb83edcfe8d8d1c5d03fa4a6e89eee216c1bac586db

See more details on using hashes here.

File details

Details for the file fastapi_yaml-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fastapi_yaml-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.4 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

Hashes for fastapi_yaml-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5b4f59b4314ca100fc678057dad61af2f7fe087e257fa9620e1752c61c00d06
MD5 f15211546ad00167b03cf2347e36af5c
BLAKE2b-256 f26b3cd770b818a2318e2510693a72d0471276ba24f67d064458bdd2241d7fe3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page