Skip to content

Commit

Permalink
Remove support for deprecated x-body-name position (#1600)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbeSneyders authored Oct 4, 2022
1 parent 1ab5400 commit 59f619c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 33 deletions.
17 changes: 1 addition & 16 deletions connexion/operations/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import logging
import warnings
from copy import copy, deepcopy

from connexion.operations.abstract import AbstractOperation
Expand Down Expand Up @@ -282,21 +281,7 @@ def _get_body_argument(self, body, arguments, has_kwargs, sanitize):
if len(arguments) <= 0 and not has_kwargs:
return {}

# get the deprecated name from the body-schema for legacy connexion compat
x_body_name = sanitize(self.body_schema.get("x-body-name"))

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")
)
x_body_name = sanitize(self.request_body.get("x-body-name", "body"))

if self.consumes[0] in FORM_CONTENT_TYPES:
result = self._get_body_argument_form(body)
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/different_schemas/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ paths:
schema:
$ref: '#/components/schemas/new_stack'
requestBody:
x-body-name: new_stack
content:
application/json:
schema:
x-body-name: new_stack
$ref: '#/components/schemas/new_stack'
required: true
'/test_schema/response/object/{valid}':
Expand Down Expand Up @@ -242,10 +242,10 @@ paths:
'200':
description: OK
requestBody:
x-body-name: test_int
content:
application/json:
schema:
x-body-name: test_int
type: integer
required: true
/schema_array:
Expand Down Expand Up @@ -276,10 +276,10 @@ components:
type: string
requestBodies:
fakeapi.hello.schema_listNewStack:
x-body-name: test_array
content:
application/json:
schema:
x-body-name: test_array
type: array
items:
type: string
Expand Down
18 changes: 8 additions & 10 deletions tests/fixtures/simple/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ paths:
content:
application/json:
schema:
# should be ignored because the preferred location is at the requestBody level above
x-body-name: this_should_be_ignored
$ref: '#/components/schemas/new_stack'
default:
image_version: default_image
Expand Down Expand Up @@ -306,10 +304,10 @@ paths:
'200':
description: OK
requestBody:
x-body-name: stack_version
content:
application/json:
schema:
x-body-name: stack_version
type: integer
format: int32
example: 1
Expand All @@ -322,10 +320,10 @@ paths:
'200':
description: OK
requestBody:
x-body-name: stack
content:
application/json:
schema:
x-body-name: stack
type: object
/resolver-test/method:
get:
Expand Down Expand Up @@ -391,13 +389,13 @@ paths:
post:
operationId: fakeapi.hello.test_array_csv_form_param3
requestBody:
x-body-name: items
content:
application/x-www-form-urlencoded:
schema:
type: object
default:
items: ["squash", "banana"]
x-body-name: items
properties:
items:
type: array
Expand All @@ -415,11 +413,11 @@ paths:
post:
operationId: fakeapi.hello.test_array_pipes_form_param3
requestBody:
x-body-name: items
content:
application/x-www-form-urlencoded:
schema:
type: object
x-body-name: items
properties:
items:
type: array
Expand Down Expand Up @@ -596,10 +594,10 @@ paths:
'200':
description: OK
requestBody:
x-body-name: formData
content:
multipart/form-data:
schema:
x-body-name: formData
type: object
properties:
formData:
Expand Down Expand Up @@ -835,11 +833,11 @@ paths:
'200':
description: OK
requestBody:
x-body-name: contents
content:
application/json:
schema:
nullable: true
x-body-name: contents
type: object
properties:
name:
Expand Down Expand Up @@ -867,11 +865,11 @@ paths:
'200':
description: OK
requestBody:
x-body-name: contents
content:
application/json:
schema:
nullable: true
x-body-name: contents
type: object
properties:
name:
Expand Down Expand Up @@ -955,10 +953,10 @@ paths:
'200':
description: OK
requestBody:
x-body-name: post_param
content:
text/plain:
schema:
x-body-name: post_param
type: string
description: Just a testing parameter.
required: true
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/snake_case/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ paths:
schema:
type: integer
requestBody:
x-body-name: some_other_id
content:
application/json:
schema:
x-body-name: some_other_id
type: object
description: SomeOtherId parameter
required: true
Expand All @@ -147,10 +147,10 @@ paths:
schema:
type: integer
requestBody:
x-body-name: round_
content:
application/json:
schema:
x-body-name: round_
type: object
description: round parameter
required: true
Expand All @@ -174,10 +174,10 @@ paths:
schema:
type: integer
requestBody:
x-body-name: some_other_id
content:
application/json:
schema:
x-body-name: some_other_id
type: object
description: someOtherId parameter
required: true
Expand Down Expand Up @@ -207,10 +207,10 @@ paths:
schema:
type: string
requestBody:
x-body-name: next_
content:
application/json:
schema:
x-body-name: next_
type: object
description: next parameter
required: true
Expand Down

0 comments on commit 59f619c

Please sign in to comment.