swagger-inspetor
swagger inspetor是API测试和生成文档的工具,官网地址swagger inspector
说明
- 尚未开源
- B/S架构,浏览器中完成API测试
- 无法本地搭建,只能使用swagger云服务
- 可以测试HTTP/HTTPS/webservice
- 如果有swaggerhub账号(可以用github账号替代),可以保存测试记录到云服务中,随时随地登录可查看
- 测试记录可生成API文档保存到swaggerhub中
swagger-inspector使用方法
swagger-inspector主界面

未登录的情况下也可是使用,在当前会话中可以保存测试记录

登录
登录可以选择swaggerhub账号,也可以直接使用github账号登录。

如果已经使用过inspector测试,登录后可以查看到所有的测试历史记录、测试集(自定义的部分API作为一个集合)。


创建API请求
- 选择合适的请求方式,比如GET、DELETE、POST等;
- 填写API URI;
- 如果没有任何认证、参数,直接点击“send”即可;
- 如果有参数,在Request下方有Parameters(参数)、Authentication&Headers(认证方式和头信息)、body(消息体),根据需要填写;

Request
parameters:查询参数,在这里输入的参数会自动拼接到URI后面,这种方式只是为了方便查看,实际请求中并不会重复。

Authentication & Headers :设置认证和请求头信息。选择Basic authentication,可以设置用户名和密码;选择OAuth 2.0或者JWT(Json web token),可以设置token和头信息完成认证;其他认证直接选择no authentication,任意设置头信息。


Body :请求消息体
加载OpenAPI、WSDL文件
YMAL、JSON、WSDL文件都可以直接加载定义好的API




创建definitions
可以自定义或者使用其他工具编写,这里只介绍从inspector导入。

点击“GO TO SWAGGERHUB”进入swaggerhub,导入inspector生成的definitions,在swaggerhub中可以继续编辑,测试,维护API文档。



右边是API测试操作区域,可以看到测试结果数据。

网友评论