Skip to content

Commit

Permalink
docs: upgrade docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkqm committed Dec 1, 2022
1 parent fcb081e commit 03365b7
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 30 deletions.
49 changes: 25 additions & 24 deletions docs/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,31 @@
- 文件名称: .yapix
- 文件格式: properties
#### 配置项
| 名称 | 类型 | 描述 | 备注 |
|:---------------------| :--- |:--------------------------|:------------------------------------------|
| yapiProjectId | integer | YApi项目id |
| rap2ProjectId | integer | Rap2项目id |
| eolinkerProjectId | string | Eolinker项目id |
| showdocProjectId | string | ShowDoc项目id |
| | | |
| yapiUrl | string | YApi服务地址 | 场景:插件无法支持YApi统一登录方式,此时可使用项目token方式 |
| yapiProjectToken | string | YApi项目访问token |
| | | |
| strict | boolean | 是否开启严格模式, true(默认), false | 严格模式下不会解析无分类、无接口名的 |
| | | |
| returnWrapType | string | 方法返回值,统一包装类限定名 | 场景: spring统一配置了返回包装类 |
| returnUnwrapTypes | string | 方法返回值,指定不需要包装的类 | 场景: 某些类不需要spring统一包装, 多个用英文逗号分割 |
| parameterIgnoreTypes | list<string> | 方法参数忽略的类全称 | 场景: 某些方法参数不是由浏览器客户端上传到 |
| requestBodyParamType | string | 简化请求参数json自定义注解(io.your.RequestBodyParam#value) | 场景: 自定义注解,实现简单json请求参数避免使用@RequestBody需要包装一个实体 |
| | | |
| dateTimeFormatMvc | string | 默认返回时间格式(表单) | 默认格式: yyyy-MM-dd HH:mm:ss, 时间轴配置: integer |
| dateTimeFormatJson | string | 默认返回时间格式(json) | 默认格式: yyyy-MM-dd HH:mm:ss, 时间轴配置: integer |
| dateFormat | string | 默认返回时间格式(LocalDate) | 默认格式: yyyy-MM-dd |
| timeFormat | string | 默认返回时间格式(LocalTime) | 默认格式: HH:mm:ss |
| | | |
| beans[X] | BeanCustom | 自定义bean配置 |
| mockRules | List<MockRule> | 自定义mock规则 |
| 名称 | 类型 | 描述 | 备注 |
|:---------------------|:------------------|:------------------------------------------------|:------------------------------------------|
| yapiProjectId | integer | YApi项目id |
| rap2ProjectId | integer | Rap2项目id |
| eolinkerProjectId | string | Eolinker项目id |
| showdocProjectId | string | ShowDoc项目id |
| | | |
| yapiUrl | string | YApi服务地址 | 场景:插件无法支持YApi统一登录方式,此时可使用项目token方式 |
| yapiProjectToken | string | YApi项目访问token |
| | | |
| strict | boolean | 是否开启严格模式, true(默认), false | 严格模式下不会解析无分类、无接口名的 |
| path | string | 全局接口路径前缀 | 严格模式下不会解析无分类、无接口名的 |
| | | |
| returnWrapType | string | 方法返回值,统一包装类限定名 | 场景: spring统一配置了返回包装类 |
| returnUnwrapTypes | string | 方法返回值,指定不需要包装的类 | 场景: 某些类不需要spring统一包装, 多个用英文逗号分割 |
| parameterIgnoreTypes | list<string> | 方法参数忽略的类全称 | 场景: 某些方法参数不是由浏览器客户端上传到 |
| requestBodyParamType | string | 简化请求参数json自定义注解(io.your.RequestBodyParam#value) | 场景: 自定义注解,实现简单json请求参数避免使用@RequestBody需要包装一个实体 |
| | | |
| dateTimeFormatMvc | string | 默认返回时间格式(表单) | 默认格式: yyyy-MM-dd HH:mm:ss, 时间轴配置: integer |
| dateTimeFormatJson | string | 默认返回时间格式(json) | 默认格式: yyyy-MM-dd HH:mm:ss, 时间轴配置: integer |
| dateFormat | string | 默认返回时间格式(LocalDate) | 默认格式: yyyy-MM-dd |
| timeFormat | string | 默认返回时间格式(LocalTime) | 默认格式: HH:mm:ss |
| | | |
| beans[X] | BeanCustom | 自定义bean配置 |
| mockRules | List<MockRule> | 自定义mock规则 |

#### beans
- 概述: 自定义bean配置, Map类型: Key是类限定名, Value是配置项
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/io/apidocx/config/ApidocxConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public class ApidocxConfig {
*/
private boolean strict = true;

/**
* 路径前缀
*/
private String path;

/**
* yapi项目id
*/
Expand Down Expand Up @@ -143,11 +148,12 @@ public RequestBodyParamType(String type) {
public static ApidocxConfig fromProperties(Properties properties) {
Splitter splitter = Splitter.on(",").trimResults().omitEmptyStrings();
String strict = properties.getProperty("strict", "");
String path = properties.getProperty("path", null);
String yapiProjectId = properties.getProperty("yapiProjectId", "");
String yapiUrl = properties.getProperty("yapiUrl", "");
String yapiProjectToken = properties.getProperty("yapiProjectToken", "");
String rap2ProjectId = properties.getProperty("rap2ProjectId", "");
String eolinkerProjectId = properties.getProperty("eolinkerProjectId", "");
String eolinkProjectId = properties.getProperty("eolinkerProjectId", "");
String showdocProjectId = properties.getProperty("showdocProjectId", "");
String apifoxProjectId = properties.getProperty("apifoxProjectId", "");
String returnWrapType = properties.getProperty("returnWrapType", "");
Expand All @@ -164,11 +170,12 @@ public static ApidocxConfig fromProperties(Properties properties) {
if (StringUtils.isNotEmpty(strict)) {
config.strict = Boolean.parseBoolean(strict);
}
config.setPath(path);
config.yapiUrl = yapiUrl.trim();
config.yapiProjectToken = yapiProjectToken.trim();
config.yapiProjectId = yapiProjectId.trim();
config.rap2ProjectId = rap2ProjectId.trim();
config.eolinkProjectId = eolinkerProjectId.trim();
config.eolinkProjectId = eolinkProjectId.trim();
config.showdocProjectId = showdocProjectId.trim();
config.apifoxProjectId = apifoxProjectId.trim();
config.returnWrapType = returnWrapType.trim();
Expand Down Expand Up @@ -218,6 +225,7 @@ public static ApidocxConfig getMergedInternalConfig(ApidocxConfig settings) {

ApidocxConfig config = new ApidocxConfig();
config.setStrict(settings.isStrict());
config.setPath(settings.getPath());
config.setYapiUrl(settings.getYapiUrl());
config.setYapiProjectId(settings.getYapiProjectId());
config.setYapiProjectToken(settings.getYapiProjectToken());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ private ApiDetail getApiDetail(Long projectId, String folderPath, String title,
if (apiItem == null) {
// 同分类下: method+path, title
apiItem = folderApis.stream().filter(ApiTreeItem::isApiType)
.filter(item -> StringUtils.equals(item.getApi().getMethod(), method)
&& StringUtils.equals(item.getApi().getPath(), path))
.filter(item -> StringUtils.equals(item.getName(), title))
.filter(item -> (StringUtils.equals(item.getApi().getMethod(), method) && StringUtils.equals(item.getApi().getPath(), path))
|| StringUtils.equals(item.getName(), title))
.findFirst()
.orElse(null);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/apidocx/parse/ApiParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ public class ApiParser {
private final ParseHelper parseHelper;
private final Project project;
private final Module module;
private final ApidocxConfig settings;

public ApiParser(Project project, Module module, ApidocxConfig settings) {
checkNotNull(project);
checkNotNull(module);
checkNotNull(settings);
this.project = project;
this.module = module;
this.settings = settings;
this.requestParser = new RequestParser(project, module, settings);
this.responseParser = new ResponseParser(project, module, settings);
this.parseHelper = new ParseHelper(project, module);
Expand Down Expand Up @@ -131,6 +133,9 @@ private MethodApiData doParseMethod(PsiMethod method, ClassLevelApiInfo classLev
}
api.setMethod(pathInfo.getMethod());
api.setPath(PathUtils.path(classLevelInfo.getPath(), path));
if (this.settings.getPath() != null) {
api.setPath(PathUtils.path(this.settings.getPath(), api.getPath()));
}
api.setCategory(classLevelInfo.getCategory());
return api;
}).collect(Collectors.toList());
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@
<change-notes><![CDATA[
1.1.0: <br>
- feat: 支持上传到Apifox<br>
- refactor: 优化重构代码和重命名插件<br>
- feat: 支持配置全局路径前缀<br>
- fix: 复制为cURL严格模式问题<br>
- refactor: 优化重构代码和重命名插件<br>
<br>
1.0.0: <br>
- feat: 支持更多常量枚举解析<br>
Expand Down

0 comments on commit 03365b7

Please sign in to comment.