Skip to content

Commit 530be1f

Browse files
committed
fix: Cleanup imports. Fix typing.
1 parent 1d1a0b7 commit 530be1f

File tree

5 files changed

+50
-11
lines changed

5 files changed

+50
-11
lines changed

openapi_pydantic/v3/v3_0_3/oauth_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, Optional, Union
1+
from typing import Dict, Optional
22

33
from pydantic import BaseModel, Extra
44

openapi_pydantic/v3/v3_0_3/security_scheme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Union
1+
from typing import Optional
22

33
from pydantic import BaseModel, Extra, Field
44

openapi_pydantic/v3/v3_1_0/oauth_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Dict, Optional, Union
1+
from typing import Dict, Optional
22

33
from pydantic import BaseModel, Extra
44

openapi_pydantic/v3/v3_1_0/security_scheme.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Union
1+
from typing import Optional
22

33
from pydantic import BaseModel, Extra, Field
44

tests/test_openapi.py

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,50 @@ def test_parse_with_callback(version: str) -> None:
2727
}
2828

2929
if version == "3.0.3":
30-
module = v3_0_3
30+
assert v3_0_3.OpenAPI.parse_obj(data) == v3_0_3.OpenAPI(
31+
info=v3_0_3.Info(title="API with Callback", version=""),
32+
paths={
33+
"/create": v3_0_3.PathItem(
34+
post=v3_0_3.Operation(
35+
responses={"200": v3_0_3.Response(description="Success")},
36+
callbacks={
37+
"event": {
38+
"callback": v3_0_3.PathItem(
39+
post=v3_0_3.Operation(
40+
responses={
41+
"200": v3_0_3.Response(
42+
description="Success"
43+
)
44+
}
45+
)
46+
)
47+
}
48+
},
49+
)
50+
)
51+
},
52+
)
3153
else:
32-
module = v3_1_0
33-
34-
open_api = module.OpenAPI.parse_obj(data)
35-
create_endpoint = open_api.paths["/create"]
36-
assert "200" in create_endpoint.post.responses
37-
assert "200" in create_endpoint.post.callbacks["event"]["callback"].post.responses
54+
assert v3_1_0.OpenAPI.parse_obj(data) == v3_1_0.OpenAPI(
55+
info=v3_1_0.Info(title="API with Callback", version=""),
56+
paths={
57+
"/create": v3_1_0.PathItem(
58+
post=v3_1_0.Operation(
59+
responses={"200": v3_1_0.Response(description="Success")},
60+
callbacks={
61+
"event": {
62+
"callback": v3_1_0.PathItem(
63+
post=v3_1_0.Operation(
64+
responses={
65+
"200": v3_1_0.Response(
66+
description="Success"
67+
)
68+
}
69+
)
70+
)
71+
}
72+
},
73+
)
74+
)
75+
},
76+
)

0 commit comments

Comments
 (0)