Allow hiding from OpenAPI (and Swagger UI) Query, Cookie, Header, and Path parameters (#3144)

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Mark
2022-01-23 23:54:59 +08:00
committed by GitHub
parent 347e391271
commit ca5d57ea79
9 changed files with 474 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
from typing import Optional
from fastapi import FastAPI, Query
app = FastAPI()
@app.get("/items/")
async def read_items(
hidden_query: Optional[str] = Query(None, include_in_schema=False)
):
if hidden_query:
return {"hidden_query": hidden_query}
else:
return {"hidden_query": "Not found"}