这是一个示例服务器petstore服务器。您可以在[http://savigig.i](http://sAgAj.IO)或[IRC.FieloDe.NET,Saviggiger-](http://savigig.iO/IRC/)上了解更多关于Sigggg的信息。对于这个示例,可以使用API密钥“特殊密钥”来测试授权筛选器。

anotherstupidpackage的Python项目详细描述


#入门

这是一个示例服务器petstore服务器。您可以在[http://swagger.io](http://swagger.io)或[irc.freenode.net,swagger](http://swagger.io/irc/)上了解有关swagger的更多信息。对于此示例,可以使用API密钥"特殊密钥"测试授权筛选器。

此sdk包依赖于其他python包,如nose、jsonpickle等。
这些依赖项在sdk附带的``requirements.txt``文件中定义。
要解决这些依赖项,可以使用pip依赖项管理器。按照[https://pip.pypa.io/en/stable/installing/](https://pip.pypa.io/en/stable/installing/)中的步骤安装它。

python和pip可执行文件应在路径中定义。打开命令提示符并键入``pip--version``.
如果安装成功并正确定义了路径,则应显示安装的pip依赖关系管理器的版本。

*使用命令行,导航到包含为sdk生成的文件(包括``requirements.txt```)的目录。
*运行命令``pip install-r requirements.txt```。这应该安装所有必需的依赖项。

![构建sdk-步骤1](https://apidocs.io/illustration/python?step=installdependencies&workspacefolder=swagger%20petstore python)



在ide中打开项目

打开python ide,比如pycharm。如果您喜欢使用不同的编辑器或IDE,这里提供的基本工作流也适用。

![在PyCharm中打开项目-步骤1](https://apidocs.io/illustration/python?step=pycharm)

[在PyCharm中打开项目-第2步](https://apidocs.io/illustration/python?step=openproject0&workspacefolder=swagger%20petstore python)


项目文件将显示在侧栏中,如下所示:

![在PyCharm中打开项目-第3步](https://apidocs.io/illustration/python?step=openproject1&workspacefolder=swagger%20petstore python&;projectname=anotherstupidpackage)

2。添加一个新的测试项目

右键单击解决方案名称创建一个新目录,如下所示:

![在PyCharm中添加新项目-步骤1](https://apidocs.io/illustration/python?step=createdirectory&workspacefolder=swagger%20petstore python&;projectname=anotherstupidpackage)


将目录命名为"test"

![在PyCharm中添加新项目-步骤2](https://apidocs.io/illustration/python?step=nameditory)


将一个名为"testsdk"的python文件添加到此项目中

![在PyCharm中添加新项目-步骤3](https://apidocs.io/illustration/python?step=createfile&workspacefolder=swagger%20petstore python&;projectname=anotherstupidpackage)

[在PyCharm中添加新项目-步骤4](https://apidocs.io/illustration/python?step=namefile)


在您的python文件中,需要使用以下代码行从另一个stupidpackage导入生成的python库

``python
。另一个stupidpackage\u客户端导入另一个stupidpackageclient
```

![在PyCharm中添加新项目-步骤4](https://apidocs.io/illustration/python?step=projectfiles&workspacefolder=swagger%20petstore python&libraryname=anotherstupidpackage.anotherstupidpackage\u client&projectname=anotherstupidpackage&classname=anotherstupidpackageclient)

在此之后,您可以编写代码来实例化api客户端对象,获取一个控制器对象并进行api调用。示例代码在后续章节中给出。

3。运行测试项目

若要在测试项目中运行该文件,请右键单击测试项目中的python文件,然后单击"运行"`

![运行测试项目-步骤1](https://apidocs.io/illustation/python?step=runproject&workspacefolder=swagger%20petstore python&libraryname=anotherstupidpackage.anotherstupidpackage\u client&projectname=anotherstupidpackage&;classname=anotherstupidpackageclient)



unittest用作测试框架,nose用作测试
运行器。您可以按如下方式运行测试:

1。从terminal/cmd导航到sdk的根目录。
2。调用``pip install-r test requirements.txt``
3。调用``nosetests``

您需要以下信息。

以下是。

``python
一个有身份的人重定向一个有身份的人)
````



















>
*[store

a name="pet_controller">;<;/a>;![类:](https://apidocs.io/img/class.png.pet controller")petcontroller

\a name="update_pet">;<;/a>;![方法:](https://apidocs.io/img/method.png".petcontroller.update戡pet")update戡pet

>;更新现有的pet

``python
def update戡pet(self,
body)
`````




35 35 35

```````````````````````````````````````````````````````````````````````````````````````````````````示例用法

`` python
body=Pet()

pet_controller.update_pet(body)

```

#### Errors

| Error Code | Error Description |
|------------|-------------------|
| 400 | Invalid ID supplied |
| 404 | Pet not found |
| 405 | Validation exception |




### <a name="add_pet">;<;/a>;![方法:](https://apidocs.io/img/method.png".petcontroller.add撸pet")添加宠物

>;将新宠物添加到商店

``python
def add撸pet(self,
body)
`````




35 35 35

```````````````````````````````````````````````````````````````````````````````````````````````````示例用法

`` python
body=pet()


>
```










<;a name="find_pets_by_status">;<;/a>;![方法:](https://apidocs.io/img/method.png).petcontroller.find_pets_by_status")find_pets_by_status

>;可以为多个状态值提供逗号分隔的字符串

``python
def find_pets_by_status(self,
status)
````





































`` python
状态=[status7enum.available]


result=pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-pet-

& & a & gt;[方法:](https://apidocs.io/img/method.png".petcontroller.find_pets_by_tags")find_pets_by_tags

>;多个标记可以提供逗号分隔的字符串。使用Tag1、Tag2、Tag3进行测试。


``python
defind_宠物_by_宠物_by_宠物(self,
tag)
``









参数标签






\ \35 \35 \ \35 \ \\35 \35 \35 \ \35 35 \35 \35 \\\\35 \ \\\错误描述
----------
400无效标记值|





[方法:](https://apidocs.io/img/method.png".petcontroller.get_pet_by_id")get_pet_by_id

>;返回单个pet

``python
def get_pet_by_id(self,
pet-id)
````






````````````````````````````````````````````````````````````````````````` ` ` `




```

#### Errors

| Error Code | Error Description |
|------------|-------------------|
| 400 | Invalid ID supplied |
| 404 | Pet not found |




### <a name="update_pet_with_form"></a>![方法:](https://apidocs.io/img/method.png).petcontroller.update_pet_with_form")update_pet_with_form

>;使用表单数据更新存储区中的宠物

``python
def update_pet_with_form(self,
pet id,
name=none,
status=none)
````



35 35 35 35 35

``````````````````````````````````````````````````````````````````````````````````````;更新宠物的名称|
status `` optional ```更新宠物的状态







``````









>错误代码错误代码错误描述;




































<







>;删除宠物

`` python
def delete榍pet(self,
pet榍id,
api榍key=none)
```

|
-----````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````br/>API密钥="api_key"

pet_controller.delete_pet(pet_id,api_key)

````

__errors

申请的宠物未找到![方法:](https://apidocs.io/img/method.png".petcontroller.upload撸file")上传撸file

>;上传图像

```python
def upload撸file(self,
pet撸id,
附加撸metadata=none,
file=none)
````




35 35 35 35 35 35

file
file
file
file ``````````````````````````````````````````````````````````````````要传递到服务器的其他数据
|文件``可选````要上载的文件





\pet id=35
其他元数据='其他元数据'
文件=打开("路径文件","rb")

结果=pet控制器。上载文件(pet id,其他元数据,文件)

````


[返回控制器列表](控制器列表)


[类:](https://apidocs.io/img/class.png.store controller")storecontroller

a name="get_inventory">;<;/a>;![方法:](https://apidocs.io/img/method.png".storecontroller.get_inventory")获取库存

>;将状态代码的映射返回到数量


``python
def get_inventory(self)
````


``python
``python


result=store_controller.get_inventory()











//





/>

U订单">;<;/A>;![方法:](https://apidocs.io/img/method.png".storecontroller.create庠place庠order")创建庠place庠order

>;*标记:*```跳过身份验证`````

>;为宠物下单

`` python
def创建庠place order(self,
body)
````




35 35

```````````````````````````````````````````````````````````````````````````````````````````````示例用法

`` python
body=



>result=store-cuu-controller.create-place-cuu-order(body)

```



35 35 35 35 35 35 35 35 35<




















<;a name="get_order_by_id">;<;/a>;![方法:](https://apidocs.io/img/method.png".storecontroller.get_order_by_id")get_order_by_id

>;*标记:*```skips authentication```

>;若要获得有效响应,请尝试值为>;=1和<;=10的整数id。其他值则会生成异常


``python
>defeget_order_order_order_order_order_order_order_id(self,
```



35 35


参数标签







<<



```````````需要宠物的身份证要取






35 35 35 35 35 35 \35 \35 \35 \35 \ \35 \35 \ \ \\\\35 \ \\错误代码错误描述
----------
400无效ID提供的
404未找到订单





\[方法:](https://apidocs.io/img/method.png".storecontroller.delete\order")delete\order

>;*标记:*```跳过身份验证```

>;若要获得有效响应,请尝试使用正整数值的整数ID。负值或非整数值将生成API错误

``` python
def delete_order(self,
order_id)
````

-----|









35 35 35 35 35 35 35 35 35 \35 \35 \ \35 \35 \ \\\35 \\\\错误

错误代码错误描述|
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————[类:](https://apidocs.io/img/class.png.user controller")用户控制器

a name="create_user">;<;/a>;![方法:](https://apidocs.io/img/method.png".usercontroller.create戡user")创建戡user

>;*标记:*```跳过身份验证````

>;这只能由登录用户完成。

`` python
def create戡user(self,
body)
`````





























































35;示例用法

`` python
正文=




```











































<<;a name="create_users_with_array_input">;<;/a>;![方法:](https://apidocs.io/img/method.png".usercontroller.create_users_with_array_input")create_users_with_array_input

>;*标记:*```跳过身份验证``````

>;创建具有给定输入数组的用户列表

`` python
def create_users_with_array_input(self,
body)
``````




















``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````示例



``python
body=[user()]







````























<0操作成功操作成功操作成功操作成功操作成功





a name="create_users_with_list_input">;<;/a>;![方法:](https://apidocs.io/img/method.png".usercontroller.create_users_with_list_input")create_users_with_list_input

>
body)
``````




















``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````示例



``python
body=[user()]







````










用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户用户





a name="get_login_user">;<;/a>;![方法:](https://apidocs.io/img/method.png".usercontroller.get-login-user")get-login-user

>;*标记:"``跳过身份验证````

>;将用户登录到系统

``python
def get-login-user(self,
username,
密码)
```

lear text




\密码)













>错误代码错误描述;
>
>




















>;*标记:*```跳过身份验证````

>;登录当前登录的当前登录用户会话


``` python
def get登录用户(self)
````


`````python












``````````````` python用户(user)控制器.获取登录用户(user)








<<<

错误代码错误描述|
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————[方法:](https://apidocs.io/img/method.png".usercontroller.get_user_by_name")get_user_by_name

>;*标记:*```跳过身份验证````

>;get user by user name

`` python
def get_user_by_name(self,
用户名)
```

使用user1进行测试。|







35 35 35 35 35 35 35 35 \35 \35 \35 \ \ \35 \35 35 35 \ \35 \\\\ \35 \\
用户名无效提供的
404找不到用户




\[方法:](https://apidocs.io/img/method.png.usercontroller.update-user)更新用户

>;*标记:*```跳过身份验证````

>;这只能由登录用户完成。

`` python
def update-user(self,
用户名,
车身)
````````



35

br/>



用法

`` python
username='username'
body=user()




`````








>错误代码错误代码错误描述;































<<;a name="delete_user">;<;/a>;![方法:](https://apidocs.io/img/method.png".usercontroller.delete戡user")删除戡user

>;*标记:*```跳过身份验证````

>;这只能由登录用户完成。

`` python
def delete戡user(self,
username)
`````
















\参数标签标签描述;








































;示例用法

`` python
用户名='username'




```
























```````````````````



br/>



[返回列表控制器](控制器列表)








欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java播放流媒体音乐   LWJGL中的java纹理未显示   java从父集合中删除时删除子对象   mysql希望在我的代码中添加验证,如果表不存在,它应该用java创建新表   java我可以关闭客户端的socket而不引起服务器端的EOFEException吗?   java Primefaces对话框框架咆哮和showMessageInDialog不工作   hadoop配置单元无法初始化类java。网网络接口   关键字中缺少oracle11g Java iBatis   java在RESTAPI中创建PUT和POST端点,而不创建GET端点?   java Math abs和ceil输出编译错误   java Tomcat 8.017代md5及其摘要。球棒   java SpringBean配置xml文件在IteliJ Idea中加载   java为什么在使用Powershell指定Xms和Xmx时,它们什么都不做,但通过Netbeans IDE可以正常工作?   java Drools项目构建失败,kjar打包从7.7版开始