Skip to main content

Package provides an easy way to have camelcase request/response bodies for Pydantic

Project description

CircleCI

Fastapi Camelcase

Package for providing a class for camelizing request and response bodies for fastapi while keeping your python code snake cased.

Full documentation can be found here

How to install

pip install fastapi-camelcase

Dependencies

pydantic
pyhumps

How to use

# using CamelModel instead of Pydantic BaseModel
from fastapi_camelcase import CamelModel


class User(CamelModel):
    first_name: str
    last_name: str
    age: int

How to use (full example)

import uvicorn
from fastapi import FastAPI
from fastapi_camelcase import CamelModel


class User(CamelModel):
    first_name: str
    last_name: str
    age: int


app = FastAPI()


@app.get("/user/get", response_model=User)
async def get_user():
    return User(first_name="John", last_name="Doe", age=30)


@app.post("/user/create", response_model=User)
async def create_user(user: User):
    return user


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)

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_camelcase-0.1.2.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file fastapi_camelcase-0.1.2.tar.gz.

File metadata

  • Download URL: fastapi_camelcase-0.1.2.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

File hashes

Hashes for fastapi_camelcase-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8f834ad0cc4784ff48377d38c7125a8f8ccf2aba9ec0e1c608bb24f31f4b7dae
MD5 a02a086c5b2d62661c1a1e0c22fa25c6
BLAKE2b-256 67d9304261fb14334a7eed1dad95904f96f23055f2ab55e070aed7e3d1de7c98

See more details on using hashes here.

Supported by

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