Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hey, I am not the most experienced, so sorry if my question is a bit trivial.
I generated a client of the pet store api to practice the usage, (https://petstore3.swagger.io/)
I tried to use the api with that code:


client = Client(base_url="https://petstore3.swagger.io")

from swagger_petstore_open_api_3_0_client.models import FindPetsByStatusStatus
from swagger_petstore_open_api_3_0_client.api.pet import find_pets_by_status
from swagger_petstore_open_api_3_0_client.types import Response
status = FindPetsByStatusStatus.AVAILABLE
    
with client as client:
    my_data: FindPetsByStatusStatus = find_pets_by_status.sync(client=client, status=status)
    print("Pet Data:")
    print(my_data)
    response: Response[FindPetsByStatusStatus] = find_pets_by_status.sync_detailed(client=client, status=status)
    print("Response Status Code:", response.status_code)

Unfortunately I get the output
"Pet Data: None
Response Status Code: 404"
Is there something that I am missing from the usage?

You must be logged in to vote

Replies: 1 comment

Comment options

i think with client as client: might be your problem, try with client as c: and then provide the c object to the sync call, you probably have a clashing/scoping variable name issue in that with block

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.