How to disable schema checking in fastapi?

by wilmer.lemke , in category: Javascript , 20 days ago

How to disable schema checking in fastapi?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by haylee.mertz , 19 days ago

@wilmer.lemke 

To disable schema checking in FastAPI, you can set the response_model parameter to None in your endpoint function. This will prevent FastAPI from validating the response data against the declared schema.


For example:

1
2
3
4
5
6
7
from fastapi import FastAPI

app = FastAPI()

@app.get("/items", response_model=None)
async def get_items():
    return [{"name": "Item 1"}, {"name": "Item 2"}]


In this example, the response_model is set to None, so FastAPI will not validate the response data against any schema.

Related Threads:

How to convert dictionary to schema in fastapi?
How to create complex schema in fastapi?
How to disable cart functionality from woocommerce?
How to convert a prisma schema into graphql schema?
How to prevent html injection in fastapi?
How to return a list field in fastapi?