mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-04 12:10:48 -05:00
* Make compatible with pydantic v1 * Remove unused import * Remove unused ignores * Update pydantic version * Fix minor formatting issue * ⏪ Revert removing iterate_in_threadpool * ✨ Add backwards compatibility with Pydantic 0.32.2 with deprecation warnings * ✅ Update tests to not break when using Pydantic < 1.0.0 * 📝 Update docs for Pydantic version 1.0.0 * 📌 Update Pydantic range version to support from 0.32.2 * 🎨 Format test imports * ✨ Add support for Pydantic < 1.2 for populate_validators * ✨ Add backwards compatibility for Pydantic < 1.2.0 with required fields * 📌 Relax requirement for Pydantic to < 2.0.0 🎉 🚀 * 💚 Update pragma coverage for older Pydantic versions
23 lines
389 B
Python
23 lines
389 B
Python
from fastapi import FastAPI
|
|
from pydantic import BaseModel, EmailStr
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class UserIn(BaseModel):
|
|
username: str
|
|
password: str
|
|
email: EmailStr
|
|
full_name: str = None
|
|
|
|
|
|
class UserOut(BaseModel):
|
|
username: str
|
|
email: EmailStr
|
|
full_name: str = None
|
|
|
|
|
|
@app.post("/user/", response_model=UserOut)
|
|
async def create_user(*, user: UserIn):
|
|
return user
|