diff --git a/aiohttp_apischema/generator.py b/aiohttp_apischema/generator.py index effa2cb..91eae5b 100644 --- a/aiohttp_apischema/generator.py +++ b/aiohttp_apischema/generator.py @@ -1,10 +1,11 @@ import functools import inspect +import sys from collections.abc import Awaitable, Callable, Mapping from http import HTTPStatus from pathlib import Path from types import UnionType -from typing import Any, Literal, Required, TypedDict, TypeGuard, TypeVar, cast, get_args, get_origin +from typing import Any, Literal, TypedDict, TypeGuard, TypeVar, cast, get_args, get_origin from aiohttp import web from aiohttp.hdrs import METH_ALL @@ -13,6 +14,11 @@ from aiohttp_apischema.response import APIResponse +if sys.version_info >= (3, 11): + from typing import Required +else: + from typing_extensions import Required + OPENAPI_METHODS = frozenset({"get", "put", "post", "delete", "options", "head", "patch", "trace"}) _T = TypeVar("_T")