Chapter 4: Managing Pydantic Data Models in FastAPI
This chapter will cover in more detail the definition of a data model with Pydantic, the underlying data validation library used by FastAPI. We'll explain how to implement variations of the same model without repeating the same code again and again, thanks to class inheritance. Finally, we'll show how to implement custom data validation logic into Pydantic models.
In this chapter, we're going to cover the following main topics:
- Defining models and their field types with Pydantic
- Creating model variations with class inheritance
- Adding custom data validation with Pydantic
- Working with Pydantic objects