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

Uploaded Source

File details

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

File metadata

  • Download URL: fastapi_camelcase-2.0.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.9

File hashes

Hashes for fastapi_camelcase-2.0.0.tar.gz
Algorithm Hash digest
SHA256 96925a604778b36784a68aeae4ecbbc04936cf4b7f4a09a26ca6292ab2849929
MD5 d0bc19220422b7f0985415f22b641721
BLAKE2b-256 bad3aa53e6b3447bec5326dfc246b5705eac3d0ada961fc60144f7a482358765

See more details on using hashes here.

Supported by

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