Skip to content

Commit 4f94f67

Browse files
committed
epoch - use pydantic-extra-types
1 parent 114b0b4 commit 4f94f67

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

aiopenapi3/model.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,16 @@ def generate_type_format_to_class():
5858

5959
type_format_to_class["string"]["byte"] = Base64Str
6060

61-
from aiopenapi3.models import epoch
61+
type_format_to_class["integer"][None] = int
6262

63-
type_format_to_class["number"]["date-time"] = epoch.Number
63+
try:
64+
from pydantic_extra_types import epoch
6465

65-
if "integer" not in type_format_to_class:
66-
type_format_to_class["integer"][None] = int
67-
type_format_to_class["integer"]["date-time"] = epoch.Integer
66+
type_format_to_class["number"]["date-time"] = epoch.Number
67+
type_format_to_class["integer"]["date-time"] = epoch.Integer
68+
69+
except ImportError:
70+
pass
6871

6972

7073
def class_from_schema(s, _type):

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ auth = [
5454
socks = [
5555
"httpx-socks",
5656
]
57-
57+
types =[
58+
"pydantic-extra-types @ git+https://github.com/pydantic/pydantic-extra-types.git@3668b3af8ab378c56342c613672aa9415dab865b",
59+
]
5860
[project.scripts]
5961
aiopenapi3 = "aiopenapi3.cli:main"
6062

@@ -118,6 +120,7 @@ tests = [
118120
"bootstrap-flask",
119121
"ijson",
120122
"python-multipart>=0.0.6",
123+
"pydantic-extra-types @ git+https://github.com/pydantic/pydantic-extra-types.git@3668b3af8ab378c56342c613672aa9415dab865b"
121124
]
122125

123126
[tool.pdm]

0 commit comments

Comments
 (0)