fastapi-camelcase

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


Keywords
fastapi, fastapi-camelcase, python, python3, python36, rest-api
License
MIT
Install
pip install fastapi-camelcase==2.0.0

Documentation

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)