Skip to content

Commit

Permalink
Exclude Accept, Content-type and Authorization header from OpenAPI do…
Browse files Browse the repository at this point in the history
…cs (#504)

* Exclude Acccept, Content-type and Authorization header from the list of parameters

Based on the OpenAPI specs, some headers are not supposed to be listed directly as parameters https://swagger.io/docs/specification/describing-parameters/#header-parameters

---------

Co-authored-by: Roberto Prevato <roberto.prevato@gmail.com>
  • Loading branch information
ticapix and RobertoPrevato authored Jan 16, 2025
1 parent 7a0108f commit b212cba
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion blacksheep/server/openapi/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,14 @@ def get_parameter_location_for_binder(
return ParameterLocation.QUERY
if isinstance(binder, CookieBinder):
return ParameterLocation.COOKIE
if isinstance(binder, HeaderBinder):

# exclude those specific header value per documentation
# https://swagger.io/docs/specification/describing-parameters/#header-parameters
if isinstance(binder, HeaderBinder) and binder.parameter_name.lower() not in [
"content-type",
"accept",
"authorization",
]:
return ParameterLocation.HEADER
return None

Expand Down

0 comments on commit b212cba

Please sign in to comment.