Skip to content

Commit

Permalink
Add samples
Browse files Browse the repository at this point in the history
  • Loading branch information
lmdevries committed Dec 15, 2024
1 parent 40debfe commit ed3abfe
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ def __init_subclass__(cls, **kwargs):
BaseFakeApi.subclasses = BaseFakeApi.subclasses + (cls,)
async def fake_query_param_default(
self,
has_default: Annotated[Optional[StrictStr], Field(description="has default value")],
no_default: Annotated[Optional[StrictStr], Field(description="no default value")],
has_default: Annotated[Optional[StrictStr], Field(description="has default value")], no_default: Annotated[Optional[StrictStr], Field(description="no default value")]
) -> None:
""""""
...
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def add_pet(
""""""
if not BasePetApi.subclasses:
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(
Expand All @@ -78,7 +78,7 @@ async def delete_pet(
""""""
if not BasePetApi.subclasses:
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(
Expand All @@ -100,7 +100,7 @@ async def find_pets_by_status(
"""Multiple status values can be provided with comma separated strings"""
if not BasePetApi.subclasses:
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(
Expand All @@ -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."""
if not BasePetApi.subclasses:
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(
Expand All @@ -145,7 +145,7 @@ async def get_pet_by_id(
"""Returns a single pet"""
if not BasePetApi.subclasses:
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(
Expand All @@ -169,7 +169,7 @@ async def update_pet(
""""""
if not BasePetApi.subclasses:
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(
Expand All @@ -192,7 +192,7 @@ async def update_pet_with_form(
""""""
if not BasePetApi.subclasses:
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(
Expand All @@ -215,4 +215,4 @@ async def upload_file(
""""""
if not BasePetApi.subclasses:
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)
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ def __init_subclass__(cls, **kwargs):
async def add_pet(
self,
pet: Annotated[Pet, Field(description="Pet object that needs to be added to the store")],
token_petstore_auth: str
) -> Pet:
""""""
...


async def delete_pet(
self,
petId: Annotated[StrictInt, Field(description="Pet id to delete")],
api_key: Optional[StrictStr],
petId: Annotated[StrictInt, Field(description="Pet id to delete")], api_key: Optional[StrictStr],
token_petstore_auth: str
) -> None:
""""""
...
Expand All @@ -35,6 +36,7 @@ async def delete_pet(
async def find_pets_by_status(
self,
status: Annotated[List[StrictStr], Field(description="Status values that need to be considered for filter")],
token_petstore_auth: str
) -> List[Pet]:
"""Multiple status values can be provided with comma separated strings"""
...
Expand All @@ -43,6 +45,7 @@ async def find_pets_by_status(
async def find_pets_by_tags(
self,
tags: Annotated[List[StrictStr], Field(description="Tags to filter by")],
token_petstore_auth: str
) -> List[Pet]:
"""Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing."""
...
Expand All @@ -51,6 +54,7 @@ async def find_pets_by_tags(
async def get_pet_by_id(
self,
petId: Annotated[StrictInt, Field(description="ID of pet to return")],
token_api_key: str
) -> Pet:
"""Returns a single pet"""
...
Expand All @@ -59,26 +63,25 @@ async def get_pet_by_id(
async def update_pet(
self,
pet: Annotated[Pet, Field(description="Pet object that needs to be added to the store")],
token_petstore_auth: str
) -> Pet:
""""""
...


async def update_pet_with_form(
self,
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")],
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")],
token_petstore_auth: str
) -> None:
""""""
...


async def upload_file(
self,
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")],
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")],
token_petstore_auth: str
) -> ApiResponse:
""""""
...
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def get_inventory(
"""Returns a map of status codes to quantities"""
if not BaseStoreApi.subclasses:
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,32 @@ def __init_subclass__(cls, **kwargs):
BaseStoreApi.subclasses = BaseStoreApi.subclasses + (cls,)
async def delete_order(
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:
"""For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors"""
...


async def get_inventory(
self,

token_api_key: str
) -> Dict[str, int]:
"""Returns a map of status codes to quantities"""
...


async def get_order_by_id(
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:
"""For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions"""
...


async def place_order(
self,
order: Annotated[Order, Field(description="order placed for purchasing the pet")],
order: Annotated[Order, Field(description="order placed for purchasing the pet")]
) -> Order:
""""""
...
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def create_user(
"""This can only be done by the logged in user."""
if not BaseUserApi.subclasses:
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(
Expand All @@ -75,7 +75,7 @@ async def create_users_with_array_input(
""""""
if not BaseUserApi.subclasses:
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(
Expand All @@ -96,7 +96,7 @@ async def create_users_with_list_input(
""""""
if not BaseUserApi.subclasses:
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(
Expand All @@ -118,7 +118,7 @@ async def delete_user(
"""This can only be done by the logged in user."""
if not BaseUserApi.subclasses:
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(
Expand Down Expand Up @@ -178,7 +178,7 @@ async def logout_user(
""""""
if not BaseUserApi.subclasses:
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(
Expand All @@ -201,4 +201,4 @@ async def update_user(
"""This can only be done by the logged in user."""
if not BaseUserApi.subclasses:
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)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init_subclass__(cls, **kwargs):
async def create_user(
self,
user: Annotated[User, Field(description="Created user object")],
token_api_key: str
) -> None:
"""This can only be done by the logged in user."""
...
Expand All @@ -25,6 +26,7 @@ async def create_user(
async def create_users_with_array_input(
self,
user: Annotated[List[User], Field(description="List of user object")],
token_api_key: str
) -> None:
""""""
...
Expand All @@ -33,6 +35,7 @@ async def create_users_with_array_input(
async def create_users_with_list_input(
self,
user: Annotated[List[User], Field(description="List of user object")],
token_api_key: str
) -> None:
""""""
...
Expand All @@ -41,39 +44,41 @@ async def create_users_with_list_input(
async def delete_user(
self,
username: Annotated[StrictStr, Field(description="The name that needs to be deleted")],
token_api_key: str
) -> None:
"""This can only be done by the logged in user."""
...


async def get_user_by_name(
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:
""""""
...


async def login_user(
self,
username: Annotated[str, Field(strict=True, description="The user name for login")],
password: Annotated[StrictStr, Field(description="The password for login in clear text")],
username: Annotated[str, Field(strict=True, description="The user name for login")], password: Annotated[StrictStr, Field(description="The password for login in clear text")]
) -> str:
""""""
...


async def logout_user(
self,

token_api_key: str
) -> None:
""""""
...


async def update_user(
self,
username: Annotated[StrictStr, Field(description="name that need to be deleted")],
user: Annotated[User, Field(description="Updated user object")],
username: Annotated[StrictStr, Field(description="name that need to be deleted")], user: Annotated[User, Field(description="Updated user object")],
token_api_key: str
) -> None:
"""This can only be done by the logged in user."""
...

0 comments on commit ed3abfe

Please sign in to comment.