Skip to content

Commit

Permalink
Only warn about the schema's x-body-name being deprecated if it's use…
Browse files Browse the repository at this point in the history
…d. (#1554)

Co-authored-by: Motti Lanzkron <motti@microfocus.com>
  • Loading branch information
lanzkron and mottil authored Jun 14, 2022
1 parent 4dee786 commit 1ce3e2e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions connexion/operations/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,16 @@ def _get_body_argument(self, body, arguments, has_kwargs, sanitize):
if len(arguments) <= 0 and not has_kwargs:
return {}

# prefer the x-body-name as an extension of requestBody
x_body_name = sanitize(self.request_body.get('x-body-name', None))
# get the deprecated name from the body-schema for legacy connexion compat
x_body_name = sanitize(self.body_schema.get('x-body-name'))

if not x_body_name:
# x-body-name also accepted in the schema field for legacy connexion compat
x_body_name = sanitize(self.body_schema.get('x-body-name', 'body'))
if x_body_name:
warnings.warn('x-body-name within the requestBody schema will be deprecated in the '
'next major version. It should be provided directly under '
'the requestBody instead.', DeprecationWarning)

if x_body_name:
warnings.warn('x-body-name within the requestBody schema will be deprecated in the '
'next major version. It should be provided directly under '
'the requestBody instead.', DeprecationWarning)
# prefer the x-body-name as an extension of requestBody, fallback to deprecated schema name, default 'body'
x_body_name = sanitize(self.request_body.get('x-body-name', x_body_name or 'body'))

if self.consumes[0] in FORM_CONTENT_TYPES:
result = self._get_body_argument_form(body)
Expand Down

0 comments on commit 1ce3e2e

Please sign in to comment.