PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

用swagger-php/ui作API测试

原创
2016-06-13 12:14:43 802浏览

用swagger-php/ui做API测试
功能:
1 swagger-php根据自定义的规则生成API请求规则,通过phar生成json文件
2 打开swagger-ui/dist/index.html。输入json文件夹目录地址(需要同源),swagger-ui会根据请求的JSON生成API,页面很漂亮。输入请求参数后执行会获取返回值。
缺点:不能对返回的数据进行验证。功能类似chrome的插件postman。
Api Action测试参考代码:
Resource/PostAction.php


项目描述信息
Info/api.php

readme
# Usage of API Docs### Raw Spec Structure* Info - General Info.* Model - Entity Class* Resource - API endpoint### Compile API info.* after modify the spec, run shell script, as follows.	`cd api-docs`		`./genDocumentation.sh`* the compiled content (.json) is stored in documentation/Output/### View API docs* visit http://{domain}/documenation/


sh 执行文件
#!/bin/sh../swagger-php/swagger.phar ../output-docs -o ../documentation/output/

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。