Merge 4ba2b8026193d3ddb2b3c150a788903b8a8b2a4c into 2fb26c362ea6557c90353606ccdc3c446d6a8f35

This commit is contained in:
L.M. de Vries 2025-05-12 10:35:08 +09:00 committed by GitHub
commit ddfbd9d5e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 45 additions and 37 deletions

View File

@ -68,7 +68,7 @@ async def {{operationId}}(
{{#notes}}"""{{.}}""" {{#notes}}"""{{.}}"""
{{/notes}}if not Base{{classname}}.subclasses: {{/notes}}if not Base{{classname}}.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await Base{{classname}}.subclasses[0]().{{operationId}}({{#allParams}}{{>impl_argument}}{{^-last}}, {{/-last}}{{/allParams}}) return await Base{{classname}}.subclasses[0]().{{operationId}}({{#allParams}}{{>impl_argument}}{{^-last}}, {{/-last}}{{/allParams}}{{#authMethods}}{{#hasParams}}, {{/hasParams}}{{#authMethods}}token_{{name}}=token_{{name}}{{^-last}}, {{/-last}}{{/authMethods}}{{/authMethods}})
{{^-last}} {{^-last}}

View File

@ -18,14 +18,13 @@ class Base{{classname}}:
async def {{operationId}}( async def {{operationId}}(
self, self,
{{#allParams}} {{#allParams}}
{{>impl_argument_definition}}, {{>impl_argument_definition}}{{^-last}},{{/-last}}{{/allParams}}{{#authMethods}}{{#hasParams}},{{/hasParams}}{{#authMethods}}
{{/allParams}} token_{{name}}: str{{^-last}},{{/-last}}{{/authMethods}}{{/authMethods}}
) -> {{returnType}}{{^returnType}}None{{/returnType}}: ) -> {{returnType}}{{^returnType}}None{{/returnType}}:
{{#notes}}"""{{.}}""" {{#notes}}"""{{.}}"""
...{{/notes}}{{^notes}}...{{/notes}} ...{{/notes}}{{^notes}}...{{/notes}}
{{^-last}} {{^-last}}
{{/-last}} {{/-last}}
{{/operation}} {{/operation}}
{{/operations}} {{/operations}}

View File

@ -15,8 +15,7 @@ class BaseFakeApi:
BaseFakeApi.subclasses = BaseFakeApi.subclasses + (cls,) BaseFakeApi.subclasses = BaseFakeApi.subclasses + (cls,)
async def fake_query_param_default( async def fake_query_param_default(
self, self,
has_default: Annotated[Optional[StrictStr], Field(description="has default value")], has_default: Annotated[Optional[StrictStr], Field(description="has default value")], no_default: Annotated[Optional[StrictStr], Field(description="no default value")]
no_default: Annotated[Optional[StrictStr], Field(description="no default value")],
) -> None: ) -> None:
"""""" """"""
... ...

View File

@ -56,7 +56,7 @@ async def add_pet(
"""""" """"""
if not BasePetApi.subclasses: if not BasePetApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BasePetApi.subclasses[0]().add_pet(pet) return await BasePetApi.subclasses[0]().add_pet(pet, token_petstore_auth=token_petstore_auth)
@router.delete( @router.delete(
@ -78,7 +78,7 @@ async def delete_pet(
"""""" """"""
if not BasePetApi.subclasses: if not BasePetApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BasePetApi.subclasses[0]().delete_pet(petId, api_key) return await BasePetApi.subclasses[0]().delete_pet(petId, api_key, token_petstore_auth=token_petstore_auth)
@router.get( @router.get(
@ -100,7 +100,7 @@ async def find_pets_by_status(
"""Multiple status values can be provided with comma separated strings""" """Multiple status values can be provided with comma separated strings"""
if not BasePetApi.subclasses: if not BasePetApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BasePetApi.subclasses[0]().find_pets_by_status(status) return await BasePetApi.subclasses[0]().find_pets_by_status(status, token_petstore_auth=token_petstore_auth)
@router.get( @router.get(
@ -122,7 +122,7 @@ async def find_pets_by_tags(
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""" """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
if not BasePetApi.subclasses: if not BasePetApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BasePetApi.subclasses[0]().find_pets_by_tags(tags) return await BasePetApi.subclasses[0]().find_pets_by_tags(tags, token_petstore_auth=token_petstore_auth)
@router.get( @router.get(
@ -145,7 +145,7 @@ async def get_pet_by_id(
"""Returns a single pet""" """Returns a single pet"""
if not BasePetApi.subclasses: if not BasePetApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BasePetApi.subclasses[0]().get_pet_by_id(petId) return await BasePetApi.subclasses[0]().get_pet_by_id(petId, token_api_key=token_api_key)
@router.put( @router.put(
@ -169,7 +169,7 @@ async def update_pet(
"""""" """"""
if not BasePetApi.subclasses: if not BasePetApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BasePetApi.subclasses[0]().update_pet(pet) return await BasePetApi.subclasses[0]().update_pet(pet, token_petstore_auth=token_petstore_auth)
@router.post( @router.post(
@ -192,7 +192,7 @@ async def update_pet_with_form(
"""""" """"""
if not BasePetApi.subclasses: if not BasePetApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BasePetApi.subclasses[0]().update_pet_with_form(petId, name, status) return await BasePetApi.subclasses[0]().update_pet_with_form(petId, name, status, token_petstore_auth=token_petstore_auth)
@router.post( @router.post(
@ -215,4 +215,4 @@ async def upload_file(
"""""" """"""
if not BasePetApi.subclasses: if not BasePetApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BasePetApi.subclasses[0]().upload_file(petId, additional_metadata, file) return await BasePetApi.subclasses[0]().upload_file(petId, additional_metadata, file, token_petstore_auth=token_petstore_auth)

View File

@ -18,6 +18,7 @@ class BasePetApi:
async def add_pet( async def add_pet(
self, self,
pet: Annotated[Pet, Field(description="Pet object that needs to be added to the store")], pet: Annotated[Pet, Field(description="Pet object that needs to be added to the store")],
token_petstore_auth: str
) -> Pet: ) -> Pet:
"""""" """"""
... ...
@ -25,8 +26,8 @@ class BasePetApi:
async def delete_pet( async def delete_pet(
self, self,
petId: Annotated[StrictInt, Field(description="Pet id to delete")], petId: Annotated[StrictInt, Field(description="Pet id to delete")], api_key: Optional[StrictStr],
api_key: Optional[StrictStr], token_petstore_auth: str
) -> None: ) -> None:
"""""" """"""
... ...
@ -35,6 +36,7 @@ class BasePetApi:
async def find_pets_by_status( async def find_pets_by_status(
self, self,
status: Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")], status: Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")],
token_petstore_auth: str
) -> List[Pet]: ) -> List[Pet]:
"""Multiple status values can be provided with comma separated strings""" """Multiple status values can be provided with comma separated strings"""
... ...
@ -43,6 +45,7 @@ class BasePetApi:
async def find_pets_by_tags( async def find_pets_by_tags(
self, self,
tags: Annotated[List[StrictStr], Field(description="Tags to filter by")], tags: Annotated[List[StrictStr], Field(description="Tags to filter by")],
token_petstore_auth: str
) -> List[Pet]: ) -> List[Pet]:
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.""" """Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
... ...
@ -51,6 +54,7 @@ class BasePetApi:
async def get_pet_by_id( async def get_pet_by_id(
self, self,
petId: Annotated[StrictInt, Field(description="ID of pet to return")], petId: Annotated[StrictInt, Field(description="ID of pet to return")],
token_api_key: str
) -> Pet: ) -> Pet:
"""Returns a single pet""" """Returns a single pet"""
... ...
@ -59,6 +63,7 @@ class BasePetApi:
async def update_pet( async def update_pet(
self, self,
pet: Annotated[Pet, Field(description="Pet object that needs to be added to the store")], pet: Annotated[Pet, Field(description="Pet object that needs to be added to the store")],
token_petstore_auth: str
) -> Pet: ) -> Pet:
"""""" """"""
... ...
@ -66,9 +71,8 @@ class BasePetApi:
async def update_pet_with_form( async def update_pet_with_form(
self, self,
petId: Annotated[StrictInt, Field(description="ID of pet that needs to be updated")], petId: Annotated[StrictInt, Field(description="ID of pet that needs to be updated")], name: Annotated[Optional[StrictStr], Field(description="Updated name of the pet")], status: Annotated[Optional[StrictStr], Field(description="Updated status of the pet")],
name: Annotated[Optional[StrictStr], Field(description="Updated name of the pet")], token_petstore_auth: str
status: Annotated[Optional[StrictStr], Field(description="Updated status of the pet")],
) -> None: ) -> None:
"""""" """"""
... ...
@ -76,9 +80,8 @@ class BasePetApi:
async def upload_file( async def upload_file(
self, self,
petId: Annotated[StrictInt, Field(description="ID of pet to update")], petId: Annotated[StrictInt, Field(description="ID of pet to update")], additional_metadata: Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")], file: Annotated[Optional[Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]]], Field(description="file to upload")],
additional_metadata: Annotated[Optional[StrictStr], Field(description="Additional data to pass to server")], token_petstore_auth: str
file: Annotated[Optional[Union[StrictBytes, StrictStr, Tuple[StrictStr, StrictBytes]]], Field(description="file to upload")],
) -> ApiResponse: ) -> ApiResponse:
"""""" """"""
... ...

View File

@ -72,7 +72,7 @@ async def get_inventory(
"""Returns a map of status codes to quantities""" """Returns a map of status codes to quantities"""
if not BaseStoreApi.subclasses: if not BaseStoreApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BaseStoreApi.subclasses[0]().get_inventory() return await BaseStoreApi.subclasses[0]().get_inventory(token_api_key=token_api_key)
@router.get( @router.get(

View File

@ -16,7 +16,7 @@ class BaseStoreApi:
BaseStoreApi.subclasses = BaseStoreApi.subclasses + (cls,) BaseStoreApi.subclasses = BaseStoreApi.subclasses + (cls,)
async def delete_order( async def delete_order(
self, self,
orderId: Annotated[StrictStr, Field(description="ID of the order that needs to be deleted")], orderId: Annotated[StrictStr, Field(description="ID of the order that needs to be deleted")]
) -> None: ) -> None:
"""For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors""" """For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors"""
... ...
@ -24,6 +24,8 @@ class BaseStoreApi:
async def get_inventory( async def get_inventory(
self, self,
token_api_key: str
) -> Dict[str, int]: ) -> Dict[str, int]:
"""Returns a map of status codes to quantities""" """Returns a map of status codes to quantities"""
... ...
@ -31,7 +33,7 @@ class BaseStoreApi:
async def get_order_by_id( async def get_order_by_id(
self, self,
orderId: Annotated[int, Field(le=5, strict=True, ge=1, description="ID of pet that needs to be fetched")], orderId: Annotated[int, Field(le=5, strict=True, ge=1, description="ID of pet that needs to be fetched")]
) -> Order: ) -> Order:
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions""" """For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions"""
... ...
@ -39,7 +41,7 @@ class BaseStoreApi:
async def place_order( async def place_order(
self, self,
order: Annotated[Order, Field(description="order placed for purchasing the pet")], order: Annotated[Order, Field(description="order placed for purchasing the pet")]
) -> Order: ) -> Order:
"""""" """"""
... ...

View File

@ -54,7 +54,7 @@ async def create_user(
"""This can only be done by the logged in user.""" """This can only be done by the logged in user."""
if not BaseUserApi.subclasses: if not BaseUserApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BaseUserApi.subclasses[0]().create_user(user) return await BaseUserApi.subclasses[0]().create_user(user, token_api_key=token_api_key)
@router.post( @router.post(
@ -75,7 +75,7 @@ async def create_users_with_array_input(
"""""" """"""
if not BaseUserApi.subclasses: if not BaseUserApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BaseUserApi.subclasses[0]().create_users_with_array_input(user) return await BaseUserApi.subclasses[0]().create_users_with_array_input(user, token_api_key=token_api_key)
@router.post( @router.post(
@ -96,7 +96,7 @@ async def create_users_with_list_input(
"""""" """"""
if not BaseUserApi.subclasses: if not BaseUserApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BaseUserApi.subclasses[0]().create_users_with_list_input(user) return await BaseUserApi.subclasses[0]().create_users_with_list_input(user, token_api_key=token_api_key)
@router.delete( @router.delete(
@ -118,7 +118,7 @@ async def delete_user(
"""This can only be done by the logged in user.""" """This can only be done by the logged in user."""
if not BaseUserApi.subclasses: if not BaseUserApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BaseUserApi.subclasses[0]().delete_user(username) return await BaseUserApi.subclasses[0]().delete_user(username, token_api_key=token_api_key)
@router.get( @router.get(
@ -178,7 +178,7 @@ async def logout_user(
"""""" """"""
if not BaseUserApi.subclasses: if not BaseUserApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BaseUserApi.subclasses[0]().logout_user() return await BaseUserApi.subclasses[0]().logout_user(token_api_key=token_api_key)
@router.put( @router.put(
@ -201,4 +201,4 @@ async def update_user(
"""This can only be done by the logged in user.""" """This can only be done by the logged in user."""
if not BaseUserApi.subclasses: if not BaseUserApi.subclasses:
raise HTTPException(status_code=500, detail="Not implemented") raise HTTPException(status_code=500, detail="Not implemented")
return await BaseUserApi.subclasses[0]().update_user(username, user) return await BaseUserApi.subclasses[0]().update_user(username, user, token_api_key=token_api_key)

View File

@ -17,6 +17,7 @@ class BaseUserApi:
async def create_user( async def create_user(
self, self,
user: Annotated[User, Field(description="Created user object")], user: Annotated[User, Field(description="Created user object")],
token_api_key: str
) -> None: ) -> None:
"""This can only be done by the logged in user.""" """This can only be done by the logged in user."""
... ...
@ -25,6 +26,7 @@ class BaseUserApi:
async def create_users_with_array_input( async def create_users_with_array_input(
self, self,
user: Annotated[List[User], Field(description="List of user object")], user: Annotated[List[User], Field(description="List of user object")],
token_api_key: str
) -> None: ) -> None:
"""""" """"""
... ...
@ -33,6 +35,7 @@ class BaseUserApi:
async def create_users_with_list_input( async def create_users_with_list_input(
self, self,
user: Annotated[List[User], Field(description="List of user object")], user: Annotated[List[User], Field(description="List of user object")],
token_api_key: str
) -> None: ) -> None:
"""""" """"""
... ...
@ -41,6 +44,7 @@ class BaseUserApi:
async def delete_user( async def delete_user(
self, self,
username: Annotated[StrictStr, Field(description="The name that needs to be deleted")], username: Annotated[StrictStr, Field(description="The name that needs to be deleted")],
token_api_key: str
) -> None: ) -> None:
"""This can only be done by the logged in user.""" """This can only be done by the logged in user."""
... ...
@ -48,7 +52,7 @@ class BaseUserApi:
async def get_user_by_name( async def get_user_by_name(
self, self,
username: Annotated[StrictStr, Field(description="The name that needs to be fetched. Use user1 for testing.")], username: Annotated[StrictStr, Field(description="The name that needs to be fetched. Use user1 for testing.")]
) -> User: ) -> User:
"""""" """"""
... ...
@ -56,8 +60,7 @@ class BaseUserApi:
async def login_user( async def login_user(
self, self,
username: Annotated[str, Field(strict=True, description="The user name for login")], username: Annotated[str, Field(strict=True, description="The user name for login")], password: Annotated[StrictStr, Field(description="The password for login in clear text")]
password: Annotated[StrictStr, Field(description="The password for login in clear text")],
) -> str: ) -> str:
"""""" """"""
... ...
@ -65,6 +68,8 @@ class BaseUserApi:
async def logout_user( async def logout_user(
self, self,
token_api_key: str
) -> None: ) -> None:
"""""" """"""
... ...
@ -72,8 +77,8 @@ class BaseUserApi:
async def update_user( async def update_user(
self, self,
username: Annotated[StrictStr, Field(description="name that need to be deleted")], username: Annotated[StrictStr, Field(description="name that need to be deleted")], user: Annotated[User, Field(description="Updated user object")],
user: Annotated[User, Field(description="Updated user object")], token_api_key: str
) -> None: ) -> None:
"""This can only be done by the logged in user.""" """This can only be done by the logged in user."""
... ...