Coverage for tests / test_openapi_schema_type.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-21 17:29 +0000

1import pytest 1abcd

2from fastapi.openapi.models import Schema, SchemaType 1abcd

3 

4 

5@pytest.mark.parametrize( 1abcd

6 "type_value", 

7 [ 

8 "array", 

9 ["string", "null"], 

10 None, 

11 ], 

12) 

13def test_allowed_schema_type( 1abcd

14 type_value: SchemaType | list[SchemaType] | None, 

15) -> None: 

16 """Test that Schema accepts SchemaType, List[SchemaType] and None for type field.""" 

17 schema = Schema(type=type_value) 1efg

18 assert schema.type == type_value 1efg

19 

20 

21def test_invalid_type_value() -> None: 1abcd

22 """Test that Schema raises ValueError for invalid type values.""" 

23 with pytest.raises(ValueError, match="2 validation errors for Schema"): 1hij

24 Schema(type=True) # type: ignore[arg-type] 1hij