Fake Store API
- Refer Here for api docs
Pydantic
- This helps is dealing with request and response body
- Pydantic also helps in validation
To create a message structure in pydantic
- Create a class, derive from BaseModel and define type hints
from pydantic import BaseModel
class Product(BaseModel):
id: int
name: str
description: str
price: float
-
When the user passes the request the message body

-
If the message doesnot match the types pydantic will throw validation errors
-
Prompt
Using pydantic, help me validate, Give code snippets suitable for fastapi
* Emails
* urls
* Range of values
* boundaries for numbers
any other interesting stuff
ensure its pydantic latest version
- Refer Here for changes done
