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

Only warn about the schema's x-body-name being deprecated if it's used. #1554

Merged
merged 1 commit into from
Jun 14, 2022
Merged
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
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