Skip to main content

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

Project description

CircleCI codecov Downloads GitHub Pipenv locked Python version GitHub

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

Uploaded Source

File details

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

File metadata

  • Download URL: fastapi_camelcase-1.0.4.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.8.0 tqdm/4.62.3 CPython/3.8.3

File hashes

Hashes for fastapi_camelcase-1.0.4.tar.gz
Algorithm Hash digest
SHA256 015264aac385bdb99701b021e10c12c92f52a2455f1dba1d1875fb440a37854e
MD5 22c0b4735dd4eb3a7481f0b019ab7cfb
BLAKE2b-256 1b03ae30f7fcfad5a084a0a9f1bb5222c58dbc00ebfb5a1198ad8131191c61a8

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