Fix bug query string appear as required in generated Open API specification.

This commit is contained in:
Vincent Maillol
2020-11-15 19:54:53 +01:00
parent 0d3a33c964
commit 462d8d8b98
8 changed files with 324 additions and 33 deletions

View File

@@ -13,7 +13,7 @@ Example:
from functools import lru_cache
from types import new_class
from typing import Protocol, TypeVar
from typing import Protocol, TypeVar, Optional, Type
RespContents = TypeVar("RespContents", covariant=True)
@@ -24,9 +24,10 @@ _status_code = frozenset(f"r{code}" for code in range(100, 600))
def _make_status_code_type(status_code):
if status_code in _status_code:
return new_class(status_code, (Protocol[RespContents],))
return None
def is_status_code_type(obj):
def is_status_code_type(obj) -> bool:
"""
Return True if obj is a status code type such as _200 or _404.
"""