Coverage for /usr/local/lib/python3.12/site-packages/prefect/types/_schema.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 10:48 +0000

1"""Types for OpenAPI schemas.""" 

2 

3from typing import Annotated, Any 1a

4 

5from pydantic import BeforeValidator 1a

6 

7 

8def _normalize_parameter_schema(value: Any) -> dict[str, Any]: 1a

9 """ 

10 Normalize empty or None parameter schemas to valid OpenAPI format. 

11 

12 Ensures parameter_openapi_schema is always a valid OpenAPI object schema, 

13 converting None or {} to {"type": "object", "properties": {}}. 

14 """ 

15 if value is None or value == {}: 1bcd

16 return {"type": "object", "properties": {}} 1bcd

17 return value 1bcd

18 

19 

20ParameterSchema = Annotated[ 1a

21 dict[str, Any], 

22 BeforeValidator(_normalize_parameter_schema), 

23]