[python-fastapi] Ensure path param is ... instead of None (#17532)

Fixes #16029
Code from https://github.com/OpenAPITools/openapi-generator/issues/16029#issuecomment-1776271921
This commit is contained in:
Sander Hoentjen
2024-01-31 04:03:14 +01:00
committed by GitHub
parent af4800132d
commit 7267e809c3
4 changed files with 10 additions and 10 deletions

View File

@@ -63,7 +63,7 @@ async def add_pet(
response_model_by_alias=True,
)
async def delete_pet(
petId: int = Path(None, description="Pet id to delete"),
petId: int = Path(..., description="Pet id to delete"),
api_key: str = Header(None, description=""),
token_petstore_auth: TokenModel = Security(
get_token_petstore_auth, scopes=["write:pets", "read:pets"]
@@ -125,7 +125,7 @@ async def find_pets_by_tags(
response_model_by_alias=True,
)
async def get_pet_by_id(
petId: int = Path(None, description="ID of pet to return"),
petId: int = Path(..., description="ID of pet to return"),
token_api_key: TokenModel = Security(
get_token_api_key
),
@@ -166,7 +166,7 @@ async def update_pet(
response_model_by_alias=True,
)
async def update_pet_with_form(
petId: int = Path(None, description="ID of pet that needs to be updated"),
petId: int = Path(..., description="ID of pet that needs to be updated"),
name: str = Form(None, description="Updated name of the pet"),
status: str = Form(None, description="Updated status of the pet"),
token_petstore_auth: TokenModel = Security(
@@ -187,7 +187,7 @@ async def update_pet_with_form(
response_model_by_alias=True,
)
async def upload_file(
petId: int = Path(None, description="ID of pet to update"),
petId: int = Path(..., description="ID of pet to update"),
additional_metadata: str = Form(None, description="Additional data to pass to server"),
file: str = Form(None, description="file to upload"),
token_petstore_auth: TokenModel = Security(

View File

@@ -43,7 +43,7 @@ for _, name, _ in pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + "."):
response_model_by_alias=True,
)
async def delete_order(
orderId: str = Path(None, description="ID of the order that needs to be deleted"),
orderId: str = Path(..., description="ID of the order that needs to be deleted"),
) -> None:
"""For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors"""
return BaseStoreApi.subclasses[0]().delete_order(orderId)
@@ -79,7 +79,7 @@ async def get_inventory(
response_model_by_alias=True,
)
async def get_order_by_id(
orderId: int = Path(None, description="ID of pet that needs to be fetched", ge=1, le=5),
orderId: int = Path(..., description="ID of pet that needs to be fetched", ge=1, le=5),
) -> Order:
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions"""
return BaseStoreApi.subclasses[0]().get_order_by_id(orderId)

View File

@@ -100,7 +100,7 @@ async def create_users_with_list_input(
response_model_by_alias=True,
)
async def delete_user(
username: str = Path(None, description="The name that needs to be deleted"),
username: str = Path(..., description="The name that needs to be deleted"),
token_api_key: TokenModel = Security(
get_token_api_key
),
@@ -121,7 +121,7 @@ async def delete_user(
response_model_by_alias=True,
)
async def get_user_by_name(
username: str = Path(None, description="The name that needs to be fetched. Use user1 for testing."),
username: str = Path(..., description="The name that needs to be fetched. Use user1 for testing."),
) -> User:
""""""
return BaseUserApi.subclasses[0]().get_user_by_name(username)
@@ -174,7 +174,7 @@ async def logout_user(
response_model_by_alias=True,
)
async def update_user(
username: str = Path(None, description="name that need to be deleted"),
username: str = Path(..., description="name that need to be deleted"),
user: User = Body(None, description="Updated user object"),
token_api_key: TokenModel = Security(
get_token_api_key