Skip to content

Commit

Permalink
Required: False headers don't give error if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgf committed Sep 11, 2020
1 parent b3f1a71 commit 96bfdb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 3 additions & 2 deletions connexion/decorators/response.py
Expand Up @@ -52,9 +52,10 @@ def validate_response(self, data, status_code, headers, url):

if response_definition and response_definition.get("headers"):
# converting to set is needed to support python 2.7
response_definition_header_keys = set(response_definition.get("headers").keys())
required_header_keys = {k for (k, v) in response_definition.get("headers").items()
if 'required' not in v or v['required']}
header_keys = set(headers.keys())
missing_keys = response_definition_header_keys - header_keys
missing_keys = required_header_keys - header_keys
if missing_keys:
pretty_list = ', '.join(missing_keys)
msg = ("Keys in header don't match response specification. "
Expand Down
2 changes: 0 additions & 2 deletions tests/fixtures/simple/openapi.yaml
Expand Up @@ -1157,8 +1157,6 @@ paths:
type: string
required: False



servers:
- url: http://localhost:{port}/{basePath}
variables:
Expand Down

0 comments on commit 96bfdb1

Please sign in to comment.