Bugfix: #1666: Change requestBody argument name to 'body' (#20207)

Since Connexion defaults to using 'body' as the argument name for the requestBody, the controller's argument name is adjusted accordingly.
This commit is contained in:
jops-wtakase
2024-11-30 11:20:06 +09:00
committed by GitHub
parent 706c0a177e
commit 2aa49227b0
6 changed files with 169 additions and 8 deletions

View File

@@ -8,7 +8,7 @@ from openapi_server.models.pet import Pet # noqa: E501
from openapi_server import util
def add_pet(pet): # noqa: E501
def add_pet(body): # noqa: E501
"""Add a new pet to the store
# noqa: E501
@@ -18,6 +18,7 @@ def add_pet(pet): # noqa: E501
:rtype: Union[Pet, Tuple[Pet, int], Tuple[Pet, int, Dict[str, str]]
"""
pet = body
if connexion.request.is_json:
pet = Pet.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'
@@ -77,7 +78,7 @@ def get_pet_by_id(pet_id): # noqa: E501
return 'do some magic!'
def update_pet(pet): # noqa: E501
def update_pet(body): # noqa: E501
"""Update an existing pet
# noqa: E501
@@ -87,6 +88,7 @@ def update_pet(pet): # noqa: E501
:rtype: Union[Pet, Tuple[Pet, int], Tuple[Pet, int, Dict[str, str]]
"""
pet = body
if connexion.request.is_json:
pet = Pet.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'

View File

@@ -44,7 +44,7 @@ def get_order_by_id(order_id): # noqa: E501
return 'do some magic!'
def place_order(order): # noqa: E501
def place_order(body): # noqa: E501
"""Place an order for a pet
# noqa: E501
@@ -54,6 +54,7 @@ def place_order(order): # noqa: E501
:rtype: Union[Order, Tuple[Order, int], Tuple[Order, int, Dict[str, str]]
"""
order = body
if connexion.request.is_json:
order = Order.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'

View File

@@ -7,7 +7,7 @@ from openapi_server.models.user import User # noqa: E501
from openapi_server import util
def create_user(user): # noqa: E501
def create_user(body): # noqa: E501
"""Create user
This can only be done by the logged in user. # noqa: E501
@@ -17,12 +17,13 @@ def create_user(user): # noqa: E501
:rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]]
"""
user = body
if connexion.request.is_json:
user = User.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'
def create_users_with_array_input(user): # noqa: E501
def create_users_with_array_input(body): # noqa: E501
"""Creates list of users with given input array
# noqa: E501
@@ -32,12 +33,13 @@ def create_users_with_array_input(user): # noqa: E501
:rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]]
"""
user = body
if connexion.request.is_json:
user = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
return 'do some magic!'
def create_users_with_list_input(user): # noqa: E501
def create_users_with_list_input(body): # noqa: E501
"""Creates list of users with given input array
# noqa: E501
@@ -47,6 +49,7 @@ def create_users_with_list_input(user): # noqa: E501
:rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]]
"""
user = body
if connexion.request.is_json:
user = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
return 'do some magic!'
@@ -104,7 +107,7 @@ def logout_user(): # noqa: E501
return 'do some magic!'
def update_user(username, user): # noqa: E501
def update_user(username, body): # noqa: E501
"""Updated user
This can only be done by the logged in user. # noqa: E501
@@ -116,6 +119,7 @@ def update_user(username, user): # noqa: E501
:rtype: Union[None, Tuple[None, int], Tuple[None, int, Dict[str, str]]
"""
user = body
if connexion.request.is_json:
user = User.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'