sam-mosleh
4 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
9 additions and
2 deletions
-
fastapi/openapi/models.py
|
|
@ -1,3 +1,4 @@ |
|
|
|
import os |
|
|
|
from enum import Enum |
|
|
|
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union |
|
|
|
|
|
|
@ -55,9 +56,12 @@ except ImportError: # pragma: no cover |
|
|
|
return with_info_plain_validator_function(cls._validate) |
|
|
|
|
|
|
|
|
|
|
|
_FASTAPI_OPENAPI_DEFER_BUILD = "FASTAPI_OPENAPI_DEFER_BUILD" in os.environ |
|
|
|
|
|
|
|
|
|
|
|
class BaseModelWithConfig(BaseModel): |
|
|
|
if PYDANTIC_V2: |
|
|
|
model_config = {"extra": "allow"} |
|
|
|
model_config = {"extra": "allow", "defer_build": _FASTAPI_OPENAPI_DEFER_BUILD} |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
@ -220,7 +224,10 @@ class Example(TypedDict, total=False): |
|
|
|
externalValue: Optional[AnyUrl] |
|
|
|
|
|
|
|
if PYDANTIC_V2: # type: ignore [misc] |
|
|
|
__pydantic_config__ = {"extra": "allow"} |
|
|
|
__pydantic_config__ = { |
|
|
|
"extra": "allow", |
|
|
|
"defer_build": _FASTAPI_OPENAPI_DEFER_BUILD, |
|
|
|
} |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|