Fast API's Response model and Dependencies are cover in this articles and other related stuff .
Response Model
Fastapi's response model is a powerful feature that helps you define the structure and format of data that API will return in response.
They act like a contract between your API and it's clients , specifying the expected data format in response.
Define using python type hints, typically pydantic models.
Benefits:
Automatically documentation: fastapi generate openai doc that reflect the defined response model.
Data Validation: Fastapi validate the response adata against the model,ensuring data integrity.
@app.get('/student/{id}',response_model=StudentResponse)
async def student(id):
pass
Dependencies
Dependencies injection refers to the mechanism where an object receive other objects that it depends on. The other object are called dependencies.