-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
197 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> | ||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> | ||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> | ||
<classpathentry kind="output" path="WebContent/WEB-INF/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# RAP 平台使用手册 | ||
目前文档还不是很全, 可能也比较杂乱, 请大家多多包涵... | ||
|
||
## 本地部署 RAP 平台(J2EE Web) | ||
1. 准备 MySQL一枚, tomcat7 一个 | ||
2. 连接到你的MySQL新增数据库(Schema) -> BosnAutoPlatformDB | ||
|
||
修改 [src/mysql.local.properties] 中连接数据库的用户名和密码 | ||
3. 初始化数据库(src/database) | ||
|
||
通过SQL工具连接到上面你新增的数据库依次执行如下SQL: | ||
|
||
1) create-table.sql | ||
|
||
2) create-procedure.sql | ||
|
||
3) test-data.sql | ||
|
||
4) update.sql | ||
4. 打个war包发布到tomcat7, 启动试试 | ||
|
||
例如打包为RAP.war, 发布到tomcat7后访问地址为: http://localhost:8080/RAP | ||
5. 如果页面打开正常, 那么就可以体验 RAP 平台中的功能了 | ||
|
||
登录用户: test | ||
|
||
登录密码: 123456 | ||
|
||
登录成功后可以将Dashboard中的项目全部删掉(原来自带的示例都没办法正常使用, 数据库表 tb_project 中未初始化 project_data JSON) | ||
|
||
接着就可以新建一个项目, 万事OK啦. | ||
|
||
|
||
## 在接口详情中定义mock数据 | ||
RAP通过 [Mock.js] 来生成mock数据 | ||
1. 打开Mock按钮, 显示mock信息 | ||
2. 可以在变量名中定义数次, 例如 dddd|5 | ||
3. 可以在备注中定义mock占位符, 例如 @mock=@datetime | ||
|
||
更多用法请参考 [Mock.Random] 提供的完整方法(占位符) | ||
4. 还可以参考 [rapActionSample.js] | ||
|
||
|
||
|
||
## 与业务系统集成使用RAP中定义的接口 | ||
具体示例请参考: [rap-plugin-example.html] 或 [mock.plugin/index.htm] | ||
|
||
可能碰到的问题 | ||
|
||
1. 不能在一个页面中同时引入2个项目的RAP插件 | ||
例如 | ||
```html | ||
<script src="http://localhost:8080/RAP/rap.plugin.js?projectId=10"></script> | ||
<script src="http://localhost:8080/RAP/rap.plugin.js?projectId=11"></script> | ||
``` | ||
这样会造成报错errMsg: "no matched action" | ||
|
||
不过一般都不会有这样的使用场景, 每个项目都应该单独测试使用, 不会出现混合的情况 | ||
|
||
|
||
## 项目接口定义的JSON示例 | ||
保存在tb_project表的project_data字段, 具体示例请参考: [project_data_example.json] | ||
|
||
|
||
|
||
[src/mysql.local.properties]:https://github.com/ufologist/RAP/src/mysql.local.properties | ||
[Mock.js]:http://mockjs.com/ | ||
[Mock.Random]:http://mockjs.com/#Mock.Random | ||
[rapActionSample.js]:https://github.com/ufologist/RAP/rapActionSample.js | ||
[rap-plugin-example.html]:https://github.com/ufologist/RAP/rap-plugin-example.html | ||
[mock.plugin/index.htm]:https://github.com/ufologist/RAP/WebContent/demo/mock.plugin/index.htm | ||
[project_data_example.json]:https://github.com/ufologist/RAP/project_data_example.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,42 @@ | ||
Rigel Automation Platform | ||
=== | ||
接口服务平台, 能够方便地定义出对外的(HTTP)接口服务, 支持模拟接口数据, 让前/后端针对这些定义的接口并行开发, 打造以接口为中心的开发模式 | ||
|
||
@version v0.8.1 | ||
@author Bosn(霍雍), wangjeaf(思竹) | ||
@weibo http://weibo.com/bosn, http://github.com/wangjeaf | ||
@version v0.8.2(由THX RAP v0.8.1-2014-4-18版本修改而来) | ||
@author Bosn(霍雍), wangjeaf(思竹), Sun | ||
@weibo http://weibo.com/bosn, http://github.com/wangjeaf, https://github.com/ufologist | ||
@mail [email protected], [email protected] | ||
|
||
|
||
什么是RAP? | ||
-------------------------------------- | ||
|
||
在前后端分离的开发模式下,我们通常需要定义一份`接口文档`来规范接口的具体信息。如一个请求的地址、有几个参数、参数名称及类型含义等等。`RAP` 首先方便团队录入、查看和管理这些接口文档,并通过分析结构化的文档数据,重复利用并生成自测数据、提供自测控制台等等... 大幅度提升开发效率。 | ||
|
||
[详细介绍](https://github.com/ufologist/RAP/INTRO.md) | ||
|
||
为什么fork了一份? | ||
-------------------------------------- | ||
答曰: 方便本地部署自己的RAP, 暂且叫这个版本为RAP-Local吧 | ||
|
||
话说在 2014年4月17号, 我逛到THX发现了这个项目, 马上就被其深深地吸引住了. | ||
|
||
RAP项目提供了多么实在的功能啊, 对于维护接口文档的各种痛, 相信大家都懂的. | ||
|
||
在翻看了相关文档和视频资料后, 内心那个激动啊, 但那时RAP还不能体验/安装, 是属于alibaba内部的系统. | ||
|
||
因此只能clone下项目试着自己本地部署一套了, 迫不及待地就开始着各种折腾, 各种缺少安装文档(由于RAP是最新项目, 文档还未完善)什么的, 那都是浮云啊... | ||
|
||
在调试本地可部署版的时候, 和 [Bosn](http://weibo.com/bosn) 做了很多交流, 最终得以正常发布, 非常感谢. | ||
|
||
主要的修改为 | ||
1. 增加了使用(部署)手册 | ||
2. 精简了初始化的数据配置及修复了一些数据问题 | ||
3. 增强了Web项目可以带contextPath来部署 | ||
原本只能部署在ROOT下, 但有些不方便, 例如想部署为RAPXX之类的, 就麻烦了 | ||
4. 修复了一些定死的URL | ||
|
||
|
||
相关文档 | ||
-------------------------------------- | ||
- [文档中心](http://thx.alibaba-inc.com/RAP/) | ||
- [使用手册](https://github.com/ufologist/RAP/MANUAL.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"createDateStr": "2014-04-17", | ||
"user": { | ||
"name": "test", | ||
"id": 1 | ||
}, | ||
"id": 10, | ||
"version": "0.0.0.1", | ||
"introduction": "", | ||
"name": "某项目", | ||
"moduleList": [ | ||
{ | ||
"id": 11, | ||
"introduction": "", | ||
"name": "某模块", | ||
"pageList": [ | ||
{ | ||
"id": 15, | ||
"introduction": "", | ||
"name": "某页面", | ||
"actionList": [ | ||
{ | ||
"id": 21, | ||
"name": "某请求", | ||
"description": "", | ||
"requestType": "1", | ||
"requestUrl": "", | ||
"responseTemplate": "", | ||
"requestParameterList": [ | ||
{ | ||
"id": 69, | ||
"identifier": "reqParam", | ||
"name": "某请求参数", | ||
"remark": "", | ||
"parameterList": [], | ||
"validator": "", | ||
"dataType": "number" | ||
} | ||
], | ||
"responseParameterList": [ | ||
{ | ||
"id": 70, | ||
"identifier": "resParam", | ||
"name": "某响应参数", | ||
"remark": "", | ||
"parameterList": [], | ||
"validator": "", | ||
"dataType": "number" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>使用RAP插件来调用(mock)接口</title> | ||
</head> | ||
<body> | ||
<!-- ajax lib, 随便你用什么, 只要能做ajax就行, 你直接用xhr也没人拦你 --> | ||
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | ||
<!-- RAP插件地址, 会重写ajax方法拦截请求 --> | ||
<script src="http://localhost:8080/RAP/rap.plugin.js?projectId=10"></script> | ||
<!-- 临时屏蔽RAP插件, 添加mode=0这个参数(默认处于模式3) | ||
其他模式还有 | ||
0-disabled, 1-intercept all requests, 2-black list, 3-white list | ||
<script src="http://localhost:8080/RAP/rap.plugin.js?projectId=10&mode=0"></script> | ||
--> | ||
<script> | ||
// 对应 RAP 中设置的请求链接 -> /v1/users, 可以查看rap.plugin.js中生成的所有whiteList | ||
$.getJSON('/v1/users', function(data) { | ||
document.body.innerHTML = JSON.stringify(data, null, 4); | ||
console.log(data); | ||
}); | ||
</script> | ||
</body> | ||
</html> |