change check for pydantic list in outer type
This commit is contained in:
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
github: collerek
|
||||||
@ -11,6 +11,7 @@ except ImportError: # pragma: no cover
|
|||||||
import json # type: ignore
|
import json # type: ignore
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
|
from pydantic.fields import SHAPE_LIST
|
||||||
from pydantic.main import SchemaExtraCallable
|
from pydantic.main import SchemaExtraCallable
|
||||||
|
|
||||||
import ormar # noqa: I100, I202
|
import ormar # noqa: I100, I202
|
||||||
@ -184,11 +185,11 @@ def generate_pydantic_example(
|
|||||||
"""
|
"""
|
||||||
example: Dict[str, Any] = dict()
|
example: Dict[str, Any] = dict()
|
||||||
exclude = exclude or set()
|
exclude = exclude or set()
|
||||||
for name in pydantic_model.__fields__:
|
name_to_check = [name for name in pydantic_model.__fields__ if name not in exclude]
|
||||||
if name not in exclude:
|
for name in name_to_check:
|
||||||
field = pydantic_model.__fields__[name]
|
field = pydantic_model.__fields__[name]
|
||||||
type_ = field.type_
|
type_ = field.type_
|
||||||
if getattr(field.outer_type_, "_name", None) == "List":
|
if field.shape == SHAPE_LIST:
|
||||||
example[name] = [get_pydantic_example_repr(type_)]
|
example[name] = [get_pydantic_example_repr(type_)]
|
||||||
else:
|
else:
|
||||||
example[name] = get_pydantic_example_repr(type_)
|
example[name] = get_pydantic_example_repr(type_)
|
||||||
|
|||||||
Reference in New Issue
Block a user