From 3b1f18cdf250826eb72e3f1ae7ef1328a0968c9a Mon Sep 17 00:00:00 2001 From: Alex Lam Date: Tue, 24 Dec 2024 19:24:07 +0800 Subject: [PATCH] fix: resolve ImportError for 'create_response_field' in fastapi_amis_admin/crud/parser.py (#187) --- fastapi_amis_admin/crud/parser.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fastapi_amis_admin/crud/parser.py b/fastapi_amis_admin/crud/parser.py index a29d641..d97a3ce 100644 --- a/fastapi_amis_admin/crud/parser.py +++ b/fastapi_amis_admin/crud/parser.py @@ -1,10 +1,14 @@ import datetime from functools import lru_cache +from importlib.metadata import version from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Type, TypeVar, Union from uuid import UUID import sqlalchemy -from fastapi.utils import create_cloned_field, create_response_field +if version("fastapi") > "0.112.2": + from fastapi.utils import create_model_field as create_response_field +else: + from fastapi.utils import create_response_field from pydantic import BaseConfig, BaseModel from pydantic.fields import FieldInfo from sqlalchemy import Column, String, Table