chore(types): give the variations OpenAPI fixtures explicit types

dict[str, object] on the documented request body and the openapi_extra
mapping keeps FastAPI's decorator overloads resolving, and the
ORJSONResponse deprecation on the azure-compat path is suppressed with
its reason - both to hold the basedpyright delta ceilings.
This commit is contained in:
OrangerXu 2026-10-14 13:59:50 +08:00
parent 2201c32a0d
commit f328d32870

View file

@ -53,7 +53,7 @@ IMAGE_VARIATION_OPTIONAL_FIELD_DEFAULTS: Final = MappingProxyType({"image": None
# ImageVariationRequestParams carries FileTypes (typing.IO[bytes]) which
# pydantic cannot turn into a JSON schema, so the documented JSON body
# schema is spelled out for the shape the multipart form accepts.
_IMAGE_VARIATION_REQUEST_BODY: Final = {
_IMAGE_VARIATION_REQUEST_BODY: Final[dict[str, object]] = {
"required": True,
"content": {
"application/json": {
@ -71,7 +71,7 @@ _IMAGE_VARIATION_REQUEST_BODY: Final = {
}
},
}
_IMAGE_VARIATION_OPENAPI_EXTRA: Final = MappingProxyType({"requestBody": _IMAGE_VARIATION_REQUEST_BODY})
_IMAGE_VARIATION_OPENAPI_EXTRA: Final[dict[str, object]] = {"requestBody": _IMAGE_VARIATION_REQUEST_BODY}
IMAGE_ARRAY_FIELD: Final = "image[]"
MASK_ARRAY_FIELD: Final = "mask[]"
@ -390,21 +390,21 @@ async def image_edit_api(
"/v1/images/variations",
dependencies=[Depends(user_api_key_auth)],
responses={200: {"model": ImageResponse}},
openapi_extra=dict(_IMAGE_VARIATION_OPENAPI_EXTRA),
openapi_extra=dict[str, object](_IMAGE_VARIATION_OPENAPI_EXTRA),
tags=["images"],
)
@router.post(
"/images/variations",
dependencies=[Depends(user_api_key_auth)],
responses={200: {"model": ImageResponse}},
openapi_extra=dict(_IMAGE_VARIATION_OPENAPI_EXTRA),
openapi_extra=dict[str, object](_IMAGE_VARIATION_OPENAPI_EXTRA),
tags=["images"],
)
@router.post(
"/openai/deployments/{model:path}/images/variations",
dependencies=[Depends(user_api_key_auth)],
responses={200: {"model": ImageResponse}},
openapi_extra=dict(_IMAGE_VARIATION_OPENAPI_EXTRA),
openapi_extra=dict[str, object](_IMAGE_VARIATION_OPENAPI_EXTRA),
response_class=ORJSONResponse,
) # azure compatible endpoint
async def image_variation_api(