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

testingwithnewplan的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依赖关系管理器的版本。

*使用命令行,导航到包含生成文件的目录(包括``` requirements.txt``)用于sdk。
*运行命令``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=20petstore python&projectname=testingwithnewplan)

添加一个新的测试项目

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

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


将目录命名为"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=testingwithnewplan)

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


在python文件中,需要使用以下代码行从testingwithnewplan.testingwithnewplan_client import testingwithnewplanclient导入生成的python库![在PyCharm中添加新项目-步骤4](https://apidocs.io/illustration/python?step=projectfiles&workspacefolder=swagger%20petstore python&libraryname=testingwithnewplan.testingwithnewplan_client&projectname=testingwithnewplan&classname=testingwithnewplanclient)

并进行api调用。示例代码在后续章节中给出。

3.运行测试项目

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

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



y生成的测试
案例。unittest用作测试框架,nose用作测试
运行器。您可以按如下方式运行测试:

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

d
o_auth_redirect_uri oauth 2重定向端点或回调uri





``python
_非统2重定向端点或回调uri



>client=testingwithnewplancclient(o_auth_客户端,o_auth_重定向uri)
``







类参考



;<;a name="list_of_控制器">;<;a>;<;a>;控制器列表



>
*[petcontroller]>[petcontroller]>




是的(#宠物控制器)
*[商店控制器](商店控制器)
*[用户控制器](用户控制器)

lt;a name="宠物控制器">;<;/a>;![类:](https://apidocs.io/img/class.png.pet controller")petcontroller

>;<;/a>;![方法](https://apiddocs.io/img/method.png.petcontroller.add-pet.pet.pet.petcontroller.add-pet)add-pet


>;将新宠物添加到商店


``python
deadd-pet(self,
```














参数标签标签描述

----------|









35 35 35
`` python
body=pet pet()


35;错误

错误代码错误描述
-----————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————[方法:](https://apiddocs.io/img/method.png.petcontroller.update-pet)update-pet

>;更新现有pet

`` python
———--|---关于`````````````````````````````需要添加到商店的宠物物品`````````````````````需要添加到商店的宠物物品``





````````````````````````````````````````````````````````````````````````````````````````````````````````````````错误

错误代码错误描述
-----————————————[方法:](https://apidocs.io/img/method.png).petcontroller.find_pets_by_status")find_pets_by_status

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

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

####参数

|参数标签描述

/>结果=宠物控制器。按宠物状态(状态)查找宠物```









错误代码错误描述;

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

>;可以为多个标记提供逗号分隔的字符串。Use tag1, tag2, tag3 for testing.

```python
def find_pets_by_tags(self,
tags)
```

#### Parameters

| Parameter | Tags | Description |
|-----------|------|-------------|
| tags | ``` Required ``` ``` Collection ``` | Tags to filter by |



#### Example Usage

```python
tags = ['tags']

result = pet_controller.find_pets_by_tags(tags)

```

#### Errors

| Error Code | Error Description |
|------------|-------------------|
| 400 | Invalid tag value |




### <a name="get_pet_by_id"></a>![方法:](https://apiddocs.io/img/method.png.petcontroller.get_pet_-pet_-pet_-pet_-pet_-pet_-pet_-pet-by_-id

>;返回单个宠物

`` python
def get_-pet_-pet_-pet_-pet_-pet-by_-id(self,
>pet-id)
``````
>>

//
——————————————————————————————————————————————————————————————————————————————————d ``` | ID of pet to return |



#### Example Usage

```python
pet_id = 109

result = pet_controller.get_pet_by_id(pet_id)

```

#### Errors

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




[方法:](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)
```

#### Parameters

| Parameter | Tags | Description |
|-----------|------|-------------|
| petId | ``` Required ``` | ID of pet that needs to be updated |
| name | ``` Optional ``` | Updated name of the pet |
| status | ``` Optional ``` | Updated status of the pet |



#### Example Usage

```python
pet_id = 109
name = 'name'
status = 'status'

pet_controller.update_pet_with_form(pet_id, name, status)

```

#### Errors

| Error Code | Error Description |
|------------|-------------------|
| 405 | Invalid input |




### <a name="delete_pet"></a>![方法:](https://apiddocs.io/img/method.png.petcontroller.delete-pet)delete-pet

>;删除宠物


聚乙烯tId | ``` Required ``` | Pet id to delete |
| apiKey | ``` Optional ``` | TODO: Add a parameter description |



#### Example Usage

```python
pet_id = 109
api_key = 'api_key'

pet_controller.delete_pet(pet_id, api_key)

```

#### Errors

| Error Code | Error Description |
|——————————————————————————————————————————————————————————————————————————————————————t找到






\[方法:](https://apiddocs.io/img/method.png.petcontroller.upload-file)upload-u文件上传

>;上传图片上传

描述

示例用法lmetadata'
file=open("pathtofile","rb")


````


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










``python
``store controller=client.store
```

/>`` python
`` storecontroller=client.store
```` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `gt;![方法:](https://apiddocs.io/img/method.png.store controller.get-cuinventory".get-inventory"get-cuinventory

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


`` python
`` python
def-get-cuinventory(self)
````

```python



result=store controller.get-cuinventory()


>
``



\吃点东西">;<;/a>;![方法:](https://apiddocs.io/img/method.png.storecontroller.create预订宠物订单)创建宠物订单


>;为宠物订购订单


``python
/>————————————————————————————————————————————————————————————————————————/>| body | ``` Required ``` | order placed for purchasing the pet |



#### Example Usage

```python
body = Order()

result = store_controller.create_place_order(body)

```

#### Errors

| Error Code | Error Description |
|------------|-------------------|
| 400 | Invalid Order |





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

>;若要获得有效响应,请尝试值为>;=1且<;=10的整数id。Other values will generated exceptions

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

#### Parameters

| Parameter | Tags | Description |
|-----------|------|-------------|
| orderId | ``` Required ``` | ID of pet that needs to be fetched |



#### Example Usage

```python
order_id = 109

result = store_controller.get_order_by_id(order_id)

```

#### Errors

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




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

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


```python
>dedededelete_order(self,
order_id)
``







;需要删除的订单的IDr/>示例用法删除订单(订单号)


````










>错误代码;错误描述

>404订单号


















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

a name="user_controller">;<;/a>;![类:](https://apidocs.io/img/class.png.user controller")usercontroller

"用户">;<;/a>;![方法:](https://apidocs.io/img/method.png.usercontroller.create_user")create_user

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

`` python
def create_user(self,
````

|
|-----------|------|-------------|
| body | ``` Required ``` | Created user object |



#### Example Usage

```python
body = User()

user_controller.create_user(body)

```

#### Errors

| Error Code | Error Description |
|---————————————————————————————————————————————————————————————————————————————————————————————————[方法:](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)
```











参数标签;







































35;示例用法

``python
body=[user()]

带有阵列输入(body)的rs-u阵列输入(body)


```


























//lt;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

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

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



























;示例用法有无列表输入(body)


````












错误代码错误描述






























>;将用户登录到系统中

`` python
def get戡login戡user(self,
用户名,
```


|参数tags `` python
用户名='用户名'
密码='password'




```


``````


` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `/>
<;名称="获取注销用户">;<;/a>;![Method: ](https://apidocs.io/img/method.png ".UserController.get_logout_user") get_logout_user

> Logs out current logged in user session

```python
def get_logout_user(self)
```

#### Example Usage

```python

user_controller.get_logout_user()

```

#### Errors

| Error Code错误描述
----------
0操作成功







<;a name="get_u user_by_name">;<;/a>;![方法:](https://apiddocs.io/img/method.png.usercontroller.get"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"获取"用户名"(self,
```














;说明
————————
用户name ``required````需要获取的名称。使用user1进行测试。|



#### Example Usage

```python
username = 'username'

result = user_controller.get_user_by_name(username)

```

#### Errors

| Error Code | Error Description |
|------------|-------------------|
| 400 | Invalid username supplied |
| 404 | User not found |




[方法:](https://apiddocs.io/img/method.png.usercontroller.update-user".update-user"update-update-user

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


``python
deupdate-user用户(self,
username,
``
``

`` `

` `

` `

` ` ` `

` ` ` ` `>
---|------|-------------|
| username | ``` Required ``` | name that need to be updated |
| body | ``` Required ``` | Updated user object |



#### Example Usage

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

user_controller.update_user(username, body)

```

#### Errors

| Er错误代码错误描述
----------
400提供的用户无效
404找不到用户





[方法:](https://apiddocs.io/img/method.png.usercontroller.delete_user".delete_user"delete用户


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


`` python
`` python
dedelete用户(self,
``
`


` `

` `>
` `
`//` ` ` ` ` ` `
` ` ` ` ` ` ` ` ` ` ` `;————————————————————————————————————————————————————————————————————————sername | ``` Required ``` | The name that needs to be deleted |



#### Example Usage

```python
username = 'username'

user_controller.delete_user(username)

```

#### Errors

| Error Code | Error Description |
|------------|-------------------|
| 400 | Invalid username supplied
404找不到用户





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







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

推荐PyPI第三方库


热门话题
java如何克服带有空值的不可空bean级验证   “此行有多个标记”的authenticateUser上的java MySQLConnection错误   java处理Jackson异常   java Netbeans编辑器如何知道文件在撤消后不会被修改?   目标C相当于Java的ArrayList   java当需要int时,可以将short传递给方法调用吗?   drawString()方法上的java MouseListener   java服务器socket是执行此操作的最佳选项   java需要单个匹配bean,但找到了2:org。springframework。网状物servlet。mvc。方法注释。RequestMappingHandlerMapping   如何在Java中执行Windows命令?   安卓应用程序的java文件主机   java将所有spring引导属性都设置在内。将yml文件转换为系统属性   Java邮件中的html内联链接在邮件客户端中不起作用   Java二进制文件的bazel版本控制   java如何在自定义ListView中使用Intent   java(Spring MVC+Hibernate 4+Test 4)自动连线DAO返回NULL   java一次add()调用可以在Solr服务器中索引多少文档?   java如何获取Avro GenericRecord大小