Skip to content

Commit

Permalink
release 2.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
shalousun committed Jul 29, 2023
1 parent e7215c7 commit ad2bf80
Show file tree
Hide file tree
Showing 19 changed files with 172 additions and 85 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>smart-doc</artifactId>
<packaging>jar</packaging>
<version>2.7.3</version>
<version>2.7.4</version>

<name>smart-doc</name>
<url>https://github.com/smart-doc-group/smart-doc.git</url>
Expand Down Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>com.ibeetl</groupId>
<artifactId>beetl</artifactId>
<version>3.15.4.RELEASE</version>
<version>3.15.7.RELEASE</version>
</dependency>
<dependency>
<groupId>com.github.shalousun</groupId>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public class HtmlApiDocBuilder {

private static final String ERROR_CODE_HTML = "error.html";
private static final String DICT_HTML = "dict.html";
private static final long now = System.currentTimeMillis();
private static String INDEX_HTML = "index.html";

/**
Expand Down
48 changes: 27 additions & 21 deletions src/main/java/com/power/doc/builder/PostmanJsonBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ private static ItemBean buildItemBean(ApiDoc apiDoc) {
List<ItemBean> itemBeans = new ArrayList<>();
List<ApiMethodDoc> apiMethodDocs = apiDoc.getList();
apiMethodDocs.forEach(
apiMethodDoc -> {
ItemBean itemBean1 = buildItem(apiMethodDoc);
itemBeans.add(itemBean1);
}
apiMethodDoc -> {
ItemBean itemBean1 = buildItem(apiMethodDoc);
itemBeans.add(itemBean1);
}
);
itemBean.setItem(itemBeans);
return itemBean;
Expand Down Expand Up @@ -142,11 +142,17 @@ private static UrlBean buildUrlBean(ApiMethodDoc apiMethodDoc) {
String url = Optional.ofNullable(apiMethodDoc.getRequestExample().getUrl()).orElse(apiMethodDoc.getUrl());
urlBean.setRaw(DocPathUtil.toPostmanPath(url));
String shortUrl = DocPathUtil.toPostmanPath(apiMethodDoc.getPath());
String[] paths = shortUrl.split("/");
String[] paths;
if (StringUtil.isNotEmpty(shortUrl)) {
paths = shortUrl.split("/");
} else {
paths = new String[0];
}
List<String> pathList = new ArrayList<>();
String serverPath = CollectionUtil.isNotEmpty(urlBean.getPath()) ? urlBean.getPath().get(0) : "";
// Add server path
if (CollectionUtil.isNotEmpty(urlBean.getPath()) && !shortUrl.contains(serverPath)) {
if (CollectionUtil.isNotEmpty(urlBean.getPath()) && StringUtil.isNotEmpty(shortUrl)
&& !shortUrl.contains(serverPath)) {
String[] serverPaths = serverPath.split("/");
pathList.addAll(Arrays.asList(serverPaths));
}
Expand All @@ -156,15 +162,15 @@ private static UrlBean buildUrlBean(ApiMethodDoc apiMethodDoc) {
pathList.add(str);
}
}
if (shortUrl.endsWith("/")) {
if (StringUtil.isNotEmpty(shortUrl) && shortUrl.endsWith("/")) {
pathList.add("");
}

urlBean.setPath(pathList);

List<ParamBean> queryParams = new ArrayList<>();
if (!apiMethodDoc.getType().equals(Methods.POST.getValue()) ||
apiMethodDoc.getContentType().contains(DocGlobalConstants.JSON_CONTENT_TYPE)) {
apiMethodDoc.getContentType().contains(DocGlobalConstants.JSON_CONTENT_TYPE)) {
for (ApiParam apiParam : apiMethodDoc.getQueryParams()) {
ParamBean queryParam = new ParamBean();
queryParam.setDescription(apiParam.getDesc());
Expand Down Expand Up @@ -236,15 +242,15 @@ private static List<HeaderBean> buildHeaderBeanList(ApiMethodDoc apiMethodDoc) {
List<HeaderBean> headerBeans = new ArrayList<>();
List<ApiReqParam> headers = apiMethodDoc.getRequestHeaders();
headers.forEach(
apiReqHeader -> {
HeaderBean headerBean = new HeaderBean();
headerBean.setKey(apiReqHeader.getName());
headerBean.setName(apiReqHeader.getName());
headerBean.setValue(apiReqHeader.getValue());
headerBean.setDisabled(!apiReqHeader.isRequired());
headerBean.setDescription(apiReqHeader.getDesc());
headerBeans.add(headerBean);
}
apiReqHeader -> {
HeaderBean headerBean = new HeaderBean();
headerBean.setKey(apiReqHeader.getName());
headerBean.setName(apiReqHeader.getName());
headerBean.setValue(apiReqHeader.getValue());
headerBean.setDisabled(!apiReqHeader.isRequired());
headerBean.setDescription(apiReqHeader.getDesc());
headerBeans.add(headerBean);
}
);

return headerBeans;
Expand All @@ -257,10 +263,10 @@ private static void postManCreate(ApiConfig config, ProjectDocConfigBuilder conf
requestItem.setInfo(new InfoBean(config.getProjectName()));
List<ItemBean> itemBeans = new ArrayList<>();
apiDocList.forEach(
apiDoc -> {
ItemBean itemBean = buildItemBean(apiDoc);
itemBeans.add(itemBean);
}
apiDoc -> {
ItemBean itemBean = buildItemBean(apiDoc);
itemBeans.add(itemBean);
}
);
requestItem.setItem(itemBeans);
String filePath = config.getOutPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@

package com.power.doc.builder.openapi;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import com.power.common.util.CollectionUtil;
import com.power.common.util.StringUtil;
import com.power.doc.builder.DocBuilderTemplate;
Expand All @@ -45,6 +36,8 @@
import com.power.doc.utils.OpenApiSchemaUtil;
import com.thoughtworks.qdox.JavaProjectBuilder;

import java.util.*;

import static com.power.doc.constants.DocGlobalConstants.*;


Expand Down
12 changes: 3 additions & 9 deletions src/main/java/com/power/doc/builder/openapi/OpenApiBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,8 @@
*/
package com.power.doc.builder.openapi;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import com.power.common.util.CollectionUtil;
import com.power.common.util.FileUtil;
import com.power.common.util.StringUtil;
import com.power.doc.constants.DocGlobalConstants;
import com.power.doc.constants.Methods;
import com.power.doc.helper.JavaProjectBuilderHelper;
Expand All @@ -43,6 +34,9 @@
import com.thoughtworks.qdox.JavaProjectBuilder;
import org.apache.commons.lang3.StringUtils;

import java.util.*;
import java.util.stream.Collectors;

import static com.power.doc.constants.DocGlobalConstants.*;

/**
Expand Down
16 changes: 3 additions & 13 deletions src/main/java/com/power/doc/builder/openapi/SwaggerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,21 @@
*/
package com.power.doc.builder.openapi;

import java.util.*;

import com.power.common.util.CollectionUtil;
import com.power.common.util.FileUtil;
import com.power.common.util.StringUtil;
import com.power.doc.builder.DocBuilderTemplate;
import com.power.doc.builder.ProjectDocConfigBuilder;
import com.power.doc.constants.DocGlobalConstants;
import com.power.doc.factory.BuildTemplateFactory;
import com.power.doc.helper.JavaProjectBuilderHelper;
import com.power.doc.model.ApiConfig;
import com.power.doc.model.ApiDoc;
import com.power.doc.model.ApiGroup;
import com.power.doc.model.ApiMethodDoc;
import com.power.doc.model.ApiParam;
import com.power.doc.model.ApiReqParam;
import com.power.doc.model.*;
import com.power.doc.model.openapi.OpenApiTag;
import com.power.doc.template.IDocBuildTemplate;
import com.power.doc.utils.DocUtil;
import com.power.doc.utils.JsonUtil;
import com.power.doc.utils.OpenApiSchemaUtil;
import com.thoughtworks.qdox.JavaProjectBuilder;
import com.thoughtworks.qdox.model.JavaClass;
import org.apache.commons.lang3.StringUtils;

import java.util.*;

import static com.power.doc.constants.DocGlobalConstants.*;


Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/power/doc/constants/JAXRSAnnotations.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package com.power.doc.constants;

/**
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/power/doc/constants/SolonAnnotations.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package com.power.doc.constants;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/power/doc/constants/TornaConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
*/
public class TornaConstants {


public static final String ID = "id";
public static final String CODE = "code";
public static final String MESSAGE = "msg";
Expand All @@ -62,6 +61,7 @@ public class TornaConstants {
public static final String PUSH = "doc.push";

public static final String ENUM_PUSH = "enum.batch.push";

/**
* torna文件数组类型
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package com.power.doc.extension.json;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static <T> IDocBuildTemplate getDocBuildTemplate(String framework) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
throw new RuntimeException(
"The class=>" + className + " is not found , smart-doc currently supported framework name can only be set in [dubbo, spring].");
"The class=>" + className + " is not found , smart-doc currently supported framework name can only be set in [dubbo, spring,solon,JAX-RS].");
}
return null;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/power/doc/function/RequestMappingFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
import com.power.doc.model.request.RequestMapping;
import com.thoughtworks.qdox.model.JavaClass;


/**
* beetl template function
* @author yu 2022/12/02.
*/

@FunctionalInterface
public interface RequestMappingFunc {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
package com.power.doc.model.framework;

/**
* @author yusun 2021/06/30.
*/
public class PageableAsQueryParam {

/**
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/com/power/doc/model/openapi/OpenApiTag.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package com.power.doc.model.openapi;

import java.util.Objects;
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/power/doc/model/request/JaxrsPathMapping.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*
* smart-doc https://github.com/smart-doc-group/smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.power.doc.model.request;

/**
Expand Down
Loading

0 comments on commit ad2bf80

Please sign in to comment.