* feat(relationship): support legacy-compatible response format * feat(score): add support for legacy score response format in API * fix(score): avoid missing greenlet * fix(score): fix missing field for model validation * feat(user): apply legacy score format for user * feat(api): use `int` to hint `APIVersion`
17 lines
352 B
Python
17 lines
352 B
Python
from __future__ import annotations
|
|
|
|
from typing import Annotated
|
|
|
|
from fastapi import Depends, Header
|
|
|
|
|
|
def get_api_version(version: int | None = Header(None, alias="x-api-version")) -> int:
|
|
if version is None:
|
|
return 0
|
|
if version < 1:
|
|
raise ValueError
|
|
return version
|
|
|
|
|
|
APIVersion = Annotated[int, Depends(get_api_version)]
|