Skip to content

Commit e4e63cb

Browse files
committed
cover another error case
1 parent f0f105c commit e4e63cb

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

end_to_end_tests/generator_errors_and_warnings/test_invalid_unions.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,16 @@ def warnings(self):
1212
"""
1313
components:
1414
schemas:
15-
ModelType1:
16-
type: object
17-
properties:
18-
modelType: {"type": "string"}
19-
name: {"type": "string"}
20-
required: ["modelType"]
21-
ModelType2:
22-
type: object
23-
properties:
24-
modelType: {"type": "string"}
25-
name: {"type": "string"}
26-
required: ["modelType"]
2715
UnionWithInvalidReference:
2816
anyOf:
2917
- $ref: "#/components/schemas/DoesntExist"
3018
UnionWithInvalidDefault:
3119
type: ["number", "integer"]
3220
default: aaa
21+
UnionWithMalformedVariant:
22+
anyOf:
23+
- type: string
24+
- type: array # invalid because no items
3325
"""
3426
)
3527

@@ -39,6 +31,9 @@ def test_invalid_reference(self, warnings):
3931
def test_invalid_default(self, warnings):
4032
assert_bad_schema_warning(warnings, "UnionWithInvalidDefault", "Invalid int value: aaa")
4133

34+
def test_invalid_property(self, warnings):
35+
assert_bad_schema_warning(warnings, "UnionWithMalformedVariant", "Invalid property in union")
36+
4237

4338
class TestInvalidDiscriminators:
4439
@pytest.fixture(scope="class")

0 commit comments

Comments
 (0)