Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def post_items_all_params_default(
item_id: str,
body_item_a: Item,
body_item_b: Item,
query_a: int,
query_b: int,
coo: str = Cookie(None),
x_head: int = Header(None),
x_under: str = Header(None, convert_underscores=False),
):
return {
"item_id": item_id,
"body_item_a": body_item_a,
"body_item_b": body_item_b,
"query_a": query_a,
"query_b": query_b,
"coo": coo,
"x_head": x_head,
"x_under": x_under,
}
def post_items_all_params_default(
item_id: str,
body_item_a: Item,
body_item_b: Item,
query_a: int,
query_b: int,
coo: str = Cookie(None),
x_head: int = Header(None),
x_under: str = Header(None, convert_underscores=False),
):
return {
"item_id": item_id,
"body_item_a": body_item_a,
"body_item_b": body_item_b,
"query_a": query_a,
"query_b": query_b,
"coo": coo,
"x_head": x_head,
"x_under": x_under,
}
def post_items_all_params(
item_id: str = Path(...),
body: Item = Body(...),
query_a: int = Query(None),
query_b=Query(None),
coo: str = Cookie(None),
x_head: int = Header(None),
x_under: str = Header(None, convert_underscores=False),
):
return {
"item_id": item_id,
"body": body,
"query_a": query_a,
"query_b": query_b,
"coo": coo,
"x_head": x_head,
"x_under": x_under,
}
def _get_authorization_token(authorization: str = Header(...)):
token_prefix, token = authorization.split(" ")
if token_prefix != JWT_TOKEN_PREFIX:
raise HTTPException(
status_code=HTTP_403_FORBIDDEN, detail="Invalid authorization type"
)
return token
async def list_models(user_agent: str = Header(None)):
"""
Lists all available models.
:param user_agent:
:return: APIResponse
"""
return ApiResponse(data={'models': dl_service.list_models()})
def _get_authorization_token_optional(authorization: str = Header(None)):
if authorization:
return _get_authorization_token(authorization)
return ""
async def verify_token(x_token: str = Header(...)):
if x_token != "fake-super-secret-token":
raise HTTPException(status_code=400, detail="X-Token header invalid")
async def get_token_header(x_token: str = Header(...)):
if x_token != "fake-super-secret-token":
raise HTTPException(status_code=400, detail="X-Token header invalid")
async def verify_key(x_key: str = Header(...)):
if x_key != "fake-super-secret-key":
raise HTTPException(status_code=400, detail="X-Key header invalid")
return x_key