Skip to content

Commit 381e9ea

Browse files
committed
add pydantic computed field to tests #1354
1 parent 9bf8e92 commit 381e9ea

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

tests/contrib/test_pydantic.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from tests import assert_schema, generate_schema
1010

1111
try:
12-
from pydantic import BaseModel
12+
from pydantic import BaseModel, computed_field
1313
from pydantic.dataclasses import dataclass
1414
except ImportError:
1515
class BaseModel: # type: ignore
@@ -18,6 +18,9 @@ class BaseModel: # type: ignore
1818
def dataclass(f):
1919
return f
2020

21+
def computed_field(f):
22+
return f
23+
2124

2225
@dataclass
2326
class C:
@@ -34,6 +37,11 @@ class A(BaseModel):
3437
b: B
3538
d: Decimal
3639

40+
@computed_field
41+
@property
42+
def x(self) -> int:
43+
return 42
44+
3745

3846
@pytest.mark.contrib('pydantic')
3947
@pytest.mark.skipif(sys.version_info < (3, 7), reason='python 3.7+ is required by package')

tests/contrib/test_pydantic.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ components:
4343
d:
4444
title: D
4545
type: string
46+
x:
47+
readOnly: true
48+
title: X
49+
type: integer
4650
required:
4751
- id
4852
- b
4953
- d
54+
- x
5055
title: A
5156
type: object
5257
B:

0 commit comments

Comments
 (0)