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

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

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#isPathParam}}{{baseName}}{{/isPathParam}}{{^isPathParam}}{{paramName}}{{/isPathParam}}: {{>param_type}} = {{#isPathParam}}Path{{/isPathParam}}{{#isHeaderParam}}Header{{/isHeaderParam}}{{#isFormParam}}Form{{/isFormParam}}{{#isQueryParam}}Query{{/isQueryParam}}{{#isCookieParam}}Cookie{{/isCookieParam}}{{#isBodyParam}}Body{{/isBodyParam}}({{&defaultValue}}{{^defaultValue}}None{{/defaultValue}}, description="{{description}}"{{#isQueryParam}}, alias="{{baseName}}"{{/isQueryParam}}{{#isLong}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isLong}}{{#isInteger}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isInteger}}{{#pattern}}, regex=r"{{.}}"{{/pattern}}{{#minLength}}, min_length={{.}}{{/minLength}}{{#maxLength}}, max_length={{.}}{{/maxLength}})
{{#isPathParam}}{{baseName}}{{/isPathParam}}{{^isPathParam}}{{paramName}}{{/isPathParam}}: {{>param_type}} = {{#isPathParam}}Path{{/isPathParam}}{{#isHeaderParam}}Header{{/isHeaderParam}}{{#isFormParam}}Form{{/isFormParam}}{{#isQueryParam}}Query{{/isQueryParam}}{{#isCookieParam}}Cookie{{/isCookieParam}}{{#isBodyParam}}Body{{/isBodyParam}}({{&defaultValue}}{{^defaultValue}}{{#isPathParam}}...{{/isPathParam}}{{^isPathParam}}None{{/isPathParam}}{{/defaultValue}}, description="{{description}}"{{#isQueryParam}}, alias="{{baseName}}"{{/isQueryParam}}{{#isLong}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isLong}}{{#isInteger}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isInteger}}{{#pattern}}, regex=r"{{.}}"{{/pattern}}{{#minLength}}, min_length={{.}}{{/minLength}}{{#maxLength}}, max_length={{.}}{{/maxLength}})
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading