Skip to content

Commit 43861b4

Browse files
committed
json_schema_of
1 parent 5387bce commit 43861b4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/models-library/tests/test__pydantic_models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
from typing import Any, Union, get_args, get_origin
1010

1111
import pytest
12+
from common_library.json_serialization import json_dumps
1213
from models_library.projects_nodes import InputTypes, OutputTypes
1314
from models_library.projects_nodes_io import SimCoreFileLink
14-
from pydantic import BaseModel, Field, ValidationError, schema_json_of
15+
from pydantic import BaseModel, Field, TypeAdapter, ValidationError
1516
from pydantic.types import Json
1617
from pydantic.version import version_short
1718

@@ -37,7 +38,9 @@ class ArgumentAnnotation(BaseModel):
3738
data_schema: Json
3839

3940
# notice that this is a raw string!
40-
jsonschema_of_x = schema_json_of(list[int], title="schema[x]")
41+
jsonschema_of_x = json_dumps(
42+
{**TypeAdapter(list[int]).json_schema(), "title": "schema[x]"}
43+
)
4144
assert isinstance(jsonschema_of_x, str)
4245

4346
x_annotation = ArgumentAnnotation(name="x", data_schema=jsonschema_of_x)

0 commit comments

Comments
 (0)