Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce header param type conversion #1931

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions connexion/validators/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from starlette.requests import Request

from connexion.exceptions import BadRequestProblem, ExtraParameterProblem
from connexion.utils import boolean, is_null, is_nullable
from connexion.utils import boolean, is_null, is_nullable, coerce_type, TypeValidationError

logger = logging.getLogger("connexion.validators.parameter")

Expand Down Expand Up @@ -97,7 +97,12 @@ def validate_path_parameter(self, param, request):

def validate_header_parameter(self, param, request):
val = request.headers.get(param["name"])
return self.validate_parameter("header", val, param)
parameter_type = "header"
try:
converted_value = coerce_type(param, val, parameter_type)
except TypeValidationError as e:
return str(e)
return self.validate_parameter(parameter_type, converted_value, param)

def validate_cookie_parameter(self, param, request):
val = request.cookies.get(param["name"])
Expand Down